diff --git a/src/components/ResourceTable.tsx b/src/components/ResourceTable.tsx
index cd30914..fb68cbc 100644
--- a/src/components/ResourceTable.tsx
+++ b/src/components/ResourceTable.tsx
@@ -123,15 +123,45 @@ const ResourceEntry = ({resource}: {resource: AuditoryResource}) => {
)
}
-const ResourceTable = ({resources}: {resources?: AuditoryResource[]}) => {
+const PagesNavigation = ({currentPage, pageCount}: {currentPage: number, pageCount: number}) => {
+ const PageButton = ({number}: {number: number}) => {
+ return (
+
+
+ {number}
+
+
+ )
+ }
+
+ const pages = Array.from(Array(pageCount).keys()).map((pageNumber) => {
+ return (
+
+ )
+ });
+
+ return (
+
+ )
+ }
- const resourceElements = resources?.map((resource, index) => {
+const ResourceTable = ({resources, currentPage}: {resources?: AuditoryResource[], currentPage: number}) => {
+ const resourcesPerPage = 10;
+ const totalPages = Math.ceil((resources?.length ?? 0) / resourcesPerPage);
+ const pageResources = resources?.slice(resourcesPerPage*(currentPage-1), (resourcesPerPage*currentPage)) ?? [];
+ const resourceElements = pageResources?.map((resource, index) => {
return ();
}) ?? [];
return(
+
diff --git a/src/pages/resources/index.tsx b/src/pages/resources/index.tsx
index bd7fde9..8df20af 100644
--- a/src/pages/resources/index.tsx
+++ b/src/pages/resources/index.tsx
@@ -1,6 +1,7 @@
import { createProxySSGHelpers } from "@trpc/react-query/ssg";
import Head from "next/head";
import Link from "next/link";
+import { useRouter } from "next/router";
import ResourceTable from "~/components/ResourceTable";
import { appRouter } from "~/server/api/root";
import { prisma } from "~/server/db";
@@ -25,7 +26,13 @@ export async function getStaticProps() {
}
const Resources = () => {
+ const router = useRouter()
const query = api.auditoryResource.getAll.useQuery();
+ if (!query.data) {
+ return <>>
+ }
+
+ const currentPage = Number(router.query["page"] ?? 1)
return (
<>
@@ -36,15 +43,7 @@ const Resources = () => {
>
diff --git a/src/server/api/routers/auditoryResources.ts b/src/server/api/routers/auditoryResources.ts
index 92f7ac8..2eb22d4 100644
--- a/src/server/api/routers/auditoryResources.ts
+++ b/src/server/api/routers/auditoryResources.ts
@@ -18,6 +18,6 @@ export const auditoryResourceRouter = createTRPCRouter({
}),
getAll: publicProcedure.query(({ ctx }) => {
- return ctx.prisma.auditoryResource.findMany({ take:10 });
+ return ctx.prisma.auditoryResource.findMany();
}),
});