@@ -31,7 +31,7 @@ const CohortDefinitions: React.FC<CohortDefinitionsProps> = ({
3131 CohortsEndpoint + '/' + sourceId + `/by-team-project?team-project=${ selectedTeamProject } ` ,
3232 ( ...args ) => fetch ( ...args ) . then ( ( res ) => res . json ( ) ) ,
3333 ) ;
34- let displayedCohorts : cohort [ ] = useFilter ( data ?. [ 'cohort_definitions_and_stats' ] , searchTerm , 'cohort_name' ) ;
34+ const displayedCohorts : cohort [ ] = useFilter ( data ?. [ 'cohort_definitions_and_stats' ] , searchTerm , 'cohort_name' ) ;
3535
3636 if ( error )
3737 return < React . Fragment > Error getting data for table</ React . Fragment > ;
@@ -43,17 +43,17 @@ const CohortDefinitions: React.FC<CohortDefinitionsProps> = ({
4343 </ div >
4444 ) ;
4545
46- if ( data ) {
47- displayedCohorts = displayedCohorts . slice (
46+ if ( displayedCohorts ) {
47+ const pageOfDisplayedCohorts = displayedCohorts . slice (
4848 ( page - 1 ) * rowsPerPage ,
4949 page * rowsPerPage ,
5050 ) ;
51- const totalPagesForPagination = Math . ceil ( data . length / rowsPerPage ) ;
51+ const totalPagesForPagination = Math . ceil ( displayedCohorts . length / rowsPerPage ) ;
5252
5353 return (
5454 < React . Fragment >
5555 < div className = "w-full min-h-[200px] py-5" >
56- { displayedCohorts ?. length > 0 ? (
56+ { pageOfDisplayedCohorts ?. length > 0 ? (
5757 < Table className = "shadow" >
5858 < Table . Thead className = "bg-vadc-slate_blue font-light" >
5959 < Table . Tr >
@@ -63,7 +63,7 @@ const CohortDefinitions: React.FC<CohortDefinitionsProps> = ({
6363 </ Table . Tr >
6464 </ Table . Thead >
6565 < Table . Tbody >
66- { displayedCohorts . map ( ( cohort , i ) => (
66+ { pageOfDisplayedCohorts . map ( ( cohort , i ) => (
6767 < Table . Tr
6868 key = { i }
6969 className = { i % 2 ? 'bg-vadc-alternate_row' : '' }
@@ -111,7 +111,10 @@ const CohortDefinitions: React.FC<CohortDefinitionsProps> = ({
111111 < Select
112112 className = "pt-5 pl-3 w-32"
113113 value = { rowsPerPage . toString ( ) }
114- onChange = { ( value ) => setRowsPerPage ( Number ( value ) ) }
114+ onChange = { ( value ) => {
115+ setRowsPerPage ( Number ( value ) ) ;
116+ setPage ( 1 ) ;
117+ } }
115118 size = "sm"
116119 aria-label = "pagination select"
117120 data = { [
0 commit comments