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.
34 lines
1.1 KiB
34 lines
1.1 KiB
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()); |
|
} |
|
}
|
|
|