Functionality to add prices as a client, and view them as a provider
This commit is contained in:
78
src/actions/price/reducer.actions.js
Normal file
78
src/actions/price/reducer.actions.js
Normal file
@@ -0,0 +1,78 @@
|
||||
import {
|
||||
IS_SENDING_PRICE_REQUEST,
|
||||
SET_PRICE_REQUEST_ERROR,
|
||||
CLEAR_PRICE_REQUEST_ERROR,
|
||||
SET_PRICE_REQUEST_SUCCESS,
|
||||
CLEAR_PRICE_REQUEST_SUCCESS,
|
||||
SET_GET_EMPLOYEE_UUID,
|
||||
SET_GET_WORKTYPE_UUID,
|
||||
SET_FORM_PRICE_AMOUNT
|
||||
} from "../../constants/price.constants";
|
||||
import { parseError } from "../common.actions";
|
||||
|
||||
export function isSendingPriceRequest(sendingRequest) {
|
||||
return {
|
||||
type: IS_SENDING_PRICE_REQUEST,
|
||||
data: sendingRequest
|
||||
};
|
||||
}
|
||||
|
||||
export function setPriceRequestError(exception) {
|
||||
let error = parseError(exception);
|
||||
if (error.amount) {
|
||||
error["Amount"] = error.amount;
|
||||
delete error["amount"];
|
||||
}
|
||||
if (error.get_employee_uuid) {
|
||||
error["Employee"] = error.get_employee_uuid;
|
||||
delete error["get_employee_uuid"];
|
||||
}
|
||||
if (error.get_work_type_uuid) {
|
||||
error["WorkType"] = error.get_work_type_uuid;
|
||||
delete error["get_work_type_uuid"];
|
||||
}
|
||||
return {
|
||||
type: SET_PRICE_REQUEST_ERROR,
|
||||
data: error
|
||||
};
|
||||
}
|
||||
|
||||
export function clearPriceRequestError() {
|
||||
return {
|
||||
type: CLEAR_PRICE_REQUEST_ERROR
|
||||
};
|
||||
}
|
||||
|
||||
export function setPriceRequestSuccess(response) {
|
||||
return {
|
||||
type: SET_PRICE_REQUEST_SUCCESS,
|
||||
data: response.detail || response
|
||||
};
|
||||
}
|
||||
|
||||
export function clearPriceRequestSuccess() {
|
||||
return {
|
||||
type: CLEAR_PRICE_REQUEST_SUCCESS
|
||||
};
|
||||
}
|
||||
|
||||
export function setGetEmployeeUUID(uuid) {
|
||||
return {
|
||||
type: SET_GET_EMPLOYEE_UUID,
|
||||
data: uuid
|
||||
};
|
||||
}
|
||||
|
||||
export function setGetWorktypeUUID(uuid) {
|
||||
return {
|
||||
type: SET_GET_WORKTYPE_UUID,
|
||||
data: uuid
|
||||
};
|
||||
}
|
||||
|
||||
export function setFormPriceAmount(amount) {
|
||||
return {
|
||||
type: SET_FORM_PRICE_AMOUNT,
|
||||
data: amount
|
||||
};
|
||||
}
|
26
src/actions/price/saga.actions.js
Normal file
26
src/actions/price/saga.actions.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import {
|
||||
CREATE_PRICE_REQUEST,
|
||||
UPDATE_PRICE_REQUEST,
|
||||
DELETE_PRICE_REQUEST
|
||||
} from "../../constants/price.constants";
|
||||
|
||||
export function createPriceRequest(postBody) {
|
||||
return {
|
||||
type: CREATE_PRICE_REQUEST,
|
||||
data: postBody
|
||||
};
|
||||
}
|
||||
|
||||
export function updatePriceRequest(payload) {
|
||||
return {
|
||||
type: UPDATE_PRICE_REQUEST,
|
||||
data: payload
|
||||
};
|
||||
}
|
||||
|
||||
export function deletePriceRequest(payload) {
|
||||
return {
|
||||
type: DELETE_PRICE_REQUEST,
|
||||
data: payload
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user