working page pagination controls
This commit is contained in:
@@ -13,7 +13,7 @@ import {
|
||||
setFormShiftNote,
|
||||
setFormShiftStartTime
|
||||
} from "../actions/cShift/reducer.actions";
|
||||
import { createCShifts } from "../api/cShift.api";
|
||||
import { createCShifts, getCShifts } from "../api/cShift.api";
|
||||
|
||||
function* createCShiftsCall(postBodies) {
|
||||
yield effects.put(isSendingCShiftRequest(true));
|
||||
@@ -36,15 +36,25 @@ function* createCShiftsCall(postBodies) {
|
||||
}
|
||||
}
|
||||
|
||||
function* getCShiftsCall(params) {
|
||||
yield effects.put(isSendingCShiftRequest(true));
|
||||
try {
|
||||
return yield effects.call(getCShifts, params);
|
||||
} catch (exception) {
|
||||
yield effects.put(setCShiftRequestError(exception));
|
||||
return false;
|
||||
} finally {
|
||||
yield effects.put(isSendingCShiftRequest(false));
|
||||
}
|
||||
}
|
||||
|
||||
export function* createCShiftsFlow(request) {
|
||||
yield effects.put(clearCShiftRequestSuccess());
|
||||
yield effects.put(clearCShiftRequestError());
|
||||
const arrResponses = yield effects.call(createCShiftsCall, request.data);
|
||||
console.log(arrResponses);
|
||||
if (arrResponses) {
|
||||
const errorResps = arrResponses.filter(resp => !!resp.error);
|
||||
if (errorResps.length > 0) {
|
||||
console.log(arrResponses);
|
||||
yield effects.put(setCShiftRequestErrors(errorResps));
|
||||
}
|
||||
const succResps = arrResponses.filter(resp => !resp.error);
|
||||
@@ -59,3 +69,12 @@ export function* createCShiftsFlow(request) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function* getCShiftsFlow(request) {
|
||||
yield effects.put(clearCShiftRequestSuccess());
|
||||
yield effects.put(clearCShiftRequestError());
|
||||
const isSuccessful = yield effects.call(getCShiftsCall, request.data);
|
||||
if (isSuccessful) {
|
||||
yield effects.put(setCShiftRequestSuccess(isSuccessful));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,8 +69,11 @@ import {
|
||||
updatePriceFlow,
|
||||
deletePriceFlow
|
||||
} from "./price.sagas";
|
||||
import { CREATE_MULTIPLE_CSHIFT_REQUEST } from "../constants/cShift.constants";
|
||||
import { createCShiftsFlow } from "./cShift.sagas";
|
||||
import {
|
||||
CREATE_MULTIPLE_CSHIFT_REQUEST,
|
||||
GET_CSHIFTS_REQUEST
|
||||
} from "../constants/cShift.constants";
|
||||
import { createCShiftsFlow, getCShiftsFlow } from "./cShift.sagas";
|
||||
|
||||
export default function* rootSaga() {
|
||||
yield takeLatest(SEND_REGISTER_REQUEST, registerUserFlow);
|
||||
@@ -99,4 +102,5 @@ export default function* rootSaga() {
|
||||
yield takeLatest(UPDATE_PRICE_REQUEST, updatePriceFlow);
|
||||
yield takeLatest(DELETE_PRICE_REQUEST, deletePriceFlow);
|
||||
yield takeLatest(CREATE_MULTIPLE_CSHIFT_REQUEST, createCShiftsFlow);
|
||||
yield takeLatest(GET_CSHIFTS_REQUEST, getCShiftsFlow);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user