rudamentary mutli-post err handling

This commit is contained in:
Alexander Wong
2018-04-22 16:39:17 -06:00
parent 530593b721
commit dac6daa933
9 changed files with 194 additions and 21 deletions

View File

@@ -1,7 +1,7 @@
import {
IS_SENDING_CSHIFT_REQUEST,
SET_CSHIFT_REQUEST_ERROR,
CLEAR_CSHIFT_REQUEST_ERROR,
SET_CSHIFT_REQUEST_ERRORS,
CLEAR_CSHIFT_REQUEST_ERRORS,
SET_CSHIFT_REQUEST_SUCCESS,
CLEAR_CSHIFT_REQUEST_SUCCESS,
SET_FORM_EMPLOYEE_UUID,
@@ -14,6 +14,13 @@ import {
} from "../../constants/cShift.constants";
import { parseError } from "../common.actions";
function transformError(error) {
if (error.get_price_uuid) {
error["Price"] = error.get_price_uuid;
delete error["get_price_uuid"];
}
}
export function isSendingCShiftRequest(sendingRequest) {
return {
type: IS_SENDING_CSHIFT_REQUEST,
@@ -23,15 +30,25 @@ export function isSendingCShiftRequest(sendingRequest) {
export function setCShiftRequestError(exception) {
let error = parseError(exception);
transformError(error);
return {
type: SET_CSHIFT_REQUEST_ERROR,
data: error
type: SET_CSHIFT_REQUEST_ERRORS,
data: [error]
};
}
export function setCShiftRequestErrors(exceptions) {
let errors = exceptions.map(exception => parseError(exception));
errors.forEach(error => transformError(error));
return {
type: SET_CSHIFT_REQUEST_ERRORS,
data: errors
}
}
export function clearCShiftRequestError() {
return {
type: CLEAR_CSHIFT_REQUEST_ERROR
type: CLEAR_CSHIFT_REQUEST_ERRORS
};
}
@@ -90,7 +107,7 @@ export function setFormShiftDates(dates) {
};
}
export function setClearCshiftState() {
export function setClearCShiftState() {
return {
type: SET_CLEAR_CSHIFT_STATE
};

View File

@@ -0,0 +1,12 @@
import { CREATE_MULTIPLE_CSHIFT_REQUEST } from "../../constants/cShift.constants";
/**
* Saga action for creating a list of shifts
* @param postBody[] array of post body for cshift post endpoint
*/
export function createMultipleCShiftRequest(postBodies) {
return {
type: CREATE_MULTIPLE_CSHIFT_REQUEST,
data: postBodies
};
}