"use client"; import { Table, TableBody, TableCaption, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import { parseAsInteger } from "next-usequerystate"; import { findAllRunsWithCounts, getAllRunstableContent, } from "../server/findAllRuns"; import { PaginationControl } from "./PaginationControl"; import { RunDisplay } from "./RunDisplay"; import useSWR from "swr"; import { LoadingIcon } from "@/components/LoadingIcon"; const itemPerPage = 6; const pageParser = parseAsInteger.withDefault(1); export function RunsTable(props: { workflow_id: string; searchParams: { [key: string]: any }; }) { const page = pageParser.parse(props.searchParams?.page ?? undefined) ?? 1; const { data, error, isLoading, isValidating } = useSWR( "runs+" + page, async () => { const data = await getAllRunstableContent({ workflow_id: props.workflow_id, limit: itemPerPage, offset: (page - 1) * itemPerPage, }); return data; }, { // suspense: false, refreshInterval: 5000, }, ); // await new Promise((resolve) => setTimeout(resolve, 5000)); return (