Create/Update worktypes
This commit is contained in:
74
src/actions/worktype/reducer.actions.js
Normal file
74
src/actions/worktype/reducer.actions.js
Normal file
@@ -0,0 +1,74 @@
|
||||
import {
|
||||
IS_SENDING_WORKTYPE_REQUEST,
|
||||
SET_WORKTYPE_REQUEST_ERROR,
|
||||
CLEAR_WORKTYPE_REQUEST_ERROR,
|
||||
SET_WORKTYPE_REQUEST_SUCCESS,
|
||||
CLEAR_WORKTYPE_REQUEST_SUCCESS,
|
||||
SET_WORKTYPE_UUID,
|
||||
SET_FORM_WORKTYPE_COLOR,
|
||||
SET_FORM_WORKTYPE_LABEL
|
||||
} from "../../constants/worktype.constants";
|
||||
import { parseError } from "../common.actions";
|
||||
|
||||
export function isSendingWorktypeRequest(sendingRequest) {
|
||||
return {
|
||||
type: IS_SENDING_WORKTYPE_REQUEST,
|
||||
data: sendingRequest
|
||||
};
|
||||
}
|
||||
|
||||
export function setWorktypeRequestError(exception) {
|
||||
let error = parseError(exception);
|
||||
if (error.label) {
|
||||
error["Label"] = error.label;
|
||||
delete error["label"];
|
||||
}
|
||||
if (error.color) {
|
||||
error["Color"] = error.color;
|
||||
delete error["color"];
|
||||
}
|
||||
return {
|
||||
type: SET_WORKTYPE_REQUEST_ERROR,
|
||||
data: error
|
||||
};
|
||||
}
|
||||
|
||||
export function clearWorktypeRequestError() {
|
||||
return {
|
||||
type: CLEAR_WORKTYPE_REQUEST_ERROR
|
||||
};
|
||||
}
|
||||
|
||||
export function setWorktypeRequestSuccess(response) {
|
||||
return {
|
||||
type: SET_WORKTYPE_REQUEST_SUCCESS,
|
||||
data: response.detail || response
|
||||
};
|
||||
}
|
||||
|
||||
export function clearWorktypeRequestSuccess() {
|
||||
return {
|
||||
type: CLEAR_WORKTYPE_REQUEST_SUCCESS
|
||||
};
|
||||
}
|
||||
|
||||
export function setWorktypeUUID(uuid) {
|
||||
return {
|
||||
type: SET_WORKTYPE_UUID,
|
||||
data: uuid
|
||||
};
|
||||
}
|
||||
|
||||
export function setFormWorktypeColor(color) {
|
||||
return {
|
||||
type: SET_FORM_WORKTYPE_COLOR,
|
||||
data: color
|
||||
};
|
||||
}
|
||||
|
||||
export function setFormWorktypeLabel(label) {
|
||||
return {
|
||||
type: SET_FORM_WORKTYPE_LABEL,
|
||||
data: label
|
||||
};
|
||||
}
|
34
src/actions/worktype/saga.actions.js
Normal file
34
src/actions/worktype/saga.actions.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import {
|
||||
CREATE_WORKTYPE_REQUEST,
|
||||
READ_WORKTYPE_REQUEST,
|
||||
UPDATE_WORKTYPE_REQUEST,
|
||||
DELETE_WORKTYPE_REQUEST
|
||||
} from "../../constants/worktype.constants";
|
||||
|
||||
export function createWorktypeRequest(postBody) {
|
||||
return {
|
||||
type: CREATE_WORKTYPE_REQUEST,
|
||||
data: postBody
|
||||
};
|
||||
}
|
||||
|
||||
export function readWorktypeRequest(payload) {
|
||||
return {
|
||||
type: READ_WORKTYPE_REQUEST,
|
||||
data: payload
|
||||
};
|
||||
}
|
||||
|
||||
export function updateWorktypeRequest(payload) {
|
||||
return {
|
||||
type: UPDATE_WORKTYPE_REQUEST,
|
||||
data: payload
|
||||
};
|
||||
}
|
||||
|
||||
export function deleteWorktypeRequest(payload) {
|
||||
return {
|
||||
type: DELETE_WORKTYPE_REQUEST,
|
||||
data: payload
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user