rudamentary mutli-post err handling
This commit is contained in:
@@ -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
|
||||
};
|
||||
|
12
src/actions/cShift/saga.actions.js
Normal file
12
src/actions/cShift/saga.actions.js
Normal 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
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user