diff --git a/src/__tests__/patients/allergies/NewAllergyModal.test.tsx b/src/__tests__/patients/allergies/NewAllergyModal.test.tsx
index e4601bc4f5..7b7ff15dc0 100644
--- a/src/__tests__/patients/allergies/NewAllergyModal.test.tsx
+++ b/src/__tests__/patients/allergies/NewAllergyModal.test.tsx
@@ -84,7 +84,7 @@ describe('New Allergy Modal', () => {
expect(wrapper.find(Alert)).toHaveLength(1)
expect(wrapper.find(Alert).prop('title')).toEqual('states.error')
- expect(wrapper.find(Alert).prop('message')).toContain('patient.allergies.error.nameRequired')
+ expect(wrapper.find(Alert).prop('message')).toContain('patient.allergies.error.unableToAdd')
})
})
})
diff --git a/src/locales/enUs/translations/patient/index.ts b/src/locales/enUs/translations/patient/index.ts
index 3397b5d2b2..cd0a98c971 100644
--- a/src/locales/enUs/translations/patient/index.ts
+++ b/src/locales/enUs/translations/patient/index.ts
@@ -42,6 +42,7 @@ export default {
new: 'Add Allergy',
error: {
nameRequired: 'Name is required.',
+ unableToAdd: 'Unable to add allergy.',
},
warning: {
noAllergies: 'No Allergies',
diff --git a/src/patients/allergies/NewAllergyModal.tsx b/src/patients/allergies/NewAllergyModal.tsx
index e1ffd080ba..62e717f859 100644
--- a/src/patients/allergies/NewAllergyModal.tsx
+++ b/src/patients/allergies/NewAllergyModal.tsx
@@ -14,6 +14,8 @@ const NewAllergyModal = (props: NewAllergyModalProps) => {
const { show, onCloseButtonClick, onSave } = props
const [allergy, setAllergy] = useState({ name: '' })
const [errorMessage, setErrorMessage] = useState('')
+ const [isAllergyNameInvalid, setIsAllergynameInvalid] = useState(false)
+ const [nameRequiredFeedback, setNameRequiredFeedback] = useState('')
const { t } = useTranslation()
useEffect(() => {
@@ -29,7 +31,9 @@ const NewAllergyModal = (props: NewAllergyModalProps) => {
const onSaveButtonClick = () => {
let newErrorMessage = ''
if (!allergy.name) {
- newErrorMessage += `${t('patient.allergies.error.nameRequired')} `
+ newErrorMessage += `${t('patient.allergies.error.unableToAdd')} `
+ setIsAllergynameInvalid(true)
+ setNameRequiredFeedback(`${t('patient.allergies.error.nameRequired')} `)
}
if (newErrorMessage) {
@@ -49,6 +53,7 @@ const NewAllergyModal = (props: NewAllergyModalProps) => {
{errorMessage &&