From e5d338414df12198a43a7d793ed5508ee01f2cea Mon Sep 17 00:00:00 2001 From: Pahan Sarathchandra Date: Wed, 22 May 2024 03:04:34 +0300 Subject: [PATCH] Prevent clicking next page if there is no next page --- src/components/app/posts-table/posts-table.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/app/posts-table/posts-table.tsx b/src/components/app/posts-table/posts-table.tsx index d7f54ab..95ea3b4 100644 --- a/src/components/app/posts-table/posts-table.tsx +++ b/src/components/app/posts-table/posts-table.tsx @@ -30,6 +30,7 @@ import { ActionsCell } from "./actions-cell"; import { type BlogPost } from "@/lib/definitions"; import { cn } from "@/lib/utils"; import { usePathname, useSearchParams } from "next/navigation"; +import { POST_LIST_PAGE_SIZE } from "@/lib/constants"; interface PostsTableProps { posts: BlogPost[]; @@ -70,6 +71,7 @@ export const PostsTable: React.FC = ({ return `${pathname}?${params.toString()}`; }; + const canVisitNext = posts.length === POST_LIST_PAGE_SIZE; return (
@@ -128,7 +130,13 @@ export const PostsTable: React.FC = ({ /> - +