1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import * as types from '../actionsTypes/actionsTypes'
- const defaultState = {
- services:[],
- categories:[],
- isFetching: false,
- error:null
- };
- export const servicesReducer = (state = defaultState, action) => {
- switch(action.type){
- case types.GET_SERVICES_REQUEST : {
- return {
- ...state,
- isFetching: true
- };
- }
- case types.GET_SERVICES_REQUEST_SUCCESS : {
- return {
- ...state,
- services:action.payload.services,
- isFetching: false
- };
- }
- case types.GET_SERVICES_REQUEST_FAIL : {
- return {
- ...state,
- error:action.payload,
- isFetching: false
- }
- }
- case types.GET_CATEGORIES_REQUEST : {
- return {
- ...state,
- isFetching: true
- };
- }
- case types.GET_CATEGORIES_REQUEST_SUCCESS : {
- return {
- ...state,
- categories:action.payload.categories,
- isFetching: false
- };
- }
- case types.GET_CATEGORIES_REQUEST_FAIL : {
- return {
- ...state,
- error:action.payload,
- isFetching: false
- }
- }
- default:
- return state
- }
- };
|