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.
30 lines
899 B
30 lines
899 B
import { effects } from "redux-saga"; |
|
import { |
|
isSendingPShiftRequest, |
|
setPShiftRequestError, |
|
setPShiftRequestSuccess, |
|
clearPShiftRequestError, |
|
clearPShiftRequestSuccess |
|
} from "../actions/pShift/reducer.actions"; |
|
import { getPShifts } from "../api/pShift.api"; |
|
|
|
function* getPShiftsCall(params) { |
|
yield effects.put(isSendingPShiftRequest(true)); |
|
try { |
|
return yield effects.call(getPShifts, params); |
|
} catch (exception) { |
|
yield effects.put(setPShiftRequestError(exception)); |
|
return false; |
|
} finally { |
|
yield effects.put(isSendingPShiftRequest(false)); |
|
} |
|
} |
|
|
|
export function* getPShiftsFlow(request) { |
|
yield effects.put(clearPShiftRequestSuccess()); |
|
yield effects.put(clearPShiftRequestError()); |
|
const wasSuccessful = yield effects.call(getPShiftsCall, request.data); |
|
if (wasSuccessful) { |
|
yield effects.put(setPShiftRequestSuccess(wasSuccessful)); |
|
} |
|
}
|
|
|