|
|
|
@ -1,5 +1,5 @@ |
|
|
|
|
import { utc, ISO_8601, duration } from "moment"; |
|
|
|
|
import React, { Component } from "react"; |
|
|
|
|
import React, { Component, Fragment } from "react"; |
|
|
|
|
import { connect } from "react-redux"; |
|
|
|
|
import { Redirect, Link } from "react-router-dom"; |
|
|
|
|
import { |
|
|
|
@ -25,9 +25,11 @@ import { |
|
|
|
|
} from "../../../actions/cShift/reducer.actions"; |
|
|
|
|
import { |
|
|
|
|
getCShiftsRequest, |
|
|
|
|
deleteCShiftRequest |
|
|
|
|
deleteCShiftRequest, |
|
|
|
|
editCShiftRequest |
|
|
|
|
} from "../../../actions/cShift/saga.actions"; |
|
|
|
|
import { getEmployeeFromPrice, getPriceFromPrice } from "./ClientShiftShared"; |
|
|
|
|
import ShiftLabel from "../../Shared/ShiftLabel"; |
|
|
|
|
|
|
|
|
|
class ClientShifts extends Component { |
|
|
|
|
constructor(props) { |
|
|
|
@ -41,7 +43,7 @@ class ClientShifts extends Component { |
|
|
|
|
this.props.dispatch( |
|
|
|
|
getCShiftsRequest({ |
|
|
|
|
page: this.props.page, |
|
|
|
|
approved: this.props.approvalFilter, |
|
|
|
|
provider_approved: this.props.approvalFilter, |
|
|
|
|
completed: this.props.completedFilter, |
|
|
|
|
manage: this.props.providerFilter, |
|
|
|
|
work_type: this.props.workTypeFilter, |
|
|
|
@ -54,7 +56,7 @@ class ClientShifts extends Component { |
|
|
|
|
this.props.dispatch( |
|
|
|
|
getCShiftsRequest({ |
|
|
|
|
page: activePage, |
|
|
|
|
approved: this.props.approvalFilter, |
|
|
|
|
provider_approved: this.props.approvalFilter, |
|
|
|
|
manage: this.props.providerFilter, |
|
|
|
|
work_type: this.props.workTypeFilter, |
|
|
|
|
page_size: this.state.pageSize |
|
|
|
@ -67,7 +69,7 @@ class ClientShifts extends Component { |
|
|
|
|
this.props.dispatch( |
|
|
|
|
getCShiftsRequest({ |
|
|
|
|
page: 1, |
|
|
|
|
approved: value, |
|
|
|
|
provider_approved: value, |
|
|
|
|
completed: this.props.completedFilter, |
|
|
|
|
manage: this.props.providerFilter, |
|
|
|
|
work_type: this.props.workTypeFilter, |
|
|
|
@ -82,7 +84,7 @@ class ClientShifts extends Component { |
|
|
|
|
this.props.dispatch( |
|
|
|
|
getCShiftsRequest({ |
|
|
|
|
page: 1, |
|
|
|
|
approved: this.props.approvalFilter, |
|
|
|
|
provider_approved: this.props.approvalFilter, |
|
|
|
|
completed: value, |
|
|
|
|
manage: this.props.providerFilter, |
|
|
|
|
work_type: this.props.workTypeFilter, |
|
|
|
@ -97,7 +99,7 @@ class ClientShifts extends Component { |
|
|
|
|
this.props.dispatch( |
|
|
|
|
getCShiftsRequest({ |
|
|
|
|
page: 1, |
|
|
|
|
approved: this.props.approvalFilter, |
|
|
|
|
provider_approved: this.props.approvalFilter, |
|
|
|
|
completed: this.props.completedFilter, |
|
|
|
|
manage: value, |
|
|
|
|
work_type: this.props.workTypeFilter, |
|
|
|
@ -112,7 +114,7 @@ class ClientShifts extends Component { |
|
|
|
|
this.props.dispatch( |
|
|
|
|
getCShiftsRequest({ |
|
|
|
|
page: 1, |
|
|
|
|
approved: this.props.approvalFilter, |
|
|
|
|
provider_approved: this.props.approvalFilter, |
|
|
|
|
completed: this.props.completedFilter, |
|
|
|
|
manage: this.props.manageFilter, |
|
|
|
|
work_type: value, |
|
|
|
@ -127,6 +129,34 @@ class ClientShifts extends Component { |
|
|
|
|
this.props.dispatch(deleteCShiftRequest(uuid)); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
approveHoursCShift = cshift => { |
|
|
|
|
const { |
|
|
|
|
set_start: approved_start, |
|
|
|
|
set_end: approved_end, |
|
|
|
|
price: get_price_uuid |
|
|
|
|
} = cshift; |
|
|
|
|
this.props.dispatch( |
|
|
|
|
editCShiftRequest({ |
|
|
|
|
uuid: cshift.uuid, |
|
|
|
|
get_price_uuid, |
|
|
|
|
approved_start, |
|
|
|
|
approved_end, |
|
|
|
|
set_start: null, |
|
|
|
|
set_end: null |
|
|
|
|
}) |
|
|
|
|
); |
|
|
|
|
this.props.dispatch( |
|
|
|
|
getCShiftsRequest({ |
|
|
|
|
page: this.props.page, |
|
|
|
|
provider_approved: this.props.approvalFilter, |
|
|
|
|
completed: this.props.completedFilter, |
|
|
|
|
manage: this.props.providerFilter, |
|
|
|
|
work_type: this.props.workTypeFilter, |
|
|
|
|
page_size: this.state.pageSize |
|
|
|
|
}) |
|
|
|
|
); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
|
const { |
|
|
|
|
isSendingCShiftRequest, |
|
|
|
@ -157,6 +187,7 @@ class ClientShifts extends Component { |
|
|
|
|
handleChangeProviderFilter={this.handleChangeProviderFilter} |
|
|
|
|
handleChangeWorkTypeFilter={this.handleChangeWorkTypeFilter} |
|
|
|
|
deleteCShift={this.deleteCShift} |
|
|
|
|
approveHoursCShift={this.approveHoursCShift} |
|
|
|
|
/> |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
@ -184,7 +215,8 @@ const ClientShiftsView = ({ |
|
|
|
|
handleChangeCompletedFilter, |
|
|
|
|
handleChangeProviderFilter, |
|
|
|
|
handleChangeWorkTypeFilter, |
|
|
|
|
deleteCShift |
|
|
|
|
deleteCShift, |
|
|
|
|
approveHoursCShift |
|
|
|
|
}) => { |
|
|
|
|
const { count = 0, results = [] } = cShiftRequestSuccess; |
|
|
|
|
const approvedOptions = [ |
|
|
|
@ -240,7 +272,7 @@ const ClientShiftsView = ({ |
|
|
|
|
Schedule Shift |
|
|
|
|
</Button> |
|
|
|
|
<Segment> |
|
|
|
|
{"Filter by Approval "} |
|
|
|
|
{"Filter by Provider Approval "} |
|
|
|
|
<Dropdown |
|
|
|
|
inline |
|
|
|
|
placeholder={approvalFilter === null ? `All` : `Pending`} |
|
|
|
@ -302,9 +334,7 @@ const ClientShiftsView = ({ |
|
|
|
|
"minutes" |
|
|
|
|
).humanize()}`; |
|
|
|
|
} |
|
|
|
|
const approved = !!result.approved; |
|
|
|
|
const rejected = !result.approved && result.approved !== null; |
|
|
|
|
const pending = result.approved === null; |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<Item key={result.uuid}> |
|
|
|
|
<Item.Content> |
|
|
|
@ -320,18 +350,14 @@ const ClientShiftsView = ({ |
|
|
|
|
{workType.label} |
|
|
|
|
</Item.Header> |
|
|
|
|
<Item.Extra> |
|
|
|
|
<Label |
|
|
|
|
color={approved ? "green" : rejected ? "red" : "grey"} |
|
|
|
|
tag |
|
|
|
|
size="small" |
|
|
|
|
> |
|
|
|
|
{approved && "Approved"} |
|
|
|
|
{pending && "Approval Pending"} |
|
|
|
|
{rejected && "Rejected"} |
|
|
|
|
</Label> |
|
|
|
|
<ShiftLabel |
|
|
|
|
provider_approved={result.provider_approved} |
|
|
|
|
client_approved_start={result.approved_start} |
|
|
|
|
client_approved_end={result.approved_end} |
|
|
|
|
/> |
|
|
|
|
</Item.Extra> |
|
|
|
|
<Item.Meta> |
|
|
|
|
{"At " + |
|
|
|
|
{"Scheduled for " + |
|
|
|
|
utc(result.set_start, ISO_8601) |
|
|
|
|
.local(false) |
|
|
|
|
.format(OLD_PEOPLE_TIME_FORMAT)} |
|
|
|
@ -348,14 +374,6 @@ const ClientShiftsView = ({ |
|
|
|
|
</Item.Content> |
|
|
|
|
{!checkedIn && ( |
|
|
|
|
<Item.Extra> |
|
|
|
|
<Button |
|
|
|
|
primary |
|
|
|
|
floated="right" |
|
|
|
|
as={Link} |
|
|
|
|
to={`/user/profile/client/edit-shift/${result.uuid}`} |
|
|
|
|
> |
|
|
|
|
Edit |
|
|
|
|
</Button> |
|
|
|
|
<Popup |
|
|
|
|
content={ |
|
|
|
|
<div> |
|
|
|
@ -378,39 +396,109 @@ const ClientShiftsView = ({ |
|
|
|
|
on="click" |
|
|
|
|
position="top right" |
|
|
|
|
/> |
|
|
|
|
<Button |
|
|
|
|
primary |
|
|
|
|
floated="right" |
|
|
|
|
as={Link} |
|
|
|
|
to={`/user/profile/client/edit-shift/${result.uuid}`} |
|
|
|
|
> |
|
|
|
|
Edit |
|
|
|
|
</Button> |
|
|
|
|
</Item.Extra> |
|
|
|
|
)} |
|
|
|
|
{checkedIn && ( |
|
|
|
|
<Item.Content> |
|
|
|
|
<Item.Description> |
|
|
|
|
{result.description && ( |
|
|
|
|
<Message>{result.description}</Message> |
|
|
|
|
)} |
|
|
|
|
<strong>Provider</strong> |
|
|
|
|
<List bulleted> |
|
|
|
|
<List.Item> |
|
|
|
|
{"Checked in at " + |
|
|
|
|
checkedIn |
|
|
|
|
.local(false) |
|
|
|
|
.format(OLD_PEOPLE_TIME_FORMAT)} |
|
|
|
|
</List.Item> |
|
|
|
|
{checkedOut && ( |
|
|
|
|
<Fragment> |
|
|
|
|
<Item.Content> |
|
|
|
|
<Item.Description> |
|
|
|
|
{result.description && ( |
|
|
|
|
<Message>{result.description}</Message> |
|
|
|
|
)} |
|
|
|
|
{result.approved_start && ( |
|
|
|
|
<Fragment> |
|
|
|
|
<strong>Client</strong> |
|
|
|
|
<List bulleted> |
|
|
|
|
<List.Item> |
|
|
|
|
{`Approved time start ${utc( |
|
|
|
|
result.approved_start |
|
|
|
|
) |
|
|
|
|
.local(false) |
|
|
|
|
.format(OLD_PEOPLE_TIME_FORMAT)}`} |
|
|
|
|
</List.Item> |
|
|
|
|
<List.Item>{`Approved time end ${utc( |
|
|
|
|
result.approved_end |
|
|
|
|
) |
|
|
|
|
.local(false) |
|
|
|
|
.format(OLD_PEOPLE_TIME_FORMAT)}`}</List.Item> |
|
|
|
|
</List> |
|
|
|
|
</Fragment> |
|
|
|
|
)} |
|
|
|
|
<strong>Provider</strong> |
|
|
|
|
<List bulleted> |
|
|
|
|
<List.Item> |
|
|
|
|
{"Checked out at " + |
|
|
|
|
checkedOut |
|
|
|
|
{"Checked in at " + |
|
|
|
|
checkedIn |
|
|
|
|
.local(false) |
|
|
|
|
.format(OLD_PEOPLE_TIME_FORMAT)} |
|
|
|
|
</List.Item> |
|
|
|
|
{checkedOut && ( |
|
|
|
|
<List.Item> |
|
|
|
|
{"Checked out at " + |
|
|
|
|
checkedOut |
|
|
|
|
.local(false) |
|
|
|
|
.format(OLD_PEOPLE_TIME_FORMAT)} |
|
|
|
|
</List.Item> |
|
|
|
|
)} |
|
|
|
|
</List> |
|
|
|
|
{result.chart && ( |
|
|
|
|
<Message> |
|
|
|
|
<Message.Header>Chart</Message.Header> |
|
|
|
|
{result.chart} |
|
|
|
|
</Message> |
|
|
|
|
)} |
|
|
|
|
</List> |
|
|
|
|
{result.chart && ( |
|
|
|
|
<Message> |
|
|
|
|
<Message.Header>Chart</Message.Header> |
|
|
|
|
{result.chart} |
|
|
|
|
</Message> |
|
|
|
|
</Item.Description> |
|
|
|
|
</Item.Content> |
|
|
|
|
<Item.Extra> |
|
|
|
|
<Popup |
|
|
|
|
content={ |
|
|
|
|
<div> |
|
|
|
|
Are you sure you want to delete this shift?<br /> |
|
|
|
|
<Button |
|
|
|
|
basic |
|
|
|
|
color="red" |
|
|
|
|
size="small" |
|
|
|
|
onClick={() => deleteCShift(result.uuid)} |
|
|
|
|
> |
|
|
|
|
Confirm Deletion |
|
|
|
|
</Button> |
|
|
|
|
</div> |
|
|
|
|
} |
|
|
|
|
trigger={ |
|
|
|
|
<Button color="red" floated="right"> |
|
|
|
|
Delete |
|
|
|
|
</Button> |
|
|
|
|
} |
|
|
|
|
on="click" |
|
|
|
|
position="top right" |
|
|
|
|
/> |
|
|
|
|
<Button |
|
|
|
|
primary |
|
|
|
|
floated="right" |
|
|
|
|
as={Link} |
|
|
|
|
to={`/user/profile/client/edit-shift/${result.uuid}`} |
|
|
|
|
> |
|
|
|
|
Adjust Hours |
|
|
|
|
</Button> |
|
|
|
|
{!result.approved_start && ( |
|
|
|
|
<Button |
|
|
|
|
color="green" |
|
|
|
|
floated="right" |
|
|
|
|
onClick={() => approveHoursCShift(result)} |
|
|
|
|
> |
|
|
|
|
Approve Hours |
|
|
|
|
</Button> |
|
|
|
|
)} |
|
|
|
|
</Item.Description> |
|
|
|
|
</Item.Content> |
|
|
|
|
</Item.Extra> |
|
|
|
|
</Fragment> |
|
|
|
|
)} |
|
|
|
|
</Item> |
|
|
|
|
); |
|
|
|
|