+
{employer.client.trim() || "No Name!"}
{employer.note}
@@ -57,7 +57,7 @@ const ProviderClientsView = ({ user, updateEmployer }) => (
)}
{employer.approved && (
-
+
{`${employer.client.first_name} ${
employer.client.last_name
}`.trim() || "No Name!"}
@@ -89,6 +89,44 @@ const ProviderClientsView = ({ user, updateEmployer }) => (
: !!employer.approved ? "Approved" : "Ended"}
+ {employer.approved && (
+
+
+ Assigned Work
+
+ {employer.prices
+ .filter(price => !price.deleted)
+ .map((price, index) => (
+
+
+
+
+ {" "}
+ {price.work_type.label || "No Label"}
+
+
+
+ Hourly Rate: ${price.amount}
+
+
+ ))}
+ {employer.prices.filter(price => !price.deleted)
+ .length === 0 && (
+
+ No Prices for this Client
+
+ )}
+
+
+
+ )}
{!employer.approved && (
diff --git a/src/constants/price.constants.js b/src/constants/price.constants.js
new file mode 100644
index 0000000..b034849
--- /dev/null
+++ b/src/constants/price.constants.js
@@ -0,0 +1,14 @@
+// Reducer Price Action Constants
+export const IS_SENDING_PRICE_REQUEST = "IS_SENDING_PRICE_REQUEST";
+export const SET_PRICE_REQUEST_ERROR = "SET_PRICE_REQUEST_ERROR";
+export const CLEAR_PRICE_REQUEST_ERROR = "CLEAR_PRICE_REQUEST_ERROR";
+export const SET_PRICE_REQUEST_SUCCESS = "SET_PRICE_REQUEST_SUCCESS";
+export const CLEAR_PRICE_REQUEST_SUCCESS = "CLEAR_PRICE_REQUEST_SUCCESS";
+export const SET_GET_EMPLOYEE_UUID = "SET_GET_EMPLOYEE_UUID";
+export const SET_GET_WORKTYPE_UUID = "SET_GET_WORKTYPE_UUID";
+export const SET_FORM_PRICE_AMOUNT = "SET_FORM_PRICE_AMOUNT";
+
+// Saga Price Action Constants
+export const CREATE_PRICE_REQUEST = "CREATE_PRICE_REQUEST";
+export const UPDATE_PRICE_REQUEST = "UPDATE_PRICE_REQUEST";
+export const DELETE_PRICE_REQUEST = "DELETE_PRICE_REQUEST";
diff --git a/src/reducers/index.js b/src/reducers/index.js
index 90b20de..67a69a4 100644
--- a/src/reducers/index.js
+++ b/src/reducers/index.js
@@ -3,12 +3,14 @@ import authReducer from "./authReducer";
import userReducer from "./userReducer";
import worktypeReducer from "./worktypeReducer";
import employeeReducer from "./employeeReducer";
+import priceReducer from "./priceReducer";
const reducer = combineReducers({
auth: authReducer,
user: userReducer,
worktype: worktypeReducer,
- employee: employeeReducer
+ employee: employeeReducer,
+ price: priceReducer
});
export default reducer;
diff --git a/src/reducers/priceReducer.js b/src/reducers/priceReducer.js
new file mode 100644
index 0000000..7ec94aa
--- /dev/null
+++ b/src/reducers/priceReducer.js
@@ -0,0 +1,68 @@
+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";
+
+const initialState = {
+ isSendingPriceRequest: false,
+ priceRequestError: "",
+ priceRequestSuccess: "",
+ getEmployeeUUID: "",
+ getWorktypeUUID: "",
+ amount: ""
+};
+
+function priceReducer(state = initialState, action) {
+ switch (action.type) {
+ case IS_SENDING_PRICE_REQUEST:
+ return {
+ ...state,
+ isSendingPriceRequest: action.data
+ };
+ case SET_PRICE_REQUEST_ERROR:
+ return {
+ ...state,
+ priceRequestError: action.data
+ };
+ case CLEAR_PRICE_REQUEST_ERROR:
+ return {
+ ...state,
+ priceRequestError: ""
+ };
+ case SET_PRICE_REQUEST_SUCCESS:
+ return {
+ ...state,
+ priceRequestSuccess: action.data
+ };
+ case CLEAR_PRICE_REQUEST_SUCCESS:
+ return {
+ ...state,
+ priceRequestSuccess: ""
+ };
+ case SET_GET_EMPLOYEE_UUID:
+ return {
+ ...state,
+ getEmployeeUUID: action.data
+ };
+ case SET_GET_WORKTYPE_UUID:
+ return {
+ ...state,
+ getWorktypeUUID: action.data
+ };
+ case SET_FORM_PRICE_AMOUNT:
+ return {
+ ...state,
+ amount: action.data
+ };
+ default:
+ return state;
+ }
+}
+
+export default priceReducer;
diff --git a/src/sagas/index.js b/src/sagas/index.js
index 27cd98f..72c65b4 100644
--- a/src/sagas/index.js
+++ b/src/sagas/index.js
@@ -59,6 +59,16 @@ import {
} from "./employee.sagas";
import { UPDATE_EMPLOYER_REQUEST } from "../constants/employer.constants";
import { updateEmployerFlow } from "./employer.sagas";
+import {
+ CREATE_PRICE_REQUEST,
+ UPDATE_PRICE_REQUEST,
+ DELETE_PRICE_REQUEST
+} from "../constants/price.constants";
+import {
+ createPriceFlow,
+ updatePriceFlow,
+ deletePriceFlow
+} from "./price.sagas";
export default function* rootSaga() {
yield takeLatest(SEND_REGISTER_REQUEST, registerUserFlow);
@@ -83,4 +93,7 @@ export default function* rootSaga() {
yield takeLatest(READ_EMPLOYEE_REQUEST, readEmployeeFlow);
yield takeLatest(DELETE_EMPLOYEE_REQUEST, deleteEmployeeFlow);
yield takeLatest(UPDATE_EMPLOYER_REQUEST, updateEmployerFlow);
+ yield takeLatest(CREATE_PRICE_REQUEST, createPriceFlow);
+ yield takeLatest(UPDATE_PRICE_REQUEST, updatePriceFlow);
+ yield takeLatest(DELETE_PRICE_REQUEST, deletePriceFlow);
}
diff --git a/src/sagas/price.sagas.js b/src/sagas/price.sagas.js
new file mode 100644
index 0000000..ce1938f
--- /dev/null
+++ b/src/sagas/price.sagas.js
@@ -0,0 +1,85 @@
+import { effects } from "redux-saga";
+import {
+ isSendingPriceRequest,
+ setPriceRequestError,
+ clearPriceRequestError,
+ setPriceRequestSuccess,
+ clearPriceRequestSuccess,
+ setGetEmployeeUUID,
+ setGetWorktypeUUID,
+ setFormPriceAmount
+} from "../actions/price/reducer.actions";
+import { getSelfUserRequest } from "../actions/user/saga.actions";
+import { createPrice, updatePrice, deletePrice } from "../api/price.api";
+
+function* createPriceCall(postBody) {
+ yield effects.put(isSendingPriceRequest(true));
+ const { get_employee_uuid, get_work_type_uuid, amount } = postBody;
+ try {
+ return yield effects.call(
+ createPrice,
+ get_employee_uuid,
+ get_work_type_uuid,
+ amount
+ );
+ } catch (exception) {
+ yield effects.put(setPriceRequestError(exception));
+ return false;
+ } finally {
+ yield effects.put(isSendingPriceRequest(false));
+ }
+}
+
+function* updatePriceCall(payload) {
+ yield effects.put(isSendingPriceRequest(true));
+ const { uuid, amount } = payload;
+ try {
+ return yield effects.call(updatePrice, uuid, amount);
+ } catch (exception) {
+ yield effects.put(setPriceRequestError(exception));
+ return false;
+ } finally {
+ yield effects.put(isSendingPriceRequest(false));
+ }
+}
+
+function* deletePriceCall(uuid) {
+ yield effects.put(isSendingPriceRequest(true));
+ try {
+ return yield effects.call(deletePrice, uuid);
+ } catch (exception) {
+ yield effects.put(setPriceRequestError(exception));
+ return false;
+ } finally {
+ yield effects.put(isSendingPriceRequest(false));
+ }
+}
+
+export function* createPriceFlow(request) {
+ yield effects.put(clearPriceRequestSuccess());
+ yield effects.put(clearPriceRequestError());
+ const wasSuccessful = yield effects.call(createPriceCall, request.data);
+ if (wasSuccessful) {
+ yield effects.put(getSelfUserRequest());
+ yield effects.put(setPriceRequestSuccess(wasSuccessful));
+ yield effects.put(setGetEmployeeUUID(""));
+ yield effects.put(setGetWorktypeUUID(""));
+ yield effects.put(setFormPriceAmount(""));
+ yield effects.put(clearPriceRequestError());
+ }
+}
+
+export function* updatePriceFlow(request) {
+ yield effects.put(clearPriceRequestSuccess());
+ yield effects.put(clearPriceRequestError());
+ const wasSuccessful = yield effects.call(updatePriceCall, request.data);
+ if (wasSuccessful) {
+ yield effects.put(getSelfUserRequest());
+ yield effects.put(setPriceRequestSuccess(wasSuccessful));
+ }
+}
+
+export function* deletePriceFlow(request) {
+ yield effects.call(deletePriceCall, request.data);
+ yield effects.put(getSelfUserRequest());
+}