diff --git a/src/actions/cShift/reducer.actions.js b/src/actions/cShift/reducer.actions.js
new file mode 100644
index 0000000..ae02c81
--- /dev/null
+++ b/src/actions/cShift/reducer.actions.js
@@ -0,0 +1,65 @@
+import {
+ IS_SENDING_CSHIFT_REQUEST,
+ SET_CSHIFT_REQUEST_ERROR,
+ CLEAR_CSHIFT_REQUEST_ERROR,
+ SET_CSHIFT_REQUEST_SUCCESS,
+ CLEAR_CSHIFT_REQUEST_SUCCESS,
+ SET_FORM_EMPLOYEE_UUID,
+ SET_FORM_PRICE_UUID,
+ SET_CLEAR_CSHIFT_STATE
+} from "../../constants/cShift.constants";
+import { parseError } from "../common.actions";
+
+export function isSendingCShiftRequest(sendingRequest) {
+ return {
+ type: IS_SENDING_CSHIFT_REQUEST,
+ data: sendingRequest
+ };
+}
+
+export function setCShiftRequestError(exception) {
+ let error = parseError(exception);
+ return {
+ type: SET_CSHIFT_REQUEST_ERROR,
+ data: error
+ };
+}
+
+export function clearCShiftRequestError() {
+ return {
+ type: CLEAR_CSHIFT_REQUEST_ERROR
+ };
+}
+
+export function setCShiftRequestSuccess(response) {
+ return {
+ type: SET_CSHIFT_REQUEST_SUCCESS,
+ data: response.detail || response
+ };
+}
+
+export function clearCShiftRequestSuccess() {
+ return {
+ type: CLEAR_CSHIFT_REQUEST_SUCCESS
+ };
+}
+
+export function setFormEmployeeUUID(uuid) {
+ return {
+ type: SET_FORM_EMPLOYEE_UUID,
+ data: uuid
+ };
+}
+
+export function setFormPriceUUID(uuid) {
+ return {
+ type: SET_FORM_PRICE_UUID,
+ data: uuid
+ };
+}
+
+export function setClearCshiftState() {
+ return {
+ type: SET_CLEAR_CSHIFT_STATE
+ };
+}
diff --git a/src/components/User/Client/ClientAddShiftForm.jsx b/src/components/User/Client/ClientAddShiftForm.jsx
index f000bdb..5634805 100644
--- a/src/components/User/Client/ClientAddShiftForm.jsx
+++ b/src/components/User/Client/ClientAddShiftForm.jsx
@@ -7,41 +7,109 @@ import {
Form,
Header,
Input,
+ Label,
TextArea
} from "semantic-ui-react";
+import {
+ clearCShiftRequestError,
+ clearCShiftRequestSuccess,
+ setFormEmployeeUUID,
+ setFormPriceUUID
+} from "../../../actions/cShift/reducer.actions";
+
class ClientAddShiftForm extends Component {
+ componentWillMount = () => {
+ this.props.dispatch(clearCShiftRequestError());
+ this.props.dispatch(clearCShiftRequestSuccess());
+ this.props.dispatch(setFormEmployeeUUID(""));
+ this.props.dispatch(setFormPriceUUID(""));
+ };
+
+ changeSelectedEmployee = (e, { value }) => {
+ if (value !== this.props.employeeUUID) {
+ this.props.dispatch(setFormPriceUUID(""));
+ }
+ this.props.dispatch(setFormEmployeeUUID(value));
+ };
+
+ changeSelectedPrice = (e, { value }) => {
+ this.props.dispatch(setFormPriceUUID(value));
+ };
+
render() {
- const { selfUser } = this.props;
+ const { selfUser, employeeUUID, priceUUID } = this.props;
if (!selfUser.client) {
return ;
}
const employeeChoices = selfUser.client.employees
- .filter(employee => !employee.deleted)
- .map((val, idx, arr) => ({
- key: val.uuid,
- value: val.uuid,
- text: val.provider.email
+ .filter(employee => !employee.deleted && !!employee.approved)
+ .map(({ uuid, provider }) => ({
+ key: uuid,
+ value: uuid,
+ text: provider.email
}));
-
- const priceChoices = selfUser.client;
-
+ const priceChoices = [];
+ if (employeeUUID) {
+ const employee = selfUser.client.employees.find(emp => {
+ return emp && emp.uuid === employeeUUID;
+ });
+ priceChoices.push(
+ ...employee.prices
+ .filter(price => !price.deleted)
+ .map(({ amount, uuid, work_type }) => ({
+ key: uuid,
+ value: uuid,
+ text: work_type.label,
+ content: (
+
+
+ {work_type.label}
+
+
+ )
+ }))
+ );
+ }
return (
);
}
}
function mapStateToProps(state) {
- return { ...state.employee, selfUser: state.user.selfUser };
+ return { ...state.cShift, selfUser: state.user.selfUser };
}
-const ClientAddShiftFormView = ({ employeeChoices, user }) => (
+const ClientAddShiftFormView = ({
+ user,
+ employeeChoices,
+ priceChoices,
+ employeeUUID,
+ priceUUID,
+ changeSelectedEmployee,
+ changeSelectedPrice
+}) => (
-
+
diff --git a/src/components/User/Client/ClientProviders.jsx b/src/components/User/Client/ClientProviders.jsx
index 248c6bb..6268fb1 100644
--- a/src/components/User/Client/ClientProviders.jsx
+++ b/src/components/User/Client/ClientProviders.jsx
@@ -83,6 +83,14 @@ const ClientProvidersView = ({ user, deleteEmployee, deletePrice }) => (
{employee.provider.userinfo && (
+ {employee.provider.email && (
+
+ Email:{" "}
+
+ {employee.provider.email}
+
+
+ )}
{employee.provider.userinfo.phone_number && (
Phone Number:{" "}
@@ -99,12 +107,16 @@ const ClientProvidersView = ({ user, deleteEmployee, deletePrice }) => (
color={
employee.approved === null
? "grey"
- : !!employee.approved ? "green" : "red"
+ : !!employee.approved
+ ? "green"
+ : "red"
}
>
{employee.approved === null
? "Pending"
- : !!employee.approved ? "Approved" : "Ended"}
+ : !!employee.approved
+ ? "Approved"
+ : "Ended"}
{employee.approved && (
diff --git a/src/components/User/Provider/ProviderClients.jsx b/src/components/User/Provider/ProviderClients.jsx
index d0b7608..4993c1e 100644
--- a/src/components/User/Provider/ProviderClients.jsx
+++ b/src/components/User/Provider/ProviderClients.jsx
@@ -65,6 +65,14 @@ const ProviderClientsView = ({ user, updateEmployer }) => (
{employer.client.userinfo && (
+ {employer.client.email && (
+
+ Email:{" "}
+
+ {employer.client.email}
+
+
+ )}
{employer.client.userinfo.phone_number && (
Phone Number:{" "}
@@ -81,12 +89,16 @@ const ProviderClientsView = ({ user, updateEmployer }) => (
color={
employer.approved === null
? "grey"
- : !!employer.approved ? "green" : "red"
+ : !!employer.approved
+ ? "green"
+ : "red"
}
>
{employer.approved === null
? "Pending"
- : !!employer.approved ? "Approved" : "Ended"}
+ : !!employer.approved
+ ? "Approved"
+ : "Ended"}
{employer.approved && (
diff --git a/src/constants/cShift.constants.js b/src/constants/cShift.constants.js
new file mode 100644
index 0000000..9a9884c
--- /dev/null
+++ b/src/constants/cShift.constants.js
@@ -0,0 +1,13 @@
+// Reducer CShift Action Constants
+export const IS_SENDING_CSHIFT_REQUEST = "IS_SENDING_CSHIFT_REQUEST";
+export const SET_CSHIFT_REQUEST_ERROR = "SET_CSHIFT_REQUEST_ERROR";
+export const CLEAR_CSHIFT_REQUEST_ERROR = "CLEAR_CSHIFT_REQUEST_ERROR";
+export const SET_CSHIFT_REQUEST_SUCCESS = "SET_CSHIFT_REQUEST_SUCCESS";
+export const CLEAR_CSHIFT_REQUEST_SUCCESS = "CLEAR_CSHIFT_REQUEST_SUCCESS";
+export const SET_FORM_EMPLOYEE_UUID = "SET_FORM_EMPLOYEE_UUID";
+export const SET_FORM_PRICE_UUID = "SET_FORM_PRICE_UUID";
+
+export const SET_CLEAR_CSHIFT_STATE = "SET_CLEAR_CSHIFT_STATE";
+
+// Saga CShift Action Constants
+export const CREATE_MULTIPLE_CSHIFT_REQUEST = "CREATE_MULTIPLE_CSHIFT_REQUEST";
diff --git a/src/reducers/cShiftReducer.js b/src/reducers/cShiftReducer.js
new file mode 100644
index 0000000..50f43ba
--- /dev/null
+++ b/src/reducers/cShiftReducer.js
@@ -0,0 +1,66 @@
+import {
+ IS_SENDING_CSHIFT_REQUEST,
+ SET_CSHIFT_REQUEST_ERROR,
+ CLEAR_CSHIFT_REQUEST_ERROR,
+ SET_CSHIFT_REQUEST_SUCCESS,
+ CLEAR_CSHIFT_REQUEST_SUCCESS,
+ SET_FORM_EMPLOYEE_UUID,
+ SET_FORM_PRICE_UUID,
+ SET_CLEAR_CSHIFT_STATE
+} from "../constants/cShift.constants";
+
+const initialState = {
+ isSendingCShiftRequest: false,
+ cShiftRequestError: "",
+ cShiftRequestSuccess: "",
+ employeeUUID: "",
+ priceUUID: ""
+};
+
+function cShiftReducer(state = initialState, action) {
+ switch (action.type) {
+ case IS_SENDING_CSHIFT_REQUEST:
+ return {
+ ...state,
+ isSendingCShiftRequest: action.data
+ };
+ case SET_CSHIFT_REQUEST_ERROR:
+ return {
+ ...state,
+ cShiftRequestError: action.data
+ };
+ case CLEAR_CSHIFT_REQUEST_ERROR:
+ return {
+ ...state,
+ cShiftRequestError: ""
+ };
+ case SET_CSHIFT_REQUEST_SUCCESS:
+ return {
+ ...state,
+ cShiftRequestSuccess: action.data
+ };
+ case CLEAR_CSHIFT_REQUEST_SUCCESS:
+ return {
+ ...state,
+ cShiftRequestSuccess: ""
+ };
+ case SET_FORM_EMPLOYEE_UUID:
+ return {
+ ...state,
+ employeeUUID: action.data
+ };
+ case SET_FORM_PRICE_UUID:
+ return {
+ ...state,
+ priceUUID: action.data
+ };
+ case SET_CLEAR_CSHIFT_STATE:
+ return {
+ ...initialState
+ };
+ default:
+ return state;
+ }
+}
+
+export default cShiftReducer;
diff --git a/src/reducers/cshiftReducer.js b/src/reducers/cshiftReducer.js
deleted file mode 100644
index e69de29..0000000
diff --git a/src/reducers/index.js b/src/reducers/index.js
index 0216af8..6d9e6ba 100644
--- a/src/reducers/index.js
+++ b/src/reducers/index.js
@@ -5,6 +5,7 @@ import worktypeReducer from "./worktypeReducer";
import employeeReducer from "./employeeReducer";
// import employerReducer from "./employerReducer"; // unused
import priceReducer from "./priceReducer";
+import cShiftReducer from "./cShiftReducer";
const reducer = combineReducers({
auth: authReducer,
@@ -12,7 +13,8 @@ const reducer = combineReducers({
worktype: worktypeReducer,
employee: employeeReducer,
// employer: employerReducer // unused
- price: priceReducer
+ price: priceReducer,
+ cShift: cShiftReducer
});
export default reducer;