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

Commit

Permalink
fix(care plans): fix undefined care plans behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcmeyer committed Jun 29, 2020
1 parent 25d0902 commit e43c9c7
Showing 1 changed file with 31 additions and 28 deletions.
59 changes: 31 additions & 28 deletions src/patients/care-plans/CarePlanTable.tsx
Expand Up @@ -12,34 +12,37 @@ const CarePlanTable = () => {
const { t } = useTranslation()
const { patient } = useSelector((state: RootState) => state.patient)

return (
<Table
tableClassName="table table-hover"
getID={(row) => row.id}
data={patient.carePlans}
columns={[
{ label: t('patient.carePlan.title'), key: 'title' },
{
label: t('patient.carePlan.startDate'),
key: 'startDate',
formatter: (row) => format(new Date(row.startDate), 'yyyy-MM-dd'),
},
{
label: t('patient.carePlan.endDate'),
key: 'endDate',
formatter: (row) => format(new Date(row.endDate), 'yyyy-MM-dd'),
},
{ label: t('patient.carePlan.status'), key: 'status' },
]}
actionsHeaderText={t('actions.label')}
actions={[
{
label: 'actions.view',
action: (row) => history.push(`/patients/${patient.id}/care-plans/${row.id}`),
},
]}
/>
)
if (patient.carePlans !== undefined) {
return (
<Table
tableClassName="table table-hover"
getID={(row) => row.id}
data={patient.carePlans}
columns={[
{ label: t('patient.carePlan.title'), key: 'title' },
{
label: t('patient.carePlan.startDate'),
key: 'startDate',
formatter: (row) => format(new Date(row.startDate), 'yyyy-MM-dd'),
},
{
label: t('patient.carePlan.endDate'),
key: 'endDate',
formatter: (row) => format(new Date(row.endDate), 'yyyy-MM-dd'),
},
{ label: t('patient.carePlan.status'), key: 'status' },
]}
actionsHeaderText={t('actions.label')}
actions={[
{
label: 'actions.view',
action: (row) => history.push(`/patients/${patient.id}/care-plans/${row.id}`),
},
]}
/>
)
}
return <></>
}

export default CarePlanTable

0 comments on commit e43c9c7

Please sign in to comment.