diff --git a/app/companions/page.tsx b/app/companions/page.tsx index c0801c4e..111da76a 100644 --- a/app/companions/page.tsx +++ b/app/companions/page.tsx @@ -3,13 +3,16 @@ import CompanionCard from "@/components/CompanionCard"; import {getSubjectColor} from "@/lib/utils"; import SearchInput from "@/components/SearchInput"; import SubjectFilter from "@/components/SubjectFilter"; +import Link from "next/link"; const CompanionsLibrary = async ({ searchParams }: SearchParams) => { const filters = await searchParams; - const subject = filters.subject ? filters.subject : ''; - const topic = filters.topic ? filters.topic : ''; + const subject = filters.subject ?? ''; + const topic = filters.topic ?? ''; + const page = parseInt(filters.page) || 1; + const limit = 9; - const companions = await getAllCompanions({ subject, topic }); + const companions = await getAllCompanions({ subject, topic, page, limit }); return (
@@ -20,6 +23,7 @@ const CompanionsLibrary = async ({ searchParams }: SearchParams) => { +
{companions.map((companion) => ( { /> ))}
+ +
+ {page > 1 && ( + + ← Previous + + )} + {companions.length === limit && ( + + Next → + + )} +
- ) + ); } + export default CompanionsLibrary