diff --git a/src/app/page.tsx b/src/app/page.tsx index f2fa9b5..c28adb5 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -4,6 +4,7 @@ import RedditFeed from "@/components/reddit-feed"; import { Metadata } from "next"; import TopRecordedGames from "@/components/recs/top-recorded-games"; import BannerAd from "@/components/ads/bannerAd"; +import { Suspense } from "react"; export const metadata: Metadata = { title: "Home - AoM.gg", @@ -34,7 +35,9 @@ export default function Home() {
- + + +
diff --git a/src/components/data-table-pagination.tsx b/src/components/data-table-pagination.tsx index d3bebda..2fc38a1 100644 --- a/src/components/data-table-pagination.tsx +++ b/src/components/data-table-pagination.tsx @@ -7,6 +7,9 @@ import { import { Table } from "@tanstack/react-table"; import { Button } from "@/components/ui/button"; +import { useQueryParams } from "@/hooks/useQueryParams"; +import { useSearchParams } from "next/navigation"; +import { useEffect } from "react"; interface DataTablePaginationProps { table: Table; @@ -15,6 +18,20 @@ interface DataTablePaginationProps { export function DataTablePagination({ table, }: DataTablePaginationProps) { + const rowOptions = [50, 100, 200] + + const searchParams = useSearchParams(); + const rows = searchParams.get("rows"); + const queryParams = useQueryParams({ rows: "50" }); + + useEffect(() => { + if (rowOptions.includes(Number(rows))) { + table.setPageSize(Number(rows)) + return + } + table.setPageSize(rowOptions[0]) + }, []); + return (
{/* Left-aligned content */} @@ -26,9 +43,10 @@ export function DataTablePagination({ value={table.getState().pagination.pageSize} onChange={(e) => { table.setPageSize(Number(e.target.value)); + queryParams.rows(e.target.value); }} > - {[50, 100, 200].map((pageSize) => ( + {rowOptions.map((pageSize) => (