|
|
@ -5,8 +5,10 @@ import { Redirect, Link } from "react-router-dom"; |
|
|
|
import { |
|
|
|
import { |
|
|
|
Button, |
|
|
|
Button, |
|
|
|
Container, |
|
|
|
Container, |
|
|
|
|
|
|
|
Dropdown, |
|
|
|
Header, |
|
|
|
Header, |
|
|
|
Item, |
|
|
|
Item, |
|
|
|
|
|
|
|
Segment, |
|
|
|
Pagination, |
|
|
|
Pagination, |
|
|
|
Loader, |
|
|
|
Loader, |
|
|
|
Label |
|
|
|
Label |
|
|
@ -15,6 +17,10 @@ import { |
|
|
|
getEmployerFromPrice, |
|
|
|
getEmployerFromPrice, |
|
|
|
getPriceFromPrice |
|
|
|
getPriceFromPrice |
|
|
|
} from "./ProviderShiftsShared"; |
|
|
|
} from "./ProviderShiftsShared"; |
|
|
|
|
|
|
|
import { |
|
|
|
|
|
|
|
setPShiftPage, |
|
|
|
|
|
|
|
setPShiftApprovalFilter |
|
|
|
|
|
|
|
} from "../../../actions/pShift/reducer.actions"; |
|
|
|
import { |
|
|
|
import { |
|
|
|
getPShiftsRequest, |
|
|
|
getPShiftsRequest, |
|
|
|
updatePShiftRequest |
|
|
|
updatePShiftRequest |
|
|
@ -24,7 +30,6 @@ class ProviderShifts extends Component { |
|
|
|
constructor(props) { |
|
|
|
constructor(props) { |
|
|
|
super(props); |
|
|
|
super(props); |
|
|
|
this.state = { |
|
|
|
this.state = { |
|
|
|
page: 1, |
|
|
|
|
|
|
|
pageSize: 10 // client can't control this, but set here just in case |
|
|
|
pageSize: 10 // client can't control this, but set here just in case |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
@ -32,7 +37,8 @@ class ProviderShifts extends Component { |
|
|
|
componentWillMount = () => { |
|
|
|
componentWillMount = () => { |
|
|
|
this.props.dispatch( |
|
|
|
this.props.dispatch( |
|
|
|
getPShiftsRequest({ |
|
|
|
getPShiftsRequest({ |
|
|
|
page: this.state.page, |
|
|
|
page: this.props.page, |
|
|
|
|
|
|
|
approved: this.props.approvalFilter, |
|
|
|
page_size: this.state.pageSize |
|
|
|
page_size: this.state.pageSize |
|
|
|
}) |
|
|
|
}) |
|
|
|
); |
|
|
|
); |
|
|
@ -42,10 +48,23 @@ class ProviderShifts extends Component { |
|
|
|
this.props.dispatch( |
|
|
|
this.props.dispatch( |
|
|
|
getPShiftsRequest({ |
|
|
|
getPShiftsRequest({ |
|
|
|
page: activePage, |
|
|
|
page: activePage, |
|
|
|
|
|
|
|
approved: this.props.approvalFilter, |
|
|
|
|
|
|
|
page_size: this.state.pageSize |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
this.props.dispatch(setPShiftPage(activePage)); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handleChangeApprovalFilter = (event, { value }) => { |
|
|
|
|
|
|
|
this.props.dispatch( |
|
|
|
|
|
|
|
getPShiftsRequest({ |
|
|
|
|
|
|
|
page: 1, |
|
|
|
|
|
|
|
approved: value, |
|
|
|
page_size: this.state.pageSize |
|
|
|
page_size: this.state.pageSize |
|
|
|
}) |
|
|
|
}) |
|
|
|
); |
|
|
|
); |
|
|
|
this.setState({ page: activePage }); |
|
|
|
this.props.dispatch(setPShiftApprovalFilter(value)); |
|
|
|
|
|
|
|
this.props.dispatch(setPShiftPage(1)); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
handleChangePShiftApproval = (uuid, approved) => { |
|
|
|
handleChangePShiftApproval = (uuid, approved) => { |
|
|
@ -60,17 +79,21 @@ class ProviderShifts extends Component { |
|
|
|
const { |
|
|
|
const { |
|
|
|
isSendingPShiftRequest, |
|
|
|
isSendingPShiftRequest, |
|
|
|
pShiftRequestSuccess, |
|
|
|
pShiftRequestSuccess, |
|
|
|
selfUser |
|
|
|
selfUser, |
|
|
|
|
|
|
|
page, |
|
|
|
|
|
|
|
approvalFilter |
|
|
|
} = this.props; |
|
|
|
} = this.props; |
|
|
|
const { page, pageSize } = this.state; |
|
|
|
const { pageSize } = this.state; |
|
|
|
if (selfUser.provider) { |
|
|
|
if (selfUser.provider) { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<ProviderShiftsView |
|
|
|
<ProviderShiftsView |
|
|
|
isSendingPShiftRequest={isSendingPShiftRequest} |
|
|
|
isSendingPShiftRequest={isSendingPShiftRequest} |
|
|
|
pShiftRequestSuccess={pShiftRequestSuccess} |
|
|
|
pShiftRequestSuccess={pShiftRequestSuccess} |
|
|
|
page={page} |
|
|
|
page={page} |
|
|
|
|
|
|
|
approvalFilter={approvalFilter} |
|
|
|
pageSize={pageSize} |
|
|
|
pageSize={pageSize} |
|
|
|
user={selfUser} |
|
|
|
user={selfUser} |
|
|
|
|
|
|
|
handleChangeApprovalFilter={this.handleChangeApprovalFilter} |
|
|
|
handlePaginationChange={this.handlePaginationChange} |
|
|
|
handlePaginationChange={this.handlePaginationChange} |
|
|
|
handleChangePShiftApproval={this.handleChangePShiftApproval} |
|
|
|
handleChangePShiftApproval={this.handleChangePShiftApproval} |
|
|
|
/> |
|
|
|
/> |
|
|
@ -90,14 +113,33 @@ const ProviderShiftsView = ({ |
|
|
|
pShiftRequestSuccess, |
|
|
|
pShiftRequestSuccess, |
|
|
|
user, |
|
|
|
user, |
|
|
|
page, |
|
|
|
page, |
|
|
|
|
|
|
|
approvalFilter, |
|
|
|
pageSize, |
|
|
|
pageSize, |
|
|
|
|
|
|
|
handleChangeApprovalFilter, |
|
|
|
handlePaginationChange, |
|
|
|
handlePaginationChange, |
|
|
|
handleChangePShiftApproval |
|
|
|
handleChangePShiftApproval |
|
|
|
}) => { |
|
|
|
}) => { |
|
|
|
const { count = 0, results = [] } = pShiftRequestSuccess; |
|
|
|
const { count = 0, results = [] } = pShiftRequestSuccess; |
|
|
|
|
|
|
|
const approvedOptions = [ |
|
|
|
|
|
|
|
{ text: "Approved", value: true }, |
|
|
|
|
|
|
|
{ text: "Rejected", value: false }, |
|
|
|
|
|
|
|
{ text: "All", value: null } |
|
|
|
|
|
|
|
]; |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<Container> |
|
|
|
<Container> |
|
|
|
<Header>Shifts</Header> |
|
|
|
<Header>Shifts</Header> |
|
|
|
|
|
|
|
<Segment.Group horizontal> |
|
|
|
|
|
|
|
<Segment> |
|
|
|
|
|
|
|
{"Filter by Approval: "} |
|
|
|
|
|
|
|
<Dropdown |
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
placeholder="All" |
|
|
|
|
|
|
|
options={approvedOptions} |
|
|
|
|
|
|
|
onChange={handleChangeApprovalFilter} |
|
|
|
|
|
|
|
value={approvalFilter} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</Segment> |
|
|
|
|
|
|
|
</Segment.Group> |
|
|
|
{!!isSendingPShiftRequest && <Loader content="Loading" active />} |
|
|
|
{!!isSendingPShiftRequest && <Loader content="Loading" active />} |
|
|
|
{!isSendingPShiftRequest && |
|
|
|
{!isSendingPShiftRequest && |
|
|
|
results.length > 0 && ( |
|
|
|
results.length > 0 && ( |
|
|
|