import EmployeeActionTypes from "./employee.types"; const INITIAL_STATE = { currentEmployee: { authorized: null, technician: null, }, signingIn: false, gettingRates: false, error: null, }; const employeeReducer = (state = INITIAL_STATE, action) => { switch (action.type) { case EmployeeActionTypes.EMPLOYEE_SIGN_IN_START: return { ...state, signingIn: true, }; case EmployeeActionTypes.EMPLOYEE_SIGN_IN_SUCCESS: return { ...state, currentEmployee: { authorized: true, technician:action.payload }, signingIn: false, error: null, }; case EmployeeActionTypes.EMPLOYEE_SIGN_IN_FAILURE: return { ...state, signingIn: false, error: action.payload, }; case EmployeeActionTypes.EMPLOYEE_SIGN_OUT: return { ...state, currentEmployee: { authorized: false, technician:null },//TODO check if this needs to do clean up like set loaders all to false error: null, }; case EmployeeActionTypes.EMPLOYEE_GET_RATES_START: return { ...state, gettingRates: true, }; case EmployeeActionTypes.EMPLOYEE_GET_RATES_SUCCESS: return { ...state, currentEmployee: { ...state.currentEmployee, technician:action.payload }, gettingRates: false, error: null, }; case EmployeeActionTypes.EMPLOYEE_GET_RATES_FAILURE: return { ...state, gettingRates: false, error: action.payload, }; default: return state; } }; export default employeeReducer;