diff --git a/src/patients/related-persons/AddRelatedPersonModal.tsx b/src/patients/related-persons/AddRelatedPersonModal.tsx index 7b57e6d3bb..c7a30bd8e0 100644 --- a/src/patients/related-persons/AddRelatedPersonModal.tsx +++ b/src/patients/related-persons/AddRelatedPersonModal.tsx @@ -48,6 +48,8 @@ const AddRelatedPersonModal = (props: Props) => { return patients.filter((p: Patient) => p.id !== patient.id) } + const formattedDate = (date: string) => (date ? format(new Date(date), 'yyyy-MM-dd') : '') + const body = (
{relatedPersonError?.message && ( @@ -65,9 +67,7 @@ const AddRelatedPersonModal = (props: Props) => { isInvalid={!!relatedPersonError?.relatedPerson} onSearch={onSearch} renderMenuItemChildren={(p: Patient) => ( -
- {`${p.fullName} - ${format(new Date(p.dateOfBirth), 'yyyy-MM-dd')} (${p.code})`} -
+
{`${p.fullName} - ${formattedDate(p.dateOfBirth)} (${p.code})`}
)} /> {relatedPersonError?.relatedPerson && ( diff --git a/src/shared/hooks/useTranslator.ts b/src/shared/hooks/useTranslator.ts index 7a55183aaf..353c81cf18 100644 --- a/src/shared/hooks/useTranslator.ts +++ b/src/shared/hooks/useTranslator.ts @@ -4,12 +4,7 @@ import { useTranslation } from 'react-i18next' export default function useTranslator() { const { t } = useTranslation() - const translate = useCallback( - (key: any): any => { - return key !== undefined ? t(key) : undefined - }, - [t], - ) + const translate = useCallback((key: any): any => (key !== undefined ? t(key) : undefined), [t]) return { t: translate,