1
1
import React , { useState } from 'react' ;
2
- // import { useQuery } from 'react-query';
3
- // import { Table, Spin, Radio } from 'antd';
4
2
import { IconDatabaseOff } from '@tabler/icons-react' ;
5
3
import { Loader , Table , Pagination , Select } from '@mantine/core' ;
6
- // import { fetchCohortDefinitions } from '../../../Utils/cohortMiddlewareApi';
7
- // import queryConfig from '../../../../SharedUtils/QueryConfig';
8
4
import { useFilter } from '../../../Utils/formHooks' ;
9
5
import { CohortsEndpoint } from '@/lib/AnalysisApps/SharedUtils/Endpoints' ;
10
6
import useSWR from 'swr' ;
@@ -29,7 +25,6 @@ const CohortDefinitions: React.FC<CohortDefinitionsProps> = ({
29
25
selectedTeamProject,
30
26
} ) => {
31
27
// State to manage selected row (only one row at a time)
32
- // const [selectedRow, setSelectedRow] = useState(null);
33
28
const [ page , setPage ] = useState ( 1 ) ; // Track current page
34
29
const [ rowsPerPage , setRowsPerPage ] = useState ( 10 ) ; // Number of rows to show per page
35
30
@@ -40,44 +35,6 @@ const CohortDefinitions: React.FC<CohortDefinitionsProps> = ({
40
35
) ;
41
36
let displayedCohorts : cohort [ ] = useFilter ( data , searchTerm , 'cohort_name' ) ;
42
37
43
- /*
44
- const handleSelectCohort = (cohortId) => {
45
- setSelectedCohort(cohortId);
46
- };
47
- */
48
- /*
49
- const cohortSelection = (inputSelectedCohort) => ({
50
- type: 'radio',
51
- columnTitle: 'Select',
52
- selectedRowKeys: inputSelectedCohort
53
- ? [inputSelectedCohort.cohort_definition_id]
54
- : [],
55
- onChange: (_, selectedRows) => {
56
- handleCohortSelect(selectedRows[0]);
57
- },
58
- renderCell: (checked, record) => null,
59
-
60
- */
61
- /* <Radio
62
- checked={checked}
63
- value={record.cohort_definition_id}
64
- aria-label={'Row action: study population selection'}
65
- />
66
- });*/
67
- /*
68
- const cohortTableConfig = [
69
- {
70
- title: 'Cohort Name',
71
- dataIndex: 'cohort_name',
72
- key: 'cohort_name',
73
- },
74
- {
75
- title: 'Size',
76
- dataIndex: 'size',
77
- key: 'size',
78
- },
79
- ];
80
- */
81
38
if ( error )
82
39
return < React . Fragment > Error getting data for table</ React . Fragment > ;
83
40
@@ -95,6 +52,7 @@ const CohortDefinitions: React.FC<CohortDefinitionsProps> = ({
95
52
( page - 1 ) * rowsPerPage ,
96
53
page * rowsPerPage ,
97
54
) ;
55
+ const totalPagesForPagination = Math . ceil ( data . length / rowsPerPage ) ;
98
56
return (
99
57
< React . Fragment >
100
58
< div className = "w-full min-h-[200px] py-5" >
@@ -148,7 +106,7 @@ const CohortDefinitions: React.FC<CohortDefinitionsProps> = ({
148
106
className = "pt-5 flex justify-end"
149
107
value = { page }
150
108
onChange = { setPage }
151
- total = { Math . ceil ( data . length / rowsPerPage ) } // Calculate total pages
109
+ total = { totalPagesForPagination } // Calculate total pages
152
110
color = "blue"
153
111
size = "md"
154
112
withEdges
0 commit comments