From e43c9c7aa13cf1a76986945323379fa909e55e80 Mon Sep 17 00:00:00 2001 From: Jack Meyer Date: Sun, 28 Jun 2020 22:58:43 -0500 Subject: [PATCH] fix(care plans): fix undefined care plans behavior --- src/patients/care-plans/CarePlanTable.tsx | 59 ++++++++++++----------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/src/patients/care-plans/CarePlanTable.tsx b/src/patients/care-plans/CarePlanTable.tsx index 8c0bb2da82..f1f42e3a4c 100644 --- a/src/patients/care-plans/CarePlanTable.tsx +++ b/src/patients/care-plans/CarePlanTable.tsx @@ -12,34 +12,37 @@ const CarePlanTable = () => { const { t } = useTranslation() const { patient } = useSelector((state: RootState) => state.patient) - return ( - 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 ( +
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