2017-09-03 22:24:43 +00:00
|
|
|
import {
|
|
|
|
IS_SENDING_USER_REQUEST,
|
|
|
|
SET_USER_REQUEST_ERROR,
|
|
|
|
CLEAR_USER_REQUEST_ERROR,
|
|
|
|
SET_USER_REQUEST_SUCCESS,
|
|
|
|
CLEAR_USER_REQUEST_SUCCESS,
|
2017-09-04 03:47:18 +00:00
|
|
|
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,
|
2017-09-04 18:29:51 +00:00
|
|
|
SET_EDIT_PROFILE_TAB_ACTIVE_INDEX,
|
2018-01-21 19:01:59 +00:00
|
|
|
SET_CLEAR_USER_STATE,
|
2017-09-04 06:30:18 +00:00
|
|
|
USER_INFO_STEP,
|
|
|
|
CLIENT
|
2017-09-03 22:24:43 +00:00
|
|
|
} from "../constants/user.constants";
|
|
|
|
|
|
|
|
const initialState = {
|
|
|
|
isSendingUserRequest: false,
|
|
|
|
userRequestError: "",
|
|
|
|
userRequestSuccess: "",
|
2017-09-04 03:47:18 +00:00
|
|
|
selfUser: {},
|
|
|
|
completeRegistrationCurrentStep: USER_INFO_STEP,
|
|
|
|
completeRegistrationMaxStep: USER_INFO_STEP,
|
2017-09-04 06:30:18 +00:00
|
|
|
completeRegistrationClientOrProvider: CLIENT,
|
2017-09-04 03:47:18 +00:00
|
|
|
phoneNumber: "",
|
|
|
|
businessNumber: "",
|
2017-09-04 18:29:51 +00:00
|
|
|
socialInsuranceNumber: "",
|
|
|
|
editProfileActiveIndex: 0
|
2017-09-03 22:24:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
|
};
|
2017-09-04 03:47:18 +00:00
|
|
|
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
|
|
|
|
};
|
2017-09-04 18:29:51 +00:00
|
|
|
case SET_EDIT_PROFILE_TAB_ACTIVE_INDEX:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
editProfileActiveIndex: action.data
|
|
|
|
};
|
2018-01-21 19:01:59 +00:00
|
|
|
case SET_CLEAR_USER_STATE:
|
|
|
|
return {
|
|
|
|
...initialState
|
|
|
|
};
|
2017-09-03 22:24:43 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default userReducer;
|