MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / SessionsTable

Function SessionsTable

apps/start/src/components/sessions/table/index.tsx:270–357  ·  view source on GitHub ↗
({ query }: Props)

Source from the content-addressed store, hash-verified

268};
269
270export const SessionsTable = ({ query }: Props) => {
271 const { isLoading } = query;
272 const columns = useColumns();
273 const navigate = useNavigate();
274 const { organizationId, projectId } = useAppParams();
275
276 const handleRowClick = useCallback(
277 (row: any) => {
278 navigate({
279 to: '/$organizationId/$projectId/sessions/$sessionId',
280 params: { organizationId, projectId, sessionId: row.original.id },
281 });
282 },
283 [navigate, organizationId, projectId]
284 );
285
286 const data = useMemo(() => {
287 if (isLoading) {
288 return LOADING_DATA;
289 }
290
291 return query.data?.pages?.flatMap((p) => p.items) ?? [];
292 }, [query.data]);
293
294 // const { setPage, state: pagination } = useDataTablePagination();
295 const { columnVisibility, setColumnVisibility } =
296 usePersistentColumnVisibility(columns);
297
298 const table = useReactTable({
299 data,
300 getCoreRowModel: getCoreRowModel(),
301 manualPagination: true,
302 manualFiltering: true,
303 manualSorting: true,
304 columns,
305 rowCount: 50,
306 pageCount: 1,
307 filterFns: {
308 isWithinRange: () => true,
309 },
310 state: {
311 columnVisibility,
312 },
313 onColumnVisibilityChange: setColumnVisibility,
314 getRowId: (row, index) => row.id ?? `loading-${index}`,
315 });
316
317 const inViewportRef = useRef<HTMLDivElement>(null);
318 const { inViewport, enterCount } = useInViewport(inViewportRef, undefined, {
319 disconnectOnLeave: true,
320 });
321
322 const hasNextPage = last(query.data?.pages ?? [])?.meta.next;
323
324 useEffect(() => {
325 if (
326 hasNextPage &&
327 data.length > 0 &&

Callers

nothing calls this directly

Calls 4

useColumnsFunction · 0.90
useAppParamsFunction · 0.90
cnFunction · 0.90

Tested by

no test coverage detected