Files
imexmobile/redux/employee/employee.reducer.js
2023-05-05 09:26:34 -04:00

51 lines
1.1 KiB
JavaScript

import EmployeeActionTypes from "./employee.types";
const INITIAL_STATE = {
currentEmployee: {
authorized: null,
technician: null,
rates:[],
},
signingIn: 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 },
error: null,
};
case EmployeeActionTypes.SET_CAMERA_JOB:
return {
...state,
currentEmployee: { rates:action.payload },
};
default:
return state;
}
};
export default employeeReducer;