You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
1.6 KiB
73 lines
1.6 KiB
import { |
|
IS_SENDING_EMPLOYEE_REQUEST, |
|
SET_EMPLOYEE_REQUEST_ERROR, |
|
CLEAR_EMPLOYEE_REQUEST_ERROR, |
|
SET_EMPLOYEE_REQUEST_SUCCESS, |
|
CLEAR_EMPLOYEE_REQUEST_SUCCESS, |
|
SET_EMPLOYEE_UUID, |
|
SET_FORM_EMPLOYEE_EMAIL, |
|
SET_FORM_EMPLOYEE_NOTE, |
|
SET_CLEAR_EMPLOYEE_STATE |
|
} from "../constants/employee.constants"; |
|
|
|
const initialState = { |
|
isSendingEmployeeRequest: false, |
|
employeeRequestError: "", |
|
employeeRequestSuccess: "", |
|
uuid: "", |
|
email: "", |
|
note: "" |
|
}; |
|
|
|
function employeeReducer(state = initialState, action) { |
|
switch (action.type) { |
|
case IS_SENDING_EMPLOYEE_REQUEST: |
|
return { |
|
...state, |
|
isSendingEmployeeRequest: action.data |
|
}; |
|
case SET_EMPLOYEE_REQUEST_ERROR: |
|
return { |
|
...state, |
|
employeeRequestError: action.data |
|
}; |
|
case CLEAR_EMPLOYEE_REQUEST_ERROR: |
|
return { |
|
...state, |
|
employeeRequestError: "" |
|
}; |
|
case SET_EMPLOYEE_REQUEST_SUCCESS: |
|
return { |
|
...state, |
|
employeeRequestSuccess: action.data |
|
}; |
|
case CLEAR_EMPLOYEE_REQUEST_SUCCESS: |
|
return { |
|
...state, |
|
employeeRequestSuccess: "" |
|
}; |
|
case SET_EMPLOYEE_UUID: |
|
return { |
|
...state, |
|
uuid: action.data |
|
}; |
|
case SET_FORM_EMPLOYEE_EMAIL: |
|
return { |
|
...state, |
|
email: action.data |
|
}; |
|
case SET_FORM_EMPLOYEE_NOTE: |
|
return { |
|
...state, |
|
note: action.data |
|
}; |
|
case SET_CLEAR_EMPLOYEE_STATE: |
|
return { |
|
...initialState |
|
}; |
|
default: |
|
return state; |
|
} |
|
} |
|
|
|
export default employeeReducer;
|
|
|