diff --git a/src/actions/cShift/saga.actions.js b/src/actions/cShift/saga.actions.js
index 00817b9..bf6d3e7 100644
--- a/src/actions/cShift/saga.actions.js
+++ b/src/actions/cShift/saga.actions.js
@@ -2,7 +2,8 @@ import {
CREATE_MULTIPLE_CSHIFT_REQUEST,
GET_CSHIFTS_REQUEST,
GET_CSHIFT_REQUEST,
- EDIT_CSHIFT_REQUEST
+ EDIT_CSHIFT_REQUEST,
+ DELETE_CSHIFT_REQUEST
} from "../../constants/cShift.constants";
/**
@@ -36,3 +37,10 @@ export function editCShiftRequest(payload) {
data: payload
}
}
+
+export function deleteCShiftRequest(uuid) {
+ return {
+ type: DELETE_CSHIFT_REQUEST,
+ data: uuid
+ }
+}
\ No newline at end of file
diff --git a/src/api/cShift.api.js b/src/api/cShift.api.js
index cd76d04..1848238 100644
--- a/src/api/cShift.api.js
+++ b/src/api/cShift.api.js
@@ -1,4 +1,4 @@
-import { get, put, post } from "./baseApi";
+import { get, put, post, del } from "./baseApi";
export function createCShifts(postBodies) {
return Promise.all(
@@ -23,3 +23,7 @@ export function getCShift(uuid, params) {
export function editCShift(uuid, payload) {
return put(`/cshift/${uuid}/`, payload).then(resp => Promise.resolve(resp));
}
+
+export function deleteCShift(uuid) {
+ return del(`/cshift/${uuid}/`).then(resp => Promise.resolve(resp));
+}
diff --git a/src/components/User/Client/ClientAddShiftForm.jsx b/src/components/User/Client/ClientAddShiftForm.jsx
index 7ab2c7b..49e8bb6 100644
--- a/src/components/User/Client/ClientAddShiftForm.jsx
+++ b/src/components/User/Client/ClientAddShiftForm.jsx
@@ -162,7 +162,7 @@ class ClientAddShiftForm extends Component {
priceUUID={priceUUID}
startTime={startTime}
duration={duration}
- note={note}
+ note={note || ""}
selectedShiftDates={selectedShiftDates}
changeSelectedEmployee={this.changeSelectedEmployee}
changeSelectedPrice={this.changeSelectedPrice}
diff --git a/src/components/User/Client/ClientEditShiftForm.jsx b/src/components/User/Client/ClientEditShiftForm.jsx
index 0c5317a..6066dee 100644
--- a/src/components/User/Client/ClientEditShiftForm.jsx
+++ b/src/components/User/Client/ClientEditShiftForm.jsx
@@ -111,7 +111,6 @@ class ClientEditShiftForm extends Component {
description: note ? note : undefined
});
}
- console.log({ ...postRequestBodies[0], uuid: cShiftUUID })
this.props.dispatch(
editCShiftRequest({ ...postRequestBodies[0], uuid: cShiftUUID })
);
@@ -196,7 +195,7 @@ class ClientEditShiftForm extends Component {
priceUUID={priceUUID}
startTime={startTime}
duration={duration}
- note={note}
+ note={note || ""}
selectedShiftDates={selectedShiftDates}
changeSelectedEmployee={this.changeSelectedEmployee}
changeSelectedPrice={this.changeSelectedPrice}
diff --git a/src/components/User/Client/ClientShiftFormView.jsx b/src/components/User/Client/ClientShiftFormView.jsx
index 502705c..3c63275 100644
--- a/src/components/User/Client/ClientShiftFormView.jsx
+++ b/src/components/User/Client/ClientShiftFormView.jsx
@@ -72,6 +72,7 @@ export const ClientShiftFormView = ({
selection
fluid
search
+ disabled={!!isEditing}
noResultsMessage="No approved employees found."
value={employeeUUID}
/>
@@ -85,7 +86,7 @@ export const ClientShiftFormView = ({
selection
fluid
search
- disabled={!employeeUUID}
+ disabled={!employeeUUID || !!isEditing}
noResultsMessage="No prices for given employee."
value={priceUUID}
/>
@@ -99,7 +100,7 @@ export const ClientShiftFormView = ({
showTimeSelectOnly
timeIntervals={30}
dateFormat="LT Z"
- timeFormat="hh:mm"
+ timeFormat="h:mm a"
placeholderText="Select shift start time"
/>
diff --git a/src/components/User/Client/ClientShiftShared.js b/src/components/User/Client/ClientShiftShared.js
index d721b43..216ee0e 100644
--- a/src/components/User/Client/ClientShiftShared.js
+++ b/src/components/User/Client/ClientShiftShared.js
@@ -11,3 +11,29 @@ export const getEmployeeFromPrice = (priceUUID, selfUser) => {
});
return matchEmployee;
};
+
+export const getWorkTypeFromPrice = (priceUUID, selfUser) => {
+ const employees = selfUser && selfUser.client && selfUser.client.employees;
+ let matchWorkType = null;
+ employees.forEach(employee => {
+ employee.prices.forEach(price => {
+ if (price.uuid === priceUUID) {
+ matchWorkType = price.work_type;
+ }
+ });
+ });
+ return matchWorkType;
+};
+
+export const getPriceFromPrice = (priceUUID, selfUser) => {
+ const employees = selfUser && selfUser.client && selfUser.client.employees;
+ let matchPrice = null;
+ employees.forEach(employee => {
+ employee.prices.forEach(price => {
+ if (price.uuid === priceUUID) {
+ matchPrice = price;
+ }
+ });
+ });
+ return matchPrice;
+};
diff --git a/src/components/User/Client/ClientShifts.jsx b/src/components/User/Client/ClientShifts.jsx
index bc4a534..e7d7c7d 100644
--- a/src/components/User/Client/ClientShifts.jsx
+++ b/src/components/User/Client/ClientShifts.jsx
@@ -1,3 +1,4 @@
+import { utc, ISO_8601, duration } from "moment";
import React, { Component } from "react";
import { connect } from "react-redux";
import { Redirect, Link } from "react-router-dom";
@@ -8,9 +9,15 @@ import {
Item,
Segment,
Pagination,
- Loader
+ Popup,
+ Loader,
+ Label
} from "semantic-ui-react";
-import { getCShiftsRequest } from "../../../actions/cShift/saga.actions";
+import {
+ getCShiftsRequest,
+ deleteCShiftRequest
+} from "../../../actions/cShift/saga.actions";
+import { getEmployeeFromPrice, getPriceFromPrice } from "./ClientShiftShared";
class ClientShifts extends Component {
constructor(props) {
@@ -40,6 +47,10 @@ class ClientShifts extends Component {
this.setState({ page: activePage });
};
+ deleteCShift = uuid => {
+ this.props.dispatch(deleteCShiftRequest(uuid));
+ };
+
render() {
const {
isSendingCShiftRequest,
@@ -56,6 +67,7 @@ class ClientShifts extends Component {
pageSize={pageSize}
user={selfUser}
handlePaginationChange={this.handlePaginationChange}
+ deleteCShift={this.deleteCShift}
/>
);
} else {
@@ -74,7 +86,8 @@ const ClientShiftsView = ({
user,
page,
pageSize,
- handlePaginationChange
+ handlePaginationChange,
+ deleteCShift
}) => {
const { count = 0, results = [] } = cShiftRequestSuccess;
@@ -96,27 +109,95 @@ const ClientShiftsView = ({
{!isSendingCShiftRequest &&
results.length > 0 && (
{JSON.stringify(result, null, 2)}
- {JSON.stringify(result, null, 2)}
+
+
+
+ }
+ trigger={
+
+ }
+ on="click"
+ position="top right"
+ />
+