Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(refactor) Refactor registration form cancel modal to match conventions #1294

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/esm-appointments-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"createNewAppointment": "Create new appointment",
"date": "Date",
"date&Time": "Date & time",
"dateAppointmentIssuedCannotBeAfterAppointmentDate": "Date appointment issued cannot be after the appointment date",
"dateOfBirth": "Date of birth",
"dateScheduled": "Date appointment issued",
"dateScheduledDetail": "Date appointment issued",
Expand Down Expand Up @@ -124,6 +125,7 @@
"providers": "Providers",
"providersBooked": "Providers booked: {{time}}",
"recurringAppointment": "Recurring Appointment",
"recurringAppointmentShouldHaveEndDate": "A recurring appointment should have an end date",
"repeatEvery": "Repeat every",
"save": "Save",
"saveAndClose": "Save and close",
Expand Down
5 changes: 1 addition & 4 deletions packages/esm-patient-registration-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ export const editPatient = getSyncLifecycle(rootComponent, {

export const addPatientLink = getSyncLifecycle(addPatientLinkComponent, options);

export const cancelPatientEditModal = getAsyncLifecycle(
() => import('./widgets/cancel-patient-edit.component'),
options,
);
export const cancelPatientEditModal = getAsyncLifecycle(() => import('./widgets/cancel-patient-edit.modal'), options);

export const patientPhotoExtension = getSyncLifecycle(PatientPhotoExtension, options);

Expand Down
12 changes: 6 additions & 6 deletions packages/esm-patient-registration-app/src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@
"online": true,
"offline": true
},
{
"component": "cancelPatientEditModal",
"name": "cancel-patient-edit-modal",
"online": true,
"offline": true
},
{
"component": "patientPhotoExtension",
"name": "patient-photo-widget",
Expand Down Expand Up @@ -58,5 +52,11 @@
"online": true,
"offline": true
}
],
"modals": [
{
"name": "cancel-patient-edit-modal",
"component": "cancelPatientEditModal"
}
]
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { Button, ModalBody, ModalFooter, ModalHeader } from '@carbon/react';

interface CancelPatientEditPropsModal {
close(): void;
onConfirm(): void;
}

const CancelPatientEditModal: React.FC<CancelPatientEditPropsModal> = ({ close, onConfirm }) => {
const { t } = useTranslation();
return (
<>
<ModalHeader
closeModal={close}
title={t('confirmDiscardChangesTitle', 'Are you sure you want to discard these changes?')}
/>
<ModalBody>
<p>{t('confirmDiscardChangesBody', 'Your unsaved changes will be lost if you proceed to discard the form')}.</p>
</ModalBody>
<ModalFooter>
<Button kind="secondary" onClick={close}>
{t('cancel', 'Cancel')}
</Button>
<Button kind="danger" onClick={onConfirm}>
{t('discard', 'Discard')}
</Button>
</ModalFooter>
</>
);
};

export default CancelPatientEditModal;
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import React from 'react';
import userEvent from '@testing-library/user-event';
import { screen, render } from '@testing-library/react';
import CancelPatientEdit from './cancel-patient-edit.component';
import CancelPatientEdit from './cancel-patient-edit.modal';

describe('CancelPatientEdit component', () => {
describe('CancelPatientEdit modal', () => {
const mockClose = jest.fn();
const mockOnConfirm = jest.fn();

it('renders the modal and triggers close and onConfirm functions', async () => {
const user = userEvent.setup();

render(<CancelPatientEdit close={mockClose} onConfirm={mockOnConfirm} />);

const cancelButton = screen.getByRole('button', { name: /Cancel/i });
Expand Down
4 changes: 2 additions & 2 deletions packages/esm-patient-registration-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"codedPersonAttributeNoAnswerSet": "The person attribute field '{{codedPersonAttributeFieldId}}' is of type 'coded' but has been defined without an answer concept set UUID. The 'answerConceptSetUuid' key is required.",
"configure": "Configure",
"configureIdentifiers": "Configure identifiers",
"confirmDiscardChangesBody": "Your unsaved changes will be lost if you proceed to discard the form",
"confirmDiscardChangesTitle": "Are you sure you want to discard these changes?",
"confirmIdentifierDeletionText": "Are you sure you want to remove this identifier?",
"contactSection": "Contact Details",
"createNewPatient": "Create new patient",
Expand All @@ -27,8 +29,6 @@
"deleteRelationshipTooltipText": "Delete",
"demographicsSection": "Basic Info",
"discard": "Discard",
"discardModalBody": "The changes you made to this patient's details have not been saved. Discard changes?",
"discardModalHeader": "Confirm Discard Changes",
"dobToggleLabelText": "Date of Birth Known?",
"editIdentifierTooltip": "Edit",
"editPatientDetails": "Edit patient details",
Expand Down
Loading