import { IS_SENDING_USER_REQUEST, SET_USER_REQUEST_ERROR, CLEAR_USER_REQUEST_ERROR, SET_USER_REQUEST_SUCCESS, CLEAR_USER_REQUEST_SUCCESS, SET_SELF_USER, SET_COMPLETE_REGISTRATION_STEP, SET_COMPLETE_REGISTRATION_CLIENT_OR_PROVIDER, SET_FORM_PHONE_NUMBER, SET_FORM_BUSINESS_NUMBER, SET_FORM_SOCIAL_INSURANCE_NUMBER, SET_EDIT_PROFILE_TAB_ACTIVE_INDEX, USER_INFO_STEP, CLIENT } from "../constants/user.constants"; const initialState = { isSendingUserRequest: false, userRequestError: "", userRequestSuccess: "", selfUser: {}, completeRegistrationCurrentStep: USER_INFO_STEP, completeRegistrationMaxStep: USER_INFO_STEP, completeRegistrationClientOrProvider: CLIENT, phoneNumber: "", businessNumber: "", socialInsuranceNumber: "", editProfileActiveIndex: 0 }; function userReducer(state = initialState, action) { switch (action.type) { case IS_SENDING_USER_REQUEST: return { ...state, isSendingUserRequest: action.data }; case SET_USER_REQUEST_ERROR: return { ...state, userRequestError: action.data }; case CLEAR_USER_REQUEST_ERROR: return { ...state, userRequestError: "" }; case SET_USER_REQUEST_SUCCESS: return { ...state, userRequestSuccess: action.data }; case CLEAR_USER_REQUEST_SUCCESS: return { ...state, userRequestSuccess: "" }; case SET_SELF_USER: return { ...state, selfUser: action.data }; case SET_COMPLETE_REGISTRATION_STEP: return { ...state, completeRegistrationCurrentStep: action.data, completeRegistrationMaxStep: Math.max( action.data, state.completeRegistrationMaxStep ) }; case SET_COMPLETE_REGISTRATION_CLIENT_OR_PROVIDER: return { ...state, completeRegistrationClientOrProvider: action.data }; case SET_FORM_PHONE_NUMBER: return { ...state, phoneNumber: action.data }; case SET_FORM_BUSINESS_NUMBER: return { ...state, businessNumber: action.data }; case SET_FORM_SOCIAL_INSURANCE_NUMBER: return { ...state, socialInsuranceNumber: action.data }; case SET_EDIT_PROFILE_TAB_ACTIVE_INDEX: return { ...state, editProfileActiveIndex: action.data }; default: return state; } } export default userReducer;