37 lines
806 B
JavaScript
37 lines
806 B
JavaScript
import EmployeeActionTypes from "./employee.types";
|
|
|
|
const INITIAL_STATE = {
|
|
currentEmployee: {
|
|
authorized: null,
|
|
},
|
|
employeeSigningIn: false,
|
|
error: null,
|
|
};
|
|
|
|
const employeeReducer = (state = INITIAL_STATE, action) => {
|
|
switch (action.type) {
|
|
case EmployeeActionTypes.SIGN_IN_EMPLOYEE_START:
|
|
return {
|
|
...state,
|
|
employeeSigningIn: true,
|
|
error: null,
|
|
};
|
|
case EmployeeActionTypes.SIGN_IN_EMPLOYEE_SUCCESS:
|
|
return {
|
|
...state,
|
|
currentEmployee: action.payload,
|
|
error: null,
|
|
};
|
|
case EmployeeActionTypes.SIGN_OUT_EMPLOYEE_SUCCESS:
|
|
return {
|
|
...state,
|
|
currentEmployee: { authorized: false },
|
|
error: null,
|
|
};
|
|
default:
|
|
return state;
|
|
}
|
|
};
|
|
|
|
export default employeeReducer;
|