11import React , { useState } from 'react' ;
2- // import { useQuery } from 'react-query';
3- // import { Table, Spin, Radio } from 'antd';
42import { IconDatabaseOff } from '@tabler/icons-react' ;
53import { Loader , Table , Pagination , Select } from '@mantine/core' ;
6- // import { fetchCohortDefinitions } from '../../../Utils/cohortMiddlewareApi';
7- // import queryConfig from '../../../../SharedUtils/QueryConfig';
84import { useFilter } from '../../../Utils/formHooks' ;
95import { CohortsEndpoint } from '@/lib/AnalysisApps/SharedUtils/Endpoints' ;
106import useSWR from 'swr' ;
@@ -29,7 +25,6 @@ const CohortDefinitions: React.FC<CohortDefinitionsProps> = ({
2925 selectedTeamProject,
3026} ) => {
3127 // State to manage selected row (only one row at a time)
32- // const [selectedRow, setSelectedRow] = useState(null);
3328 const [ page , setPage ] = useState ( 1 ) ; // Track current page
3429 const [ rowsPerPage , setRowsPerPage ] = useState ( 10 ) ; // Number of rows to show per page
3530
@@ -40,44 +35,6 @@ const CohortDefinitions: React.FC<CohortDefinitionsProps> = ({
4035 ) ;
4136 let displayedCohorts : cohort [ ] = useFilter ( data , searchTerm , 'cohort_name' ) ;
4237
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- */
8138 if ( error )
8239 return < React . Fragment > Error getting data for table</ React . Fragment > ;
8340
@@ -95,6 +52,7 @@ const CohortDefinitions: React.FC<CohortDefinitionsProps> = ({
9552 ( page - 1 ) * rowsPerPage ,
9653 page * rowsPerPage ,
9754 ) ;
55+ const totalPagesForPagination = Math . ceil ( data . length / rowsPerPage ) ;
9856 return (
9957 < React . Fragment >
10058 < div className = "w-full min-h-[200px] py-5" >
@@ -148,7 +106,7 @@ const CohortDefinitions: React.FC<CohortDefinitionsProps> = ({
148106 className = "pt-5 flex justify-end"
149107 value = { page }
150108 onChange = { setPage }
151- total = { Math . ceil ( data . length / rowsPerPage ) } // Calculate total pages
109+ total = { totalPagesForPagination } // Calculate total pages
152110 color = "blue"
153111 size = "md"
154112 withEdges
0 commit comments