UNPKG

@omegabigdata/honoplay-redux-helper

Version:
77 lines (72 loc) 1.84 kB
import { CREATE_PROFESSION_FAILED, CREATE_PROFESSION_SUCCESS, CREATING_PROFESSION, FETCHING_PROFESSION_LIST, FETCH_PROFESSION_LIST_FAILED, FETCH_PROFESSION_LIST_SUCCESS } from "../helpers/ActionTypes/Profession"; const PROFESSION_LIST_INITIAL_STATE = { isProfessionListLoading: false, professionList: null, errorProfessionList: null }; const CREATE_PROFESSION_INITIAL_STATE = { isCreateProfessionLoading: false, newProfession: null, errorCreateProfession: null }; export const professionListReducers = ( state = PROFESSION_LIST_INITIAL_STATE, action ) => { switch (action.type) { case FETCHING_PROFESSION_LIST: return { ...state, isProfessionListLoading: true, professionList: null }; case FETCH_PROFESSION_LIST_SUCCESS: return { ...state, isProfessionListLoading: false, professionList: action.data }; case FETCH_PROFESSION_LIST_FAILED: return { ...state, isProfessionListLoading: false, errorProfessionList: action.data.error }; default: return state; } }; export const createProfessionReducers = ( state = CREATE_PROFESSION_INITIAL_STATE, action ) => { switch (action.type) { case CREATING_PROFESSION: return { ...state, isCreateProfessionLoading: true, errorCreateProfession: null }; case CREATE_PROFESSION_SUCCESS: return { ...state, isCreateProfessionLoading: false, newProfession: action.data }; case CREATE_PROFESSION_FAILED: return { ...state, isCreateProfessionLoading: false, errorCreateProfession: action.data.error }; default: return state; } };