import { IS_SENDING_AUTH_REQUEST, SET_AUTH_REQUEST_ERROR, CLEAR_AUTH_REQUEST_ERROR, SET_AUTH_REQUEST_SUCCESS, CLEAR_AUTH_REQUEST_SUCCESS, SET_SELF_USER, SET_FORM_EMAIL, SET_FORM_PASSWORD, SET_FORM_PASSWORD_CONFIRMATION } from "../constants/auth.constants"; const initialState = { isSendingAuthRequest: false, authRequestError: "", authRequestSuccess: "", currentUser: {}, email: "", password: "", passwordConfirmation: "" }; function authReducer(state = initialState, action) { switch (action.type) { case IS_SENDING_AUTH_REQUEST: return { ...state, isSendingAuthRequest: action.data }; case SET_AUTH_REQUEST_ERROR: return { ...state, authRequestError: action.data }; case CLEAR_AUTH_REQUEST_ERROR: return { ...state, authRequestError: "" }; case SET_AUTH_REQUEST_SUCCESS: return { ...state, authRequestSuccess: action.data }; case CLEAR_AUTH_REQUEST_SUCCESS: return { ...state, authRequestSuccess: "" }; case SET_SELF_USER: return { ...state, currentUser: action.data }; case SET_FORM_EMAIL: return { ...state, email: action.data }; case SET_FORM_PASSWORD: return { ...state, password: action.data }; case SET_FORM_PASSWORD_CONFIRMATION: return { ...state, passwordConfirmation: action.data }; default: return state; } } export default authReducer;