From f0e961ac3d8f9eb55867a0abda47103ea0cb4002 Mon Sep 17 00:00:00 2001 From: Isaiah Hamilton <70828596+Isaiah-Hamilton@users.noreply.github.com> Date: Fri, 24 Jun 2022 23:11:58 -0400 Subject: [PATCH] chore: update pagination logic --- apps/temp-docs/components/pagination.tsx | 53 +++----- apps/temp-docs/pages/discussions/index.tsx | 135 ++++++++++----------- 2 files changed, 82 insertions(+), 106 deletions(-) diff --git a/apps/temp-docs/components/pagination.tsx b/apps/temp-docs/components/pagination.tsx index 44758cfee6e..61cb5db6a87 100644 --- a/apps/temp-docs/components/pagination.tsx +++ b/apps/temp-docs/components/pagination.tsx @@ -1,41 +1,36 @@ import Link from 'next/link' -import { useRouter } from 'next/router' +import { IconArrowLeft, IconArrowRight } from '@supabase/ui' + +const pagination = ({ currentPage, totalCount }: { currentPage: number, totalCount: number }) => { + // TODO: not sure if this is the most efficient way to do this. may need to refactor. + const totalArray = Array.from({ length: totalCount }, (_, i: number) => i + 1) + const pages = totalArray.filter((page: number) => { + return page >= currentPage - 2 && page <= currentPage + 2 + }) -const pagination = () => { - const router = useRouter() - const Page: any = router.query.page || 1 - const page = parseInt(Page) return (