working edit cshift functionality

This commit is contained in:
Alexander Wong
2018-04-22 21:07:50 -06:00
parent 0950f264e8
commit 4f548d529f
13 changed files with 543 additions and 160 deletions
+51 -2
View File
@@ -11,9 +11,15 @@ import {
setFormShiftDates,
setFormShiftDuration,
setFormShiftNote,
setFormShiftStartTime
setFormShiftStartTime,
setCShiftUUID
} from "../actions/cShift/reducer.actions";
import { createCShifts, getCShifts } from "../api/cShift.api";
import {
createCShifts,
getCShifts,
getCShift,
editCShift
} from "../api/cShift.api";
function* createCShiftsCall(postBodies) {
yield effects.put(isSendingCShiftRequest(true));
@@ -48,6 +54,32 @@ function* getCShiftsCall(params) {
}
}
function* getCShiftCall({ uuid, params }) {
yield effects.put(isSendingCShiftRequest(true));
try {
return yield effects.call(getCShift, uuid, params);
} catch (exception) {
yield effects.put(setCShiftRequestError(exception));
return false;
} finally {
yield effects.put(isSendingCShiftRequest(false));
}
}
function* editCShiftCall(payload) {
yield effects.put(isSendingCShiftRequest(true));
try {
const edit = yield effects.call(editCShift, payload.uuid, payload);
yield effects.put(setCShiftUUID(true));
return edit;
} 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());
@@ -78,3 +110,20 @@ export function* getCShiftsFlow(request) {
yield effects.put(setCShiftRequestSuccess(isSuccessful));
}
}
export function* getCShiftFlow(request) {
yield effects.put(clearCShiftRequestSuccess());
yield effects.put(clearCShiftRequestError());
const wasSuccessful = yield effects.call(getCShiftCall, request.data);
if (wasSuccessful) {
yield effects.put(setCShiftRequestSuccess(wasSuccessful));
}
}
export function* editCShiftFlow(request) {
yield effects.put(clearCShiftRequestError());
const wasSuccessful = yield effects.call(editCShiftCall, request.data);
if (wasSuccessful) {
yield effects.put(setCShiftRequestSuccess(wasSuccessful));
}
}