text: import * as types from '../constants/collections'
  
  export const collectionListReducer = (state = { collections: [] }, action) => {
  	switch (action.type) {
  		case types.COLLECTION_LIST_REQUEST:
  			return { loading: true, collections: [] }
  		case types.COLLECTION_LIST_SUCCESS:
  			return {
  				loading: false,
  				collections: action.payload,
  			}
  		case types.COLLECTION_LIST_FAIL:
  			return { loading: false, error: action.payload }
  		case types.COLLECTION_RESET:
  			return { loading: false }
  		default:
  			return state
  	}
  }
  
  export const collectionProductsReducer = (state = { products: [] }, action) => {
  	switch (action.type) {
  		case types.COLLECTION_PRODUCTS_REQUEST:
  			return { loading: true, products: [] }
  		case types.COLLECTION_PRODUCTS_SUCCESS:
  			return {
  				loading: false,
  				products: action.payload.products,
  				pageNumber: action.payload.pageNumber,
  				pages: action.payload.pages,
  			}
  		case types.COLLECTION_PRODUCTS_FAIL:
  			return { loading: false, error: action.payload }
  
  		default:
  			return state
  	}
  }
  
  export const collectionCreateReducer = (state = {}, action) => {
  	switch (action.type) {
  		case types.COLLECTION_CREATE_REQUEST:
  			return { loading: true }
  		case types.COLLECTION_CREATE_SUCCESS:
  			return { loading: false, collection: action.payload }
  		case types.COLLECTION_CREATE_FAIL:
  			return { loading: false, error: action.payload }
  		case types.COLLECTION_RESET:
  			return { loading: false }
  
  		default:
  			return state
  	}
  }
  
  export const collectionUpdateReducer = (state = {}, action) => {
  	switch (action.type) {
  		case types.COLLECTION_UPDATE_REQUEST:
  			return { loading: true }
  		case types.COLLECTION_UPDATE_SUCCESS:
  			return { loading: false, success: true, message: action.payload }
  		case types.COLLECTION_UPDATE_FAIL:
  			return { loading: false, error: action.payload }
  		case types.COLLECTION_RESET:
  			return { loading: false }
  
  		default:
  			return state
  	}
  }
  
  export const collectionDeleteReducer = (state = {}, action) => {
  	switch (action.type) {
  		case types.COLLECTION_DELETE_REQUEST:
  			return { loading: true }
  		case types.COLLECTION_DELETE_SUCCESS:
  			return { loading: false, success: true }
  		case types.COLLECTION_DELETE_FAIL:
  			return { loading: false, error: action.payload }
  		case types.COLLECTION_RESET:
  			return { loading: false }
  
  		default:
  			return state
  	}
  }
  