Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
pirupius committed Feb 7, 2024
1 parent 415030a commit 70e5951
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,9 @@
.buttons {
justify-content: flex-end;
}

.singleLineText {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
Tooltip,
Dropdown,
DataTableSkeleton,
Tag,
} from '@carbon/react';
import {
CardHeader,
Expand Down Expand Up @@ -139,15 +140,9 @@ const OrderDetailsTable: React.FC<OrderDetailsProps> = ({ title, patientUuid, sh
),
orderedBy: order.orderer?.display,
status: (
<div
style={{
background: orderStatusColor(order.fulfillerStatus),
textAlign: 'center',
borderRadius: '1rem',
}}
>
{capitalize(order.fulfillerStatus ?? '--')}
</div>
<Tag type={orderStatusColor(order.fulfillerStatus)} className={styles.singleLineText}>
{order.fulfillerStatus ?? '--'}
</Tag>
),
}));

Expand Down
4 changes: 2 additions & 2 deletions packages/esm-patient-orders-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { configSchema } from './config-schema';
import orderBasketActionMenuComponent from './order-basket-action-button/order-basket-action-button.extension';
import { ordersDashboardMeta } from './dashboard.meta';
import OrdersSummary from './orders-summary/orders-summary.component';
import OrderCancellationForm from './order-cancellation-form/order-cancellation-form.component';
import CancelOrderForm from './order-cancellation-form/cancel-order-form.component';

export const importTranslation = require.context('../translations', false, /.json$/, 'lazy');

Expand Down Expand Up @@ -47,4 +47,4 @@ export const ordersDashboardLink =

export const ordersDashboard = getSyncLifecycle(OrdersSummary, options);

export const orderCancellationForm = getSyncLifecycle(OrderCancellationForm, options);
export const cancelOrderForm = getSyncLifecycle(CancelOrderForm, options);
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import {
DatePicker,
DatePickerInput,
} from '@carbon/react';
import { showSnackbar, useLayoutType, useSession, usePatient, useVisit } from '@openmrs/esm-framework';
import { type Order } from '@openmrs/esm-patient-common-lib';
import styles from './order-cancellation-form.scss';
import { showSnackbar, useLayoutType } from '@openmrs/esm-framework';
import { usePatientOrders, type Order } from '@openmrs/esm-patient-common-lib';
import styles from './cancel-order-form.scss';
import { saveCancelOrderRequest } from './cancel-order.resource';
import dayjs from 'dayjs';

Expand All @@ -30,12 +30,10 @@ interface OrderCancellationFormProps {
const OrderCancellationForm: React.FC<OrderCancellationFormProps> = ({ order, patientUuid, closeWorkspace }) => {
const { t } = useTranslation();
const isTablet = useLayoutType() === 'tablet';
const session = useSession();
const patient = usePatient(patientUuid);
const { currentVisit } = useVisit(patientUuid);
const [isSubmitting, setIsSubmitting] = useState(false);
const [showErrorNotification, setShowErrorNotification] = useState(false);
const [showErrorMessage, setShowErrorMessage] = useState(false);

const { mutate } = usePatientOrders(patientUuid, 'ACTIVE');

const cancelOrderSchema = useMemo(() => {
return z.object({
Expand All @@ -59,7 +57,6 @@ const OrderCancellationForm: React.FC<OrderCancellationFormProps> = ({ order, pa

const cancelOrderRequest = useCallback((data: CancelOrderFormData) => {
const formData = data;
setShowErrorMessage(true);
setShowErrorNotification(false);
setIsSubmitting(true);

Expand All @@ -74,13 +71,16 @@ const OrderCancellationForm: React.FC<OrderCancellationFormProps> = ({ order, pa
(res) => {
setIsSubmitting(false);
closeWorkspace();
mutate();

showSnackbar({
isLowContrast: true,
title: t('cancelOrder', 'Cancel Order'),
kind: 'success',
subtitle: t(
'successfullyCancelledOrder',
`You have successfully cancelled an order with OrderNumber ${order.orderNumber} `,
'You have successfully cancelled an order with OrderNumber {{orderNumber}}',
{ orderNumber: order.orderNumber },
),
});
},
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-patient-orders-app/src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
{
"name": "patient-orders-form-workspace",
"component": "orderCancellationForm",
"component": "cancelOrderForm",
"meta": {
"title": {
"key": "orderCancellation",
Expand Down
16 changes: 8 additions & 8 deletions packages/esm-patient-orders-app/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ export function orderPriorityToColor(priority) {
export function orderStatusColor(status) {
switch (status) {
case 'RECEIVED':
return '#e8daff';
return 'blue';
case 'IN_PROGRESS':
return '#defbe6';
return 'cyan';
case 'ON_HOLD':
return '#fff8e1';
return 'teal';
case 'EXCEPTION':
return '#d0e2ff';
return 'magenta';
case 'COMPLETED':
return '#a7f0ba';
return 'green';
case 'DISCONTINUED':
return '#ffd7d9';
return 'red';
case 'DECLINED':
return '#ffd7d9';
return 'red';
default:
return '#dde1e6';
return 'gray';
}
}

Expand Down
9 changes: 8 additions & 1 deletion packages/esm-patient-orders-app/translations/en.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"add": "Add",
"addResults": "Add Results",
"cancellationDate": "Cancellation date",
"cancelOrder": "Cancel Order",
"dateOfOrder": "Date of Order",
"discard": "Discard",
"error": "Error",
"errorCancellingOrder": "Error cancelling order",
"female": "Female",
"male": "Male",
"onDate": "on",
Expand All @@ -11,13 +15,16 @@
"orderId": "Order ID",
"orders": "Orders",
"Orders": "Orders",
"orderCancellation": "Order Cancellation",
"orderType": "Order Type",
"other": "Other",
"pleaseFillField": "Please fill at least one field",
"print": "Print",
"printedBy": "Printed by",
"priority": "Priority",
"reasonForCancellation": "Reason for cancellation",
"saveAndClose": "Save and close",
"status": "Status",
"successfullyCancelledOrder": "You have successfully cancelled an order with OrderNumber {{orderNumber}}",
"unknown": "Unknown",
"viewEdit": "View/Edit Order"
}

0 comments on commit 70e5951

Please sign in to comment.