pagination added to product page
This commit is contained in:
@@ -262,7 +262,7 @@ export default function Filter() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* O'lcham filtri */}
|
{/* O'lcham filtri */}
|
||||||
{visibleSectionNumber && visibleSectionNumber.length > 0 && (
|
{/* {visibleSectionNumber && visibleSectionNumber.length > 0 && (
|
||||||
<div className="bg-gray-500 rounded-lg">
|
<div className="bg-gray-500 rounded-lg">
|
||||||
<p className="bg-red-500 text-white p-2 font-semibold font-almarai text-lg rounded-t-lg">
|
<p className="bg-red-500 text-white p-2 font-semibold font-almarai text-lg rounded-t-lg">
|
||||||
O'lcham
|
O'lcham
|
||||||
@@ -297,7 +297,7 @@ export default function Filter() {
|
|||||||
{numberExpanded ? "Yashirish" : "Ko'proq ko'rish"}
|
{numberExpanded ? "Yashirish" : "Ko'proq ko'rish"}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)} */}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,50 +5,71 @@ import { useQuery } from "@tanstack/react-query";
|
|||||||
import ProductCard from "./productCard";
|
import ProductCard from "./productCard";
|
||||||
import { useCategory } from "@/store/useCategory";
|
import { useCategory } from "@/store/useCategory";
|
||||||
import { useFilter } from "@/lib/filter-zustand";
|
import { useFilter } from "@/lib/filter-zustand";
|
||||||
import { useMemo } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { useProductPageInfo } from "@/store/useProduct";
|
import { useProductPageInfo } from "@/store/useProduct";
|
||||||
import { useSubCategory } from "@/store/useSubCategory";
|
import { useSubCategory } from "@/store/useSubCategory";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
|
import PaginationLite from "@/components/paginationUI";
|
||||||
|
|
||||||
export default function MainProduct() {
|
export default function MainProduct() {
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
const category = useCategory((state) => state.category);
|
const category = useCategory((s) => s.category);
|
||||||
const subCategory = useSubCategory((state) => state.subCategory);
|
const subCategory = useSubCategory((s) => s.subCategory);
|
||||||
const filter = useFilter((state) => state.filter);
|
const filter = useFilter((s) => s.filter);
|
||||||
const getFiltersByType = useFilter((state) => state.getFiltersByType);
|
const getFiltersByType = useFilter((s) => s.getFiltersByType);
|
||||||
const setProduct = useProductPageInfo((state) => state.setProducts);
|
const setProduct = useProductPageInfo((s) => s.setProducts);
|
||||||
// Query params yaratish
|
|
||||||
|
const [currentPage, setCurrentPage] = useState(1);
|
||||||
|
|
||||||
const queryParams = useMemo(() => {
|
const queryParams = useMemo(() => {
|
||||||
const catalog = getFiltersByType("catalog");
|
const catalog = getFiltersByType("catalog");
|
||||||
const size = getFiltersByType("size");
|
const size = getFiltersByType("size");
|
||||||
|
const catalogParams = catalog.map((i) => `catalog=${i.id}`).join("&");
|
||||||
// Har bir filter uchun query string yaratish
|
const sizeParams = size.map((i) => `size=${i.id}`).join("&");
|
||||||
const catalogParams = catalog.map((item) => `catalog=${item.id}`).join("&");
|
|
||||||
const sizeParams = size.map((item) => `size=${item.id}`).join("&");
|
|
||||||
|
|
||||||
// Barcha paramslarni birlashtirish for gitea
|
|
||||||
const allParams = [catalogParams, sizeParams].filter(Boolean).join("&");
|
const allParams = [catalogParams, sizeParams].filter(Boolean).join("&");
|
||||||
|
setCurrentPage(1);
|
||||||
return allParams ? `&${allParams}` : "";
|
return allParams ? `&${allParams}` : "";
|
||||||
}, [filter, getFiltersByType]);
|
}, [filter]);
|
||||||
|
|
||||||
// Request link yaratish
|
|
||||||
const requestLink = useMemo(() => {
|
const requestLink = useMemo(() => {
|
||||||
const baseLink = category.have_sub_category
|
const baseLink = category.have_sub_category
|
||||||
? endPoints.product.bySubCategory(subCategory.id)
|
? endPoints.product.bySubCategory({ id: subCategory.id, currentPage })
|
||||||
: endPoints.product.byCategory(category.id || 0);
|
: endPoints.product.byCategory({ id: category.id, currentPage });
|
||||||
|
|
||||||
// Query params qo'shish
|
|
||||||
return `${baseLink}${queryParams}`;
|
return `${baseLink}${queryParams}`;
|
||||||
}, [category.id, category.have_sub_category, queryParams, subCategory.id]);
|
}, [
|
||||||
|
category.id,
|
||||||
|
category.have_sub_category,
|
||||||
|
queryParams,
|
||||||
|
subCategory.id,
|
||||||
|
currentPage,
|
||||||
|
]);
|
||||||
|
|
||||||
const { data, isLoading, error } = useQuery({
|
const { data, isLoading, error } = useQuery({
|
||||||
queryKey: ["products", subCategory.id, queryParams],
|
queryKey: [
|
||||||
|
"products",
|
||||||
|
subCategory.id,
|
||||||
|
category.id,
|
||||||
|
queryParams,
|
||||||
|
currentPage,
|
||||||
|
],
|
||||||
queryFn: () => httpClient(requestLink),
|
queryFn: () => httpClient(requestLink),
|
||||||
select: (data) => data?.data?.data?.results,
|
placeholderData: (prev) => prev, // ✅ pagination da flicker yo'q
|
||||||
|
select: (res) => ({
|
||||||
|
results: res?.data?.data?.results ?? [],
|
||||||
|
totalPages: res?.data?.data?.total_pages ?? 1,
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isLoading) {
|
// ✅ To'g'ridan select dan olamiz — useEffect + let emas
|
||||||
|
const results = useMemo(() => {
|
||||||
|
return data?.results ?? [];
|
||||||
|
}, [data]);
|
||||||
|
const totalPages = useMemo(() => {
|
||||||
|
return data?.totalPages ?? 1;
|
||||||
|
}, [data]);
|
||||||
|
|
||||||
|
if (isLoading && !data) {
|
||||||
|
// ✅ placeholderData bor — faqat birinchi yuklanishda
|
||||||
return (
|
return (
|
||||||
<div className="grid lg:grid-cols-3 sm:grid-cols-2 grid-cols-1 gap-5">
|
<div className="grid lg:grid-cols-3 sm:grid-cols-2 grid-cols-1 gap-5">
|
||||||
{[1, 2, 3].map((i) => (
|
{[1, 2, 3].map((i) => (
|
||||||
@@ -59,10 +80,12 @@ export default function MainProduct() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return <div className="text-center text-red-500 py-10">{t("loadingError")}</div>;
|
return (
|
||||||
|
<div className="text-center text-red-500 py-10">{t("loadingError")}</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data || data.length === 0) {
|
if (!results.length) {
|
||||||
return (
|
return (
|
||||||
<div className="text-center text-gray-400 py-10">
|
<div className="text-center text-gray-400 py-10">
|
||||||
{t("productsNotFound")}
|
{t("productsNotFound")}
|
||||||
@@ -71,16 +94,29 @@ export default function MainProduct() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid lg:grid-cols-3 sm:grid-cols-2 grid-cols-1 gap-5">
|
<div >
|
||||||
{data.map((item: any) => (
|
{/* ✅ isLoading da overlay — list o'rnini saqlab, ustidan opacity */}
|
||||||
<ProductCard
|
<div
|
||||||
key={item.id} // ✅ index o'rniga id ishlatish
|
className={`grid lg:grid-cols-3 sm:grid-cols-2 grid-cols-1 gap-5 transition-opacity ${isLoading ? "opacity-50 pointer-events-none" : "opacity-100"}`}
|
||||||
getProduct={() => setProduct(item)}
|
>
|
||||||
title={item.name}
|
{results.map((item: any) => (
|
||||||
image={item?.images[0]?.image || ""}
|
<ProductCard
|
||||||
slug="special_product"
|
key={item.id}
|
||||||
|
getProduct={() => setProduct(item)}
|
||||||
|
title={item.name}
|
||||||
|
image={item?.images?.[0]?.image || ""}
|
||||||
|
slug="special_product"
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{totalPages > 1 && (
|
||||||
|
<PaginationLite
|
||||||
|
currentPage={currentPage}
|
||||||
|
totalPages={totalPages}
|
||||||
|
onChange={(p) => setCurrentPage(p)}
|
||||||
/>
|
/>
|
||||||
))}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
import { useLocale } from "next-intl";
|
import { useLocale } from "next-intl";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
@@ -18,26 +20,141 @@ export default function ProductCard({
|
|||||||
const locale = useLocale();
|
const locale = useLocale();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link href={`/${locale}/catalog_page/products/${slug}`} onClick={getProduct} className="hover:bg-[#171616] duration-200" >
|
<Link
|
||||||
<article className="group transition-all duration-300 hover:cursor-pointer max-sm:max-w-100 max-sm:mx-auto max-sm:w-full">
|
href={`/${locale}/catalog_page/products/${slug}`}
|
||||||
|
onClick={getProduct}
|
||||||
|
className="group block"
|
||||||
|
>
|
||||||
|
<article className="
|
||||||
|
relative
|
||||||
|
bg-neutral-900
|
||||||
|
border border-zinc-800
|
||||||
|
rounded-xl
|
||||||
|
overflow-hidden
|
||||||
|
transition-all duration-300
|
||||||
|
hover:border-red-600/60
|
||||||
|
hover:shadow-[0_0_24px_0_rgba(220,38,38,0.15)]
|
||||||
|
max-sm:max-w-100 max-sm:mx-auto max-sm:w-full
|
||||||
|
h-95 flex flex-col
|
||||||
|
">
|
||||||
|
|
||||||
|
{/* Top accent line */}
|
||||||
|
<div className="
|
||||||
|
absolute top-0 left-0 right-0 h-0.5
|
||||||
|
bg-linear-to-r from-transparent via-red-600 to-transparent
|
||||||
|
opacity-0 group-hover:opacity-100
|
||||||
|
transition-opacity duration-300
|
||||||
|
z-10
|
||||||
|
" />
|
||||||
|
|
||||||
{/* Image Container */}
|
{/* Image Container */}
|
||||||
<div className="relative rounded-2xl h-45 sm:h-55 md:h-65 lg:w-[95%] w-[90%] mx-auto overflow-hidden">
|
<div className="
|
||||||
|
relative
|
||||||
|
h-48 sm:h-56 md:h-64
|
||||||
|
bg-zinc-900
|
||||||
|
border-b border-zinc-800
|
||||||
|
overflow-hidden
|
||||||
|
">
|
||||||
|
{/* Background pattern */}
|
||||||
|
<div className="
|
||||||
|
absolute inset-0
|
||||||
|
bg-[radial-gradient(circle_at_center,_rgba(39,39,42,0.8)_0%,_rgba(9,9,11,1)_100%)]
|
||||||
|
" />
|
||||||
|
|
||||||
<Image
|
<Image
|
||||||
src={image || "/placeholder.svg"}
|
src={image || "/placeholder.svg"}
|
||||||
alt={title}
|
alt={title}
|
||||||
fill
|
fill
|
||||||
className="object-contain transition-transform duration-300 group-hover:scale-105"
|
className="
|
||||||
|
object-contain
|
||||||
|
p-4
|
||||||
|
transition-transform duration-500
|
||||||
|
group-hover:scale-105
|
||||||
|
drop-shadow-[0_4px_12px_rgba(0,0,0,0.5)]
|
||||||
|
"
|
||||||
sizes="(max-width: 640px) 90vw, (max-width: 1024px) 45vw, 30vw"
|
sizes="(max-width: 640px) 90vw, (max-width: 1024px) 45vw, 30vw"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{/* Hover overlay */}
|
||||||
|
<div className="
|
||||||
|
absolute inset-0
|
||||||
|
bg-red-600/5
|
||||||
|
opacity-0 group-hover:opacity-100
|
||||||
|
transition-opacity duration-300
|
||||||
|
" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Content Container */}
|
{/* Content */}
|
||||||
<div className="p-6 sm:p-4">
|
<div className="p-5">
|
||||||
<h3 className="text-lg text-left font-unbounded font-bold text-white mb-4 line-clamp-3 group-hover:text-red-400 transition-colors duration-300">
|
{/* Decorative line */}
|
||||||
|
<div className="
|
||||||
|
w-8 h-0.5
|
||||||
|
bg-red-600
|
||||||
|
mb-3
|
||||||
|
transition-all duration-300
|
||||||
|
group-hover:w-16
|
||||||
|
" />
|
||||||
|
|
||||||
|
<h3 className="
|
||||||
|
text-sm sm:text-base
|
||||||
|
font-bold
|
||||||
|
text-zinc-100
|
||||||
|
line-clamp-3
|
||||||
|
leading-snug
|
||||||
|
tracking-wide
|
||||||
|
transition-colors duration-300
|
||||||
|
group-hover:text-white
|
||||||
|
">
|
||||||
{title}
|
{title}
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
|
{/* Bottom row */}
|
||||||
|
<div className="
|
||||||
|
flex items-center justify-between
|
||||||
|
mt-4 pt-4
|
||||||
|
border-t border-zinc-800
|
||||||
|
">
|
||||||
|
<span className="
|
||||||
|
text-xs
|
||||||
|
text-zinc-500
|
||||||
|
tracking-widest
|
||||||
|
uppercase
|
||||||
|
font-medium
|
||||||
|
">
|
||||||
|
Batafsil
|
||||||
|
</span>
|
||||||
|
|
||||||
|
{/* Arrow */}
|
||||||
|
<div className="
|
||||||
|
flex items-center justify-center
|
||||||
|
w-7 h-7
|
||||||
|
rounded-full
|
||||||
|
border border-zinc-700
|
||||||
|
text-zinc-500
|
||||||
|
transition-all duration-300
|
||||||
|
group-hover:border-red-600
|
||||||
|
group-hover:text-red-500
|
||||||
|
group-hover:bg-red-600/10
|
||||||
|
">
|
||||||
|
<svg
|
||||||
|
width="12"
|
||||||
|
height="12"
|
||||||
|
viewBox="0 0 12 12"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M2 6H10M10 6L7 3M10 6L7 9"
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeWidth="1.5"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
99
components/paginationUI.tsx
Normal file
99
components/paginationUI.tsx
Normal file
@@ -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 (
|
||||||
|
<Pagination className="w-full flex justify-center items-center mx-auto">
|
||||||
|
<PaginationContent className="w-full px-auto items-center flex justify-center ">
|
||||||
|
{totalPages !== 1 && (
|
||||||
|
<PaginationPrevious
|
||||||
|
className="hover:cursor-pointer text-white hover:text-white"
|
||||||
|
onClick={() => onChange(Math.max(1, currentPage - 1))}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Pages */}
|
||||||
|
{pages.map((p, idx) =>
|
||||||
|
p === "…" ? (
|
||||||
|
<PaginationItem key={idx} className="px-2 text-white">
|
||||||
|
…
|
||||||
|
</PaginationItem>
|
||||||
|
) : (
|
||||||
|
<PaginationItem key={idx}>
|
||||||
|
<PaginationLink
|
||||||
|
className="hover:cursor-pointer text-white hover:text-white"
|
||||||
|
isActive={p === currentPage}
|
||||||
|
onClick={() => onChange(Number(p))}
|
||||||
|
>
|
||||||
|
{p}
|
||||||
|
</PaginationLink>
|
||||||
|
</PaginationItem>
|
||||||
|
),
|
||||||
|
)}
|
||||||
|
{totalPages !== 1 && (
|
||||||
|
<PaginationNext
|
||||||
|
className="hover:cursor-pointer text-white hover:text-white"
|
||||||
|
onClick={() => onChange(Math.min(totalPages, currentPage + 1))}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</PaginationContent>
|
||||||
|
</Pagination>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,20 +1,20 @@
|
|||||||
import * as React from 'react'
|
import * as React from "react"
|
||||||
import {
|
import {
|
||||||
ChevronLeftIcon,
|
ChevronLeftIcon,
|
||||||
ChevronRightIcon,
|
ChevronRightIcon,
|
||||||
MoreHorizontalIcon,
|
MoreHorizontalIcon,
|
||||||
} from 'lucide-react'
|
} from "lucide-react"
|
||||||
|
|
||||||
import { cn } from '@/lib/utils'
|
import { cn } from "@/lib/utils"
|
||||||
import { Button, buttonVariants } from '@/components/ui/button'
|
import { Button, buttonVariants } from "@/components/ui/button"
|
||||||
|
|
||||||
function Pagination({ className, ...props }: React.ComponentProps<'nav'>) {
|
function Pagination({ className, ...props }: React.ComponentProps<"nav">) {
|
||||||
return (
|
return (
|
||||||
<nav
|
<nav
|
||||||
role="navigation"
|
role="navigation"
|
||||||
aria-label="pagination"
|
aria-label="pagination"
|
||||||
data-slot="pagination"
|
data-slot="pagination"
|
||||||
className={cn('mx-auto flex w-full justify-center', className)}
|
className={cn("mx-auto flex w-full justify-center", className)}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
@@ -23,42 +23,42 @@ function Pagination({ className, ...props }: React.ComponentProps<'nav'>) {
|
|||||||
function PaginationContent({
|
function PaginationContent({
|
||||||
className,
|
className,
|
||||||
...props
|
...props
|
||||||
}: React.ComponentProps<'ul'>) {
|
}: React.ComponentProps<"ul">) {
|
||||||
return (
|
return (
|
||||||
<ul
|
<ul
|
||||||
data-slot="pagination-content"
|
data-slot="pagination-content"
|
||||||
className={cn('flex flex-row items-center gap-1', className)}
|
className={cn("flex flex-row items-center gap-1", className)}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function PaginationItem({ ...props }: React.ComponentProps<'li'>) {
|
function PaginationItem({ ...props }: React.ComponentProps<"li">) {
|
||||||
return <li data-slot="pagination-item" {...props} />
|
return <li data-slot="pagination-item" {...props} />
|
||||||
}
|
}
|
||||||
|
|
||||||
type PaginationLinkProps = {
|
type PaginationLinkProps = {
|
||||||
isActive?: boolean
|
isActive?: boolean
|
||||||
} & Pick<React.ComponentProps<typeof Button>, 'size'> &
|
} & Pick<React.ComponentProps<typeof Button>, "size"> &
|
||||||
React.ComponentProps<'a'>
|
React.ComponentProps<"a">
|
||||||
|
|
||||||
function PaginationLink({
|
function PaginationLink({
|
||||||
className,
|
className,
|
||||||
isActive,
|
isActive,
|
||||||
size = 'icon',
|
size = "icon",
|
||||||
...props
|
...props
|
||||||
}: PaginationLinkProps) {
|
}: PaginationLinkProps) {
|
||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
aria-current={isActive ? 'page' : undefined}
|
aria-current={isActive ? "page" : undefined}
|
||||||
data-slot="pagination-link"
|
data-slot="pagination-link"
|
||||||
data-active={isActive}
|
data-active={isActive}
|
||||||
className={cn(
|
className={cn(
|
||||||
buttonVariants({
|
buttonVariants({
|
||||||
variant: isActive ? 'outline' : 'ghost',
|
variant: isActive ? "outline" : "ghost",
|
||||||
size,
|
size,
|
||||||
}),
|
}),
|
||||||
className,
|
className
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
@@ -73,11 +73,10 @@ function PaginationPrevious({
|
|||||||
<PaginationLink
|
<PaginationLink
|
||||||
aria-label="Go to previous page"
|
aria-label="Go to previous page"
|
||||||
size="default"
|
size="default"
|
||||||
className={cn('gap-1 px-2.5 sm:pl-2.5', className)}
|
className={cn("gap-1 px-2.5 sm:pl-2.5", className)}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
<ChevronLeftIcon />
|
<ChevronLeftIcon />
|
||||||
<span className="hidden sm:block">Previous</span>
|
|
||||||
</PaginationLink>
|
</PaginationLink>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -90,10 +89,9 @@ function PaginationNext({
|
|||||||
<PaginationLink
|
<PaginationLink
|
||||||
aria-label="Go to next page"
|
aria-label="Go to next page"
|
||||||
size="default"
|
size="default"
|
||||||
className={cn('gap-1 px-2.5 sm:pr-2.5', className)}
|
className={cn("gap-1 px-2.5 sm:pr-2.5", className)}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
<span className="hidden sm:block">Next</span>
|
|
||||||
<ChevronRightIcon />
|
<ChevronRightIcon />
|
||||||
</PaginationLink>
|
</PaginationLink>
|
||||||
)
|
)
|
||||||
@@ -102,12 +100,12 @@ function PaginationNext({
|
|||||||
function PaginationEllipsis({
|
function PaginationEllipsis({
|
||||||
className,
|
className,
|
||||||
...props
|
...props
|
||||||
}: React.ComponentProps<'span'>) {
|
}: React.ComponentProps<"span">) {
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
aria-hidden
|
aria-hidden
|
||||||
data-slot="pagination-ellipsis"
|
data-slot="pagination-ellipsis"
|
||||||
className={cn('flex size-9 items-center justify-center', className)}
|
className={cn("flex size-9 items-center justify-center", className)}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
<MoreHorizontalIcon className="size-4" />
|
<MoreHorizontalIcon className="size-4" />
|
||||||
@@ -124,4 +122,4 @@ export {
|
|||||||
PaginationPrevious,
|
PaginationPrevious,
|
||||||
PaginationNext,
|
PaginationNext,
|
||||||
PaginationEllipsis,
|
PaginationEllipsis,
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,8 @@
|
|||||||
|
interface ProductTypes {
|
||||||
|
id: number;
|
||||||
|
currentPage: number;
|
||||||
|
}
|
||||||
|
|
||||||
export const endPoints = {
|
export const endPoints = {
|
||||||
category: {
|
category: {
|
||||||
all: "category/",
|
all: "category/",
|
||||||
@@ -10,9 +15,20 @@ export const endPoints = {
|
|||||||
detail: (id: number) => `firesafety/${id}`,
|
detail: (id: number) => `firesafety/${id}`,
|
||||||
},
|
},
|
||||||
product: {
|
product: {
|
||||||
byCategory: (categoryId: number) => `product/?category=${categoryId}`,
|
byCategory: ({ id, currentPage }: ProductTypes) => {
|
||||||
bySubCategory: (subCategoryId: number) =>
|
let link = "product/";
|
||||||
`product/?subCategory=${subCategoryId}`,
|
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}/`,
|
detail: (id: number) => `product/${id}/`,
|
||||||
},
|
},
|
||||||
faq: "faq/",
|
faq: "faq/",
|
||||||
|
|||||||
Reference in New Issue
Block a user