Skip to content

Commit 8f96e37

Browse files
committed
implement data table in data hub
1 parent 166cb0e commit 8f96e37

1 file changed

Lines changed: 39 additions & 30 deletions

File tree

apps/web/src/routes/_app/datahub/index.tsx

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { toBasicISOString } from '@douglasneuroinformatics/libjs';
44
import {
55
ActionDropdown,
66
Button,
7-
ClientTable,
7+
DataTable,
88
Dialog,
99
Heading,
1010
SearchBar
@@ -23,6 +23,7 @@ import { PageHeader } from '@/components/PageHeader';
2323
import { subjectsQueryOptions, useSubjectsQuery } from '@/hooks/useSubjectsQuery';
2424
import { useAppStore } from '@/store';
2525
import { downloadExcel } from '@/utils/excel';
26+
2627
type MasterDataTableProps = {
2728
data: Subject[];
2829
onSelect: (subject: Subject) => void;
@@ -33,36 +34,44 @@ const MasterDataTable = ({ data, onSelect }: MasterDataTableProps) => {
3334
const subjectIdDisplaySetting = useAppStore((store) => store.currentGroup?.settings.subjectIdDisplayLength);
3435

3536
return (
36-
<ClientTable<Subject>
37-
columns={[
38-
{
39-
field: (subject) => removeSubjectIdScope(subject.id).slice(0, subjectIdDisplaySetting ?? 9),
40-
label: t('datahub.index.table.subject')
41-
},
42-
{
43-
field: (subject) => (subject.dateOfBirth ? toBasicISOString(new Date(subject.dateOfBirth)) : 'NULL'),
44-
label: t('core.identificationData.dateOfBirth.label')
45-
},
46-
{
47-
field: (subject) => {
48-
switch (subject.sex) {
49-
case 'FEMALE':
50-
return t('core.identificationData.sex.female');
51-
case 'MALE':
52-
return t('core.identificationData.sex.male');
53-
default:
54-
return 'NULL';
55-
}
37+
<div>
38+
<DataTable
39+
columns={[
40+
{
41+
accessorFn: (subject) => removeSubjectIdScope(subject.id).slice(0, subjectIdDisplaySetting ?? 9),
42+
header: t('datahub.index.table.subject'),
43+
id: 'subject'
5644
},
57-
label: t('core.identificationData.sex.label')
58-
}
59-
]}
60-
data={data}
61-
data-testid="master-data-table"
62-
entriesPerPage={15}
63-
minRows={15}
64-
onEntryClick={onSelect}
65-
/>
45+
{
46+
accessorFn: (subject) => (subject.dateOfBirth ? toBasicISOString(new Date(subject.dateOfBirth)) : 'NULL'),
47+
header: t('core.identificationData.dateOfBirth.label'),
48+
id: 'date-of-birth'
49+
},
50+
{
51+
accessorFn: (subject) => {
52+
switch (subject.sex) {
53+
case 'FEMALE':
54+
return t('core.identificationData.sex.female');
55+
case 'MALE':
56+
return t('core.identificationData.sex.male');
57+
default:
58+
return 'NULL';
59+
}
60+
},
61+
header: t('core.identificationData.sex.label'),
62+
id: 'sex'
63+
}
64+
]}
65+
data={data}
66+
data-testid="master-data-table"
67+
rowActions={[
68+
{
69+
label: t({ en: 'View', fr: 'Voir' }),
70+
onSelect
71+
}
72+
]}
73+
/>
74+
</div>
6675
);
6776
};
6877

0 commit comments

Comments
 (0)