diff --git a/src/__tests__/patients/related-persons/AddRelatedPersonModal.test.tsx b/src/__tests__/patients/related-persons/AddRelatedPersonModal.test.tsx index 23b5348334..b9c71a7fcf 100644 --- a/src/__tests__/patients/related-persons/AddRelatedPersonModal.test.tsx +++ b/src/__tests__/patients/related-persons/AddRelatedPersonModal.test.tsx @@ -143,10 +143,11 @@ describe('Add Related Person Modal', () => { wrapper.update() const errorAlert = wrapper.find(Alert) + expect(onSaveSpy).not.toHaveBeenCalled() expect(errorAlert).toHaveLength(1) expect(errorAlert.prop('message')).toEqual( - 'patient.relatedPersons.error.relatedPersonRequired patient.relatedPersons.error.relationshipTypeRequired', + 'patient.relatedPersons.error.relatedPersonErrorBanner', ) }) }) diff --git a/src/locales/enUs/translations/patient/index.ts b/src/locales/enUs/translations/patient/index.ts index e599ffb33f..7f83290fda 100644 --- a/src/locales/enUs/translations/patient/index.ts +++ b/src/locales/enUs/translations/patient/index.ts @@ -25,6 +25,7 @@ export default { relatedPerson: 'Related Person', relatedPersons: { error: { + relatedPersonErrorBanner: 'Unable to add new related person.', relatedPersonRequired: 'Related Person is required.', relationshipTypeRequired: 'Relationship Type is required.', }, diff --git a/src/patients/related-persons/AddRelatedPersonModal.tsx b/src/patients/related-persons/AddRelatedPersonModal.tsx index 809c8e66e1..fd648a924b 100644 --- a/src/patients/related-persons/AddRelatedPersonModal.tsx +++ b/src/patients/related-persons/AddRelatedPersonModal.tsx @@ -19,6 +19,8 @@ const AddRelatedPersonModal = (props: Props) => { const { show, toggle, onCloseButtonClick, onSave } = props const { t } = useTranslation() const [errorMessage, setErrorMessage] = useState('') + const [isRelatedPersonInvalid, setIsRelatedPersonInvalid] = useState(false) + const [isRelationshipInvalid, setIsRelationshipInvalid] = useState(false) const [relatedPerson, setRelatedPerson] = useState({ patientId: '', type: '', @@ -54,6 +56,7 @@ const AddRelatedPersonModal = (props: Props) => { searchAccessor="fullName" placeholder={t('patient.relatedPerson')} onChange={onPatientSelect} + isInvalid={isRelatedPersonInvalid} onSearch={async (query: string) => PatientRepository.search(query)} renderMenuItemChildren={(p: Patient) => { if (patientId() === p.id) { @@ -63,6 +66,11 @@ const AddRelatedPersonModal = (props: Props) => { return