added provider users approve clients functionality

This commit is contained in:
Alexander Wong
2018-01-21 18:20:41 -07:00
parent bc0628bcb7
commit e6ee51f481
14 changed files with 356 additions and 11 deletions
+34
View 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());
}
}