text: import * as products from '../constants/products'
  
  export const productsListReducer = (state = { products: [] }, action) => {
  	switch (action.type) {
  		case products.PRODUCT_LIST_REQUEST:
  			return { loading: true }
  		case products.PRODUCT_LIST_SUCCESS:
  			return {
  				loading: false,
  				products: action.payload.products,
  				pages: action.payload.pages,
  				pageNumber: action.payload.pageNumber,
  				pageSize: action.payload.pageSize,
  			}
  		case products.PRODUCT_LIST_FAIL:
  			return { loading: false, error: action.payload }
  		default:
  			return state
  	}
  }
  
  export const productDetailsReducer = (state = { product: {} }, action) => {
  	switch (action.type) {
  		case products.PRODUCT_DETAILS_REQUEST:
  			return { loading: true }
  		case products.PRODUCT_DETAILS_SUCCESS:
  			return { loading: false, product: action.payload }
  		case products.PRODUCT_DETAILS_FAIL:
  			return { loading: false, error: action.payload }
  		case products.PRODUCT_CLEAR:
  			return { loading: false }
  
  		default:
  			return state
  	}
  }
  
  export const productCreateReducer = (state = { product: {} }, action) => {
  	switch (action.type) {
  		case products.PRODUCT_CREATE_REQUEST:
  			return { loading: true }
  		case products.PRODUCT_CREATE_SUCCESS:
  			return { loading: false, product: action.payload }
  		case products.PRODUCT_CREATE_FAIL:
  			return { loading: false, error: action.payload }
  		case products.PRODUCT_CLEAR:
  			return { loading: false }
  		default:
  			return state
  	}
  }
  
  export const productUpdateReducer = (state = {}, action) => {
  	switch (action.type) {
  		case products.PRODUCT_UPDATE_REQUEST:
  			return { loading: true }
  		case products.PRODUCT_UPDATE_SUCCESS:
  			return { loading: false, success: true, message: action.payload }
  		case products.PRODUCT_UPDATE_FAIL:
  			return { loading: false, error: action.payload }
  		case products.PRODUCT_CLEAR:
  			return { loading: false }
  		default:
  			return state
  	}
  }
  
  export const productDeleteReducer = (state = {}, action) => {
  	switch (action.type) {
  		case products.PRODUCT_DELETE_REQUEST:
  			return { loading: true }
  		case products.PRODUCT_DELETE_SUCCESS:
  			return { loading: false, success: true, message: action.payload }
  		case products.PRODUCT_DELETE_FAIL:
  			return { loading: false, error: action.payload }
  		case products.PRODUCT_CLEAR:
  			return { loading: false }
  		default:
  			return state
  	}
  }
  