diff --git a/packages/esm-service-queues-app/src/active-visits/change-status-dialog.component.tsx b/packages/esm-service-queues-app/src/active-visits/change-status-dialog.component.tsx index cfabd3a89..e9d9bad2a 100644 --- a/packages/esm-service-queues-app/src/active-visits/change-status-dialog.component.tsx +++ b/packages/esm-service-queues-app/src/active-visits/change-status-dialog.component.tsx @@ -1,31 +1,32 @@ import React, { useMemo } from 'react'; import { Button, + ContentSwitcher, + Form, + InlineLoading, + InlineNotification, ModalBody, ModalFooter, ModalHeader, - Form, - ContentSwitcher, - Switch, - Select, - SelectItem, - InlineNotification, RadioButton, RadioButtonGroup, - InlineLoading, + Select, + SelectItem, + Stack, + Switch, } from '@carbon/react'; import { useTranslation } from 'react-i18next'; -import { navigate, showSnackbar, useConfig } from '@openmrs/esm-framework'; -import { type MappedQueueEntry } from '../types'; -import { updateQueueEntry } from './active-visits-table.resource'; -import { useQueueLocations } from '../patient-search/hooks/useQueueLocations'; -import styles from './change-status-dialog.scss'; -import { useQueues } from '../hooks/useQueues'; import { useForm, Controller } from 'react-hook-form'; import { z } from 'zod'; import { zodResolver } from '@hookform/resolvers/zod'; +import { navigate, showSnackbar, useConfig } from '@openmrs/esm-framework'; +import { type MappedQueueEntry } from '../types'; import { type ConfigObject } from '../config-schema'; +import { useQueues } from '../hooks/useQueues'; +import { updateQueueEntry } from './active-visits-table.resource'; import { useMutateQueueEntries } from '../hooks/useQueueEntries'; +import { useQueueLocations } from '../patient-search/hooks/useQueueLocations'; +import styles from './change-status-dialog.scss'; interface ChangeStatusDialogProps { queueEntry: MappedQueueEntry; @@ -41,9 +42,9 @@ const ChangeStatus: React.FC = ({ queueEntry, closeModa () => z.object({ location: z.string({ required_error: t('queueLocationRequired', 'Queue location is required') }), + priority: z.string({ required_error: t('priorityIsRequired', 'Priority is required') }), service: z.string({ required_error: t('serviceIsRequired', 'Service is required') }), status: z.string({ required_error: t('statusIsRequired', 'Status is required') }), - priority: z.string({ required_error: t('priorityIsRequired', 'Priority is required') }), }), [], ); @@ -82,18 +83,16 @@ const ChangeStatus: React.FC = ({ queueEntry, closeModa endDate, sortWeight, ).then( - ({ status }) => { - if (status === 201) { - showSnackbar({ - isLowContrast: true, - title: t('updateEntry', 'Update entry'), - kind: 'success', - subtitle: t('queueEntryUpdateSuccessfully', 'Queue Entry Updated Successfully'), - }); - closeModal(); - mutateQueueEntries(); - navigate({ to: `${window.spaBase}/home/service-queues` }); - } + () => { + showSnackbar({ + isLowContrast: true, + title: t('updateEntry', 'Update entry'), + kind: 'success', + subtitle: t('queueEntryUpdateSuccessfully', 'Queue Entry Updated Successfully'), + }); + closeModal(); + mutateQueueEntries(); + navigate({ to: `${window.spaBase}/home/service-queues` }); }, (error) => { showSnackbar({ @@ -121,127 +120,131 @@ const ChangeStatus: React.FC = ({ queueEntry, closeModa
- {queueEntry.name}   ·  {queueEntry.patientSex}   ·  {queueEntry.patientAge}  - {t('years', 'Years')} + {t('patientInfo', '{{name}}{{sexInfo}}{{ageInfo}}', { + name: queueEntry.name, + sexInfo: queueEntry.patientSex ? ` · ${queueEntry.patientSex} · ` : '', + ageInfo: queueEntry.patientAge ? `${queueEntry.patientAge} ${t('years', 'Years')}` : '', + })}
-
- ( - - )} - /> -
- -
-
{t('queueService', 'Queue service')}
- ( - - )} - /> -
- -
-
{t('queueStatus', 'Queue status')}
- {!allowedStatuses?.length ? ( - - ) : ( + +
+
{t('queueLocation', 'Queue location')}
( - { - onChange(uuid); + render={({ field: { onChange, value } }) => ( + )} /> - )} -
- -
-
{t('queuePriority', 'Queue priority')}
- ( - <> - { - onChange(event.name as any); - }}> - {allowedPriorities?.length > 0 ? ( - allowedPriorities.map(({ uuid, display }) => { - return ; - }) - ) : ( - - )} - - {errors.priority &&
{errors.priority.message}
} - +
+
+
{t('queueService', 'Queue service')}
+ ( + + )} + /> +
+
+
{t('queueStatus', 'Queue status')}
+ {!allowedStatuses?.length ? ( + + ) : ( + ( + { + onChange(uuid); + }}> + {allowedStatuses?.length > 0 && + allowedStatuses.map(({ uuid, display }) => ( + + ))} + + )} + /> )} - /> -
+
+
+
{t('queuePriority', 'Queue priority')}
+ ( + <> + { + onChange(event.name as any); + }}> + {allowedPriorities?.length > 0 ? ( + allowedPriorities.map(({ uuid, display }) => { + return ; + }) + ) : ( + + )} + + {errors.priority &&
{errors.priority.message}
} + + )} + /> +
+