-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ft : reject order setup * ft : add reject order submission * fix : reject order
- Loading branch information
Showing
7 changed files
with
225 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import React, { useState } from "react"; | ||
|
||
import { | ||
Button, | ||
ContentSwitcher, | ||
Form, | ||
ModalBody, | ||
ModalFooter, | ||
ModalHeader, | ||
Select, | ||
SelectItem, | ||
Switch, | ||
TextArea, | ||
Grid, | ||
Checkbox, | ||
TextInput, | ||
IconButton, | ||
} from "@carbon/react"; | ||
import { useTranslation } from "react-i18next"; | ||
import styles from "./reject-order-dialog.scss"; | ||
import { Result } from "../work-list/work-list.resource"; | ||
import { RejectOrder } from "./reject-order-dialog.resource"; | ||
import { showNotification, showToast } from "@openmrs/esm-framework"; | ||
|
||
interface RejectOrderDialogProps { | ||
order: Result; | ||
closeModal: () => void; | ||
} | ||
|
||
const RejectOrderDialog: React.FC<RejectOrderDialogProps> = ({ | ||
order, | ||
closeModal, | ||
}) => { | ||
const { t } = useTranslation(); | ||
|
||
const [notes, setNotes] = useState(""); | ||
|
||
const rejectOrder = async (event) => { | ||
event.preventDefault(); | ||
|
||
const payload = { | ||
fulfillerStatus: "EXCEPTION", // Todo changed to Declined when UgEMR module is upgraded to 2.6.1 | ||
fulfillerComment: notes, | ||
}; | ||
RejectOrder(order.uuid, payload).then( | ||
(resp) => { | ||
showToast({ | ||
critical: true, | ||
title: t("rejectOrder", "Rejected Order"), | ||
kind: "success", | ||
description: t( | ||
"successfullyrejected", | ||
`You have successfully rejected an Order with OrderNumber ${order.orderNumber} ` | ||
), | ||
}); | ||
closeModal(); | ||
}, | ||
(err) => { | ||
showNotification({ | ||
title: t(`errorRejecting order', 'Error Rejecting a order`), | ||
kind: "error", | ||
critical: true, | ||
description: err?.message, | ||
}); | ||
} | ||
); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<Form onSubmit={rejectOrder}> | ||
<ModalHeader | ||
closeModal={closeModal} | ||
title={t("rejectOrder", "Reject Order")} | ||
/> | ||
<ModalBody> | ||
<div className={styles.modalBody}> | ||
<section className={styles.section}> | ||
<h5 className={styles.section}> | ||
{order?.accessionNumber} · {order?.fulfillerStatus}{" "} | ||
· | ||
{order?.orderNumber} | ||
| ||
</h5> | ||
</section> | ||
<br /> | ||
<section className={styles.section}> | ||
<TextArea | ||
labelText={t("notes", "Enter Comments ")} | ||
id="nextNotes" | ||
name="nextNotes" | ||
invalidText="Required" | ||
helperText="Please enter comment" | ||
maxCount={500} | ||
enableCounter | ||
onChange={(e) => setNotes(e.target.value)} | ||
/> | ||
</section> | ||
</div> | ||
</ModalBody> | ||
<ModalFooter> | ||
<Button kind="secondary" onClick={closeModal}> | ||
{t("cancel", "Cancel")} | ||
</Button> | ||
<Button kind="danger" type="submit"> | ||
{t("rejectOrder", "Reject Order")} | ||
</Button> | ||
</ModalFooter> | ||
</Form> | ||
</div> | ||
); | ||
}; | ||
|
||
export default RejectOrderDialog; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { FetchResponse, openmrsFetch, useConfig } from "@openmrs/esm-framework"; | ||
|
||
export async function RejectOrder(uuid: string, body: any) { | ||
const abortController = new AbortController(); | ||
|
||
return openmrsFetch(`/ws/rest/v1/order/${uuid}/fulfillerdetails/`, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
signal: abortController.signal, | ||
body: body, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@use '@carbon/styles/scss/spacing'; | ||
@use '@carbon/styles/scss/type'; | ||
|
||
section { | ||
margin: spacing.$spacing-03; | ||
} | ||
|
||
.sectionTitle { | ||
margin-bottom: spacing.$spacing-04; | ||
} | ||
|
||
.modalBody { | ||
padding-bottom: spacing.$spacing-05; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters