Updated employee login
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user