+
+ {/* Background pattern */}
+
+
+
+ {/* Hover overlay */}
+
- {/* Content Container */}
-
-
+ {/* Content */}
+
}
type PaginationLinkProps = {
isActive?: boolean
-} & Pick, 'size'> &
- React.ComponentProps<'a'>
+} & Pick, "size"> &
+ React.ComponentProps<"a">
function PaginationLink({
className,
isActive,
- size = 'icon',
+ size = "icon",
...props
}: PaginationLinkProps) {
return (
@@ -73,11 +73,10 @@ function PaginationPrevious({
- Previous
)
}
@@ -90,10 +89,9 @@ function PaginationNext({
- Next
)
@@ -102,12 +100,12 @@ function PaginationNext({
function PaginationEllipsis({
className,
...props
-}: React.ComponentProps<'span'>) {
+}: React.ComponentProps<"span">) {
return (
@@ -124,4 +122,4 @@ export {
PaginationPrevious,
PaginationNext,
PaginationEllipsis,
-}
+}
\ No newline at end of file
diff --git a/request/links.ts b/request/links.ts
index 3195c9e..a992214 100644
--- a/request/links.ts
+++ b/request/links.ts
@@ -1,3 +1,8 @@
+interface ProductTypes {
+ id: number;
+ currentPage: number;
+}
+
export const endPoints = {
category: {
all: "category/",
@@ -10,9 +15,20 @@ export const endPoints = {
detail: (id: number) => `firesafety/${id}`,
},
product: {
- byCategory: (categoryId: number) => `product/?category=${categoryId}`,
- bySubCategory: (subCategoryId: number) =>
- `product/?subCategory=${subCategoryId}`,
+ byCategory: ({ id, currentPage }: ProductTypes) => {
+ let link = "product/";
+ if (id) link += `?category=${id}`;
+ if (currentPage) link += `&page=${currentPage}`;
+
+ return link;
+ },
+ bySubCategory: ({ id, currentPage }: ProductTypes) => {
+ let link = "product/";
+ if (id) link += `?subCategory=${id}`;
+ if (currentPage) link += `&page=${currentPage}`;
+
+ return link;
+ },
detail: (id: number) => `product/${id}/`,
},
faq: "faq/",
+ {/* Content */}
+
+ {/* Decorative line */}
+
+
+
{title}
+
+ {/* Bottom row */}
+
+
+ Batafsil
+
+
+ {/* Arrow */}
+
+
+
+
);
-}
+}
\ No newline at end of file
diff --git a/components/paginationUI.tsx b/components/paginationUI.tsx
new file mode 100644
index 0000000..29d1bd3
--- /dev/null
+++ b/components/paginationUI.tsx
@@ -0,0 +1,99 @@
+"use client";
+
+import {
+ Pagination,
+ PaginationContent,
+ PaginationItem,
+ PaginationLink,
+ PaginationNext,
+ PaginationPrevious,
+} from "@/components/ui/pagination";
+
+type Props = {
+ currentPage: number;
+ totalPages: number;
+ onChange: (page: number) => void;
+};
+
+export default function PaginationLite({
+ currentPage,
+ totalPages,
+ onChange,
+}: Props) {
+ const getPages = () => {
+ const visibleCount = 7; // maximum number of items to show (including ellipses)
+ const pages: (number | string)[] = [];
+
+ // If total pages are within visible limit, show all
+ if (totalPages <= visibleCount) {
+ for (let i = 1; i <= totalPages; i++) pages.push(i);
+ return pages;
+ }
+
+ // If current page is near the beginning: show 1..5, ellipsis, last
+ if (currentPage <= 4) {
+ for (let i = 1; i <= 5; i++) pages.push(i);
+ pages.push("…", totalPages);
+ return pages;
+ }
+
+ // If current page is near the end: show first, ellipsis, last-4..last
+ if (currentPage >= totalPages - 3) {
+ pages.push(1, "…");
+ for (let i = totalPages - 4; i <= totalPages; i++) pages.push(i);
+ return pages;
+ }
+
+ // Middle case: first, ellipsis, current-1, current, current+1, ellipsis, last
+ pages.push(
+ 1,
+ "…",
+ currentPage - 1,
+ currentPage,
+ currentPage + 1,
+ "…",
+ totalPages,
+ );
+ return pages;
+ };
+
+ const pages = getPages();
+
+ return (
+
+
+ {totalPages !== 1 && (
+ onChange(Math.max(1, currentPage - 1))}
+ />
+ )}
+
+ {/* Pages */}
+ {pages.map((p, idx) =>
+ p === "…" ? (
+
+ …
+
+ ) : (
+
+ onChange(Number(p))}
+ >
+ {p}
+
+
+ ),
+ )}
+ {totalPages !== 1 && (
+ onChange(Math.min(totalPages, currentPage + 1))}
+ />
+ )}
+
+
+ );
+}
diff --git a/components/ui/pagination.tsx b/components/ui/pagination.tsx
index ce8f25d..d6ee8d6 100644
--- a/components/ui/pagination.tsx
+++ b/components/ui/pagination.tsx
@@ -1,20 +1,20 @@
-import * as React from 'react'
+import * as React from "react"
import {
ChevronLeftIcon,
ChevronRightIcon,
MoreHorizontalIcon,
-} from 'lucide-react'
+} from "lucide-react"
-import { cn } from '@/lib/utils'
-import { Button, buttonVariants } from '@/components/ui/button'
+import { cn } from "@/lib/utils"
+import { Button, buttonVariants } from "@/components/ui/button"
-function Pagination({ className, ...props }: React.ComponentProps<'nav'>) {
+function Pagination({ className, ...props }: React.ComponentProps<"nav">) {
return (
)
@@ -23,42 +23,42 @@ function Pagination({ className, ...props }: React.ComponentProps<'nav'>) {
function PaginationContent({
className,
...props
-}: React.ComponentProps<'ul'>) {
+}: React.ComponentProps<"ul">) {
return (
)
}
-function PaginationItem({ ...props }: React.ComponentProps<'li'>) {
+function PaginationItem({ ...props }: React.ComponentProps<"li">) {
return
}
type PaginationLinkProps = {
isActive?: boolean
-} & Pick{title}
+ + {/* Bottom row */} +
+
+ Batafsil
+
+
+ {/* Arrow */}
+
+
+
+