This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
CarePlanTable.tsx
63 lines (56 loc) · 1.67 KB
/
CarePlanTable.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { Alert, Table } from '@hospitalrun/components'
import format from 'date-fns/format'
import React from 'react'
import { useHistory } from 'react-router-dom'
import Loading from '../../shared/components/Loading'
import useTranslator from '../../shared/hooks/useTranslator'
import usePatientCarePlans from '../hooks/usePatientCarePlans'
interface Props {
patientId: string
}
const CarePlanTable = (props: Props) => {
const { patientId } = props
const history = useHistory()
const { t } = useTranslator()
const { data, status } = usePatientCarePlans(patientId)
if (data === undefined || status === 'loading') {
return <Loading />
}
if (data.length === 0) {
return (
<Alert
color="warning"
title={t('patient.carePlans.warning.noCarePlans')}
message={t('patient.carePlans.warning.addCarePlanAbove')}
/>
)
}
return (
<Table
getID={(row) => row.id}
data={data}
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: t('actions.view'),
action: (row) => history.push(`/patients/${patientId}/care-plans/${row.id}`),
},
]}
/>
)
}
export default CarePlanTable