Updated employee login

This commit is contained in:
jfrye122
2023-04-20 10:38:57 -04:00
parent bd0ba5c0df
commit 95a53222e7
6 changed files with 69 additions and 67 deletions

View File

@@ -3,30 +3,37 @@ import EmployeeActionTypes from "./employee.types";
const INITIAL_STATE = {
currentEmployee: {
authorized: null,
technician: null,
},
employeeSigningIn: false,
signingIn: false,
error: null,
};
const employeeReducer = (state = INITIAL_STATE, action) => {
switch (action.type) {
case EmployeeActionTypes.SIGN_IN_EMPLOYEE_START:
case EmployeeActionTypes.EMPLOYEE_SIGN_IN_START:
return {
...state,
employeeSigningIn: true,
signingIn: true,
};
case EmployeeActionTypes.EMPLOYEE_SIGN_IN_SUCCESS:
return {
...state,
currentEmployee: { authorized: true, technician:action.payload },
signingIn: false,
error: null,
};
case EmployeeActionTypes.SIGN_IN_EMPLOYEE_SUCCESS:
case EmployeeActionTypes.EMPLOYEE_SIGN_OUT:
return {
...state,
currentEmployee: action.payload,
currentEmployee: { authorized: false, technician:null },
error: null,
};
case EmployeeActionTypes.SIGN_OUT_EMPLOYEE_SUCCESS:
case EmployeeActionTypes.EMPLOYEE_SIGN_IN_FAILURE:
return {
...state,
currentEmployee: { authorized: false },
error: null,
signingIn: false,
error: action.payload,
};
default:
return state;