mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-06-30 20:39:46 +02:00
Remove redundant state for pagination
This commit is contained in:
parent
3bb09f8593
commit
906538d5be
1 changed files with 1 additions and 7 deletions
|
|
@ -87,8 +87,8 @@ export default function SimulationApp() {
|
||||||
const [allRunResults, setAllRunResults] = useState<Record<string, SimulationResultType[]>>({});
|
const [allRunResults, setAllRunResults] = useState<Record<string, SimulationResultType[]>>({});
|
||||||
const [workflowVersions, setWorkflowVersions] = useState<Record<string, WithStringId<z.infer<typeof Workflow>>>>({});
|
const [workflowVersions, setWorkflowVersions] = useState<Record<string, WithStringId<z.infer<typeof Workflow>>>>({});
|
||||||
const [menuOpenId, setMenuOpenIdState] = useState<string | null>(null);
|
const [menuOpenId, setMenuOpenIdState] = useState<string | null>(null);
|
||||||
const [currentPage, setCurrentPage] = useState(Number(searchParams.get('page')) || 1);
|
|
||||||
const runsPerPage = 10;
|
const runsPerPage = 10;
|
||||||
|
const currentPage = Number(searchParams.get('page')) || 1;
|
||||||
|
|
||||||
const setMenuOpenId = useCallback((id: string | null) => {
|
const setMenuOpenId = useCallback((id: string | null) => {
|
||||||
setMenuOpenIdState(id);
|
setMenuOpenIdState(id);
|
||||||
|
|
@ -375,12 +375,6 @@ export default function SimulationApp() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add this effect to update currentPage when URL changes
|
|
||||||
useEffect(() => {
|
|
||||||
const page = Number(searchParams.get('page')) || 1;
|
|
||||||
setCurrentPage(page);
|
|
||||||
}, [searchParams]);
|
|
||||||
|
|
||||||
const indexOfLastRun = currentPage * runsPerPage;
|
const indexOfLastRun = currentPage * runsPerPage;
|
||||||
const indexOfFirstRun = indexOfLastRun - runsPerPage;
|
const indexOfFirstRun = indexOfLastRun - runsPerPage;
|
||||||
const currentRuns = runs.slice(indexOfFirstRun, indexOfLastRun);
|
const currentRuns = runs.slice(indexOfFirstRun, indexOfLastRun);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue