working page pagination controls

This commit is contained in:
Alexander Wong
2018-04-22 18:23:43 -06:00
parent dac6daa933
commit 0950f264e8
7 changed files with 153 additions and 39 deletions

View File

@@ -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));
}
}

View File

@@ -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);
}