Skip to content

Commit 1334e8f

Browse files
fix: add conditional rendering to render pagination only when totalPages > 1.
1 parent cfb0922 commit 1334e8f

1 file changed

Lines changed: 21 additions & 19 deletions

File tree

src/components/CatalogueContent.tsx

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -487,27 +487,29 @@ const CatalogueContent = () => {
487487
))
488488
)}
489489
</div>
490-
<div className="mt-8 flex items-center justify-center gap-4">
491-
<Button
492-
variant="outline"
493-
disabled={currentPage === 1}
494-
onClick={() => setCurrentPage((prev) => prev - 1)}
495-
>
496-
Previous
497-
</Button>
490+
{totalPages > 1 && (
491+
<div className="mt-8 flex items-center justify-center gap-4">
492+
<Button
493+
variant="outline"
494+
disabled={currentPage === 1}
495+
onClick={() => setCurrentPage((prev) => prev - 1)}
496+
>
497+
Previous
498+
</Button>
498499

499-
<span className="text-gray-700 dark:text-gray-300">
500-
Page {currentPage} of {totalPages}
501-
</span>
500+
<span className="text-gray-700 dark:text-gray-300">
501+
Page {currentPage} of {totalPages}
502+
</span>
502503

503-
<Button
504-
variant="outline"
505-
disabled={currentPage === totalPages}
506-
onClick={() => setCurrentPage((prev) => prev + 1)}
507-
>
508-
Next
509-
</Button>
510-
</div>
504+
<Button
505+
variant="outline"
506+
disabled={currentPage === totalPages}
507+
onClick={() => setCurrentPage((prev) => prev + 1)}
508+
>
509+
Next
510+
</Button>
511+
</div>
512+
)}
511513
</div>
512514
) : (
513515
<Error

0 commit comments

Comments
 (0)