added provider users approve clients functionality
This commit is contained in:
@@ -10,7 +10,12 @@ import {
|
||||
setFormEmployeeNote
|
||||
} from "../actions/employee/reducer.actions";
|
||||
import { getSelfUserRequest } from "../actions/user/saga.actions";
|
||||
import { addEmployee, getEmployee, deleteEmployee, updateEmployee } from "../api/employee.api";
|
||||
import {
|
||||
addEmployee,
|
||||
getEmployee,
|
||||
deleteEmployee,
|
||||
updateEmployee
|
||||
} from "../api/employee.api";
|
||||
|
||||
function* addEmployeeCall(postBody) {
|
||||
yield effects.put(isSendingEmployeeRequest(true));
|
||||
@@ -46,7 +51,7 @@ function* updateEmployeeCall(payload) {
|
||||
yield effects.put(setEmployeeRequestError(exception));
|
||||
return false;
|
||||
} finally {
|
||||
yield effects.put(isSendingEmployeeRequest(false))
|
||||
yield effects.put(isSendingEmployeeRequest(false));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,9 +83,9 @@ export function* addEmployeeFlow(request) {
|
||||
export function* readEmployeeFlow(request) {
|
||||
const wasSuccessful = yield effects.call(readEmployeeCall, request.data);
|
||||
if (wasSuccessful) {
|
||||
yield effects.put(setEmployeeUUID(wasSuccessful.uuid))
|
||||
yield effects.put(setEmployeeUUID(wasSuccessful.uuid));
|
||||
yield effects.put(setFormEmployeeEmail(wasSuccessful.provider_email));
|
||||
yield effects.put(setFormEmployeeNote(wasSuccessful.note))
|
||||
yield effects.put(setFormEmployeeNote(wasSuccessful.note));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,4 +102,4 @@ export function* updateEmployeeFlow(request) {
|
||||
export function* deleteEmployeeFlow(request) {
|
||||
yield effects.call(deleteEmployeeCall, request.data);
|
||||
yield effects.put(getSelfUserRequest());
|
||||
}
|
||||
}
|
||||
|
||||
34
src/sagas/employer.sagas.js
Normal file
34
src/sagas/employer.sagas.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import { effects } from "redux-saga";
|
||||
import {
|
||||
isSendingEmployerRequest,
|
||||
setEmployerRequestError,
|
||||
setEmployerRequestSuccess,
|
||||
clearEmployerRequestError,
|
||||
clearEmployerRequestSuccess
|
||||
} from "../actions/employer/reducer.actions";
|
||||
import { getSelfUserRequest } from "../actions/user/saga.actions";
|
||||
import { updateEmployer } from "../api/employer.api";
|
||||
|
||||
function* updateEmployerCall(payload) {
|
||||
yield effects.put(isSendingEmployerRequest(true));
|
||||
const { uuid, approved } = payload;
|
||||
try {
|
||||
return yield effects.call(updateEmployer, uuid, approved);
|
||||
} catch (exception) {
|
||||
yield effects.put(setEmployerRequestError(exception));
|
||||
return false;
|
||||
} finally {
|
||||
yield effects.put(isSendingEmployerRequest(false));
|
||||
}
|
||||
}
|
||||
|
||||
export function* updateEmployerFlow(request) {
|
||||
yield effects.put(clearEmployerRequestSuccess());
|
||||
yield effects.put(clearEmployerRequestError());
|
||||
const wasSuccessful = yield effects.call(updateEmployerCall, request.data);
|
||||
if (wasSuccessful) {
|
||||
yield effects.put(getSelfUserRequest());
|
||||
yield effects.put(setEmployerRequestSuccess(wasSuccessful));
|
||||
yield effects.put(clearEmployerRequestError());
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,8 @@ import {
|
||||
readEmployeeFlow,
|
||||
deleteEmployeeFlow
|
||||
} from "./employee.sagas";
|
||||
import { UPDATE_EMPLOYER_REQUEST } from "../constants/employer.constants";
|
||||
import { updateEmployerFlow } from "./employer.sagas";
|
||||
|
||||
export default function* rootSaga() {
|
||||
yield takeLatest(SEND_REGISTER_REQUEST, registerUserFlow);
|
||||
@@ -80,4 +82,5 @@ export default function* rootSaga() {
|
||||
yield takeLatest(CREATE_EMPLOYEE_REQUEST, addEmployeeFlow);
|
||||
yield takeLatest(READ_EMPLOYEE_REQUEST, readEmployeeFlow);
|
||||
yield takeLatest(DELETE_EMPLOYEE_REQUEST, deleteEmployeeFlow);
|
||||
yield takeLatest(UPDATE_EMPLOYER_REQUEST, updateEmployerFlow);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user