diff --git a/src/components/run/RunsTable.tsx b/src/components/run/RunsTable.tsx index 04634b6d..091a6c44 100644 --- a/src/components/run/RunsTable.tsx +++ b/src/components/run/RunsTable.tsx @@ -86,6 +86,8 @@ export const RunsTable: React.FC = ({ const { t } = useTranslation(); const navigate = useNavigate(); + const [accordionPage, setAccordionPage] = useState(0); + const [accordionsPerPage, setAccordionsPerPage] = useState(10); const [accordionSortConfigs, setAccordionSortConfigs] = useState({}); const handleSort = useCallback((columnId: keyof Data, robotMetaId: string) => { @@ -114,8 +116,6 @@ export const RunsTable: React.FC = ({ [t] ); - // const [page, setPage] = useState(0); - // const [rowsPerPage, setRowsPerPage] = useState(10); const [rows, setRows] = useState([]); const [searchTerm, setSearchTerm] = useState(''); const [isLoading, setIsLoading] = useState(true); @@ -128,6 +128,15 @@ export const RunsTable: React.FC = ({ navigate(isExpanded ? `/runs/${robotMetaId}` : '/runs'); }, [navigate]); + const handleAccordionPageChange = useCallback((event: unknown, newPage: number) => { + setAccordionPage(newPage); + }, []); + + const handleAccordionsPerPageChange = useCallback((event: React.ChangeEvent) => { + setAccordionsPerPage(+event.target.value); + setAccordionPage(0); + }, []); + const handleChangePage = useCallback((robotMetaId: string, newPage: number) => { setPaginationStates(prev => ({ ...prev, @@ -174,6 +183,7 @@ export const RunsTable: React.FC = ({ const handleSearchChange = useCallback((event: React.ChangeEvent) => { const debouncedSetSearch = debouncedSearch((value: string) => { setSearchTerm(value); + setAccordionPage(0); setPaginationStates(prev => { const reset = Object.keys(prev).reduce((acc, robotId) => ({ ...acc, @@ -347,86 +357,101 @@ export const RunsTable: React.FC = ({ - {Object.entries(groupedRows).map(([robotMetaId, data]) => ( - handleAccordionChange(robotMetaId, isExpanded)} - TransitionProps={{ unmountOnExit: true }} // Optimize accordion rendering - > - }> - {data[data.length - 1].name} - - - - - - - {translatedColumns.map((column) => ( - { - if (column.id === 'startedAt' || column.id === 'finishedAt') { - handleSort(column.id, robotMetaId); - } - }} - > - - ( + handleAccordionChange(robotMetaId, isExpanded)} + TransitionProps={{ unmountOnExit: true }} // Optimize accordion rendering + > + }> + {data[data.length - 1].name} + + +
+ + + + {translatedColumns.map((column) => ( + { + if (column.id === 'startedAt' || column.id === 'finishedAt') { + handleSort(column.id, robotMetaId); } - }}> - {column.label} - + + - {renderSortIcon(column, robotMetaId)} + {column.label} + + {renderSortIcon(column, robotMetaId)} + - - - - ))} - - - - {renderTableRows(data, robotMetaId)} - -
+ + + ))} + + + + {renderTableRows(data, robotMetaId)} + + - handleChangePage(robotMetaId, newPage)} - onRowsPerPageChange={(event) => - handleChangeRowsPerPage(robotMetaId, +event.target.value) - } - rowsPerPageOptions={[10, 25, 50, 100]} - /> -
-
- ))} + handleChangePage(robotMetaId, newPage)} + onRowsPerPageChange={(event) => + handleChangeRowsPerPage(robotMetaId, +event.target.value) + } + rowsPerPageOptions={[10, 25, 50, 100]} + /> + + + ))}
+ + ); }; \ No newline at end of file