Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
fix(patients): fixes related person search crashing if no DoB
Browse files Browse the repository at this point in the history
  • Loading branch information
blestab committed Jul 9, 2020
1 parent ebdaef5 commit babc7e3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/patients/related-persons/AddRelatedPersonModal.tsx
Expand Up @@ -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 = (
<form>
{relatedPersonError?.message && (
Expand All @@ -65,9 +67,7 @@ const AddRelatedPersonModal = (props: Props) => {
isInvalid={!!relatedPersonError?.relatedPerson}
onSearch={onSearch}
renderMenuItemChildren={(p: Patient) => (
<div>
{`${p.fullName} - ${format(new Date(p.dateOfBirth), 'yyyy-MM-dd')} (${p.code})`}
</div>
<div>{`${p.fullName} - ${formattedDate(p.dateOfBirth)} (${p.code})`}</div>
)}
/>
{relatedPersonError?.relatedPerson && (
Expand Down
7 changes: 1 addition & 6 deletions src/shared/hooks/useTranslator.ts
Expand Up @@ -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,
Expand Down

1 comment on commit babc7e3

@vercel
Copy link

@vercel vercel bot commented on babc7e3 Jul 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.