-
- EN
-
-
|
-
- FA
-
+
+ {languages.map((language) => (
+
changeLocale(language.locale as TLocales)}
+ key={language.title}
+ >
+
+
+ {language.title}
+
+
+ ))}
);
}
diff --git a/src/components/layout/navbar/index.tsx b/src/components/layout/navbar/index.tsx
index 86628d4..186b6f4 100644
--- a/src/components/layout/navbar/index.tsx
+++ b/src/components/layout/navbar/index.tsx
@@ -11,7 +11,7 @@ import { useTranslations } from 'next-intl';
import routeFactory from '@/assets/constants/routeFactory';
export default function Navbar() {
- const [open, setOpen] = useState(false);
+ const [open, setOpen] = useState
(false);
const pathname = usePathname();
const params = useParams();
const locale = params.locale as string;
diff --git a/src/components/layout/pagination/index.tsx b/src/components/layout/pagination/index.tsx
new file mode 100644
index 0000000..47518db
--- /dev/null
+++ b/src/components/layout/pagination/index.tsx
@@ -0,0 +1,55 @@
+'use client';
+
+import Button, { IconButton } from '@/components/uikit/button';
+import React from 'react';
+
+interface PaginationProps {
+ page: number;
+ totalPages: number;
+ onPageChange?: (page: number) => void;
+ className?: string;
+}
+
+export default function Pagination({
+ page,
+ totalPages,
+ onPageChange = () => {},
+ className,
+}: PaginationProps) {
+ if (totalPages <= 1) return null;
+
+ const pages = [];
+ for (let i = 1; i <= totalPages; i++) {
+ pages.push(i);
+ }
+
+ return (
+
+ );
+}
diff --git a/src/components/pages/products/productList/index.tsx b/src/components/pages/products/productList/index.tsx
new file mode 100644
index 0000000..29de78c
--- /dev/null
+++ b/src/components/pages/products/productList/index.tsx
@@ -0,0 +1,38 @@
+'use client';
+
+import { useState } from 'react';
+import ProductCard from '../ProductCard';
+import Pagination from '@/components/layout/pagination';
+import { getProducts } from '@/services/products';
+import { IProductListProps } from './productList';
+
+export default function ProductList({
+ initialProducts,
+ initialPagination,
+ categoryId,
+}: IProductListProps) {
+ const [products, setProducts] = useState(initialProducts);
+ const [pagination, setPagination] = useState(initialPagination);
+
+ const fetchPage = (page: number) => {
+ getProducts(categoryId, page)
+ .then((res) => {
+ setProducts(res.data);
+ setPagination(res.pagination);
+ })
+ .catch((error) => {
+ console.error('Failed to fetch products:', error);
+ });
+ };
+
+ return (
+ <>
+
+ {products.map((product, index) => (
+
+ ))}
+
+
+ >
+ );
+}
diff --git a/src/components/pages/products/productList/productList.d.ts b/src/components/pages/products/productList/productList.d.ts
new file mode 100644
index 0000000..2916fa8
--- /dev/null
+++ b/src/components/pages/products/productList/productList.d.ts
@@ -0,0 +1,8 @@
+import { IPagination } from '@/models/response';
+import { IProductCardProps } from '../productCard';
+
+export interface IProductListProps {
+ initialProducts: IProductCardProps[];
+ initialPagination: IPagination;
+ categoryId: string;
+}
diff --git a/src/components/uikit/button/button.d.ts b/src/components/uikit/button/button.d.ts
index 940c1d5..9b7dcc4 100644
--- a/src/components/uikit/button/button.d.ts
+++ b/src/components/uikit/button/button.d.ts
@@ -8,6 +8,7 @@ export interface IBaseButtonProps
disabled?: boolean;
className?: string;
link?: URL | string;
+ onClick?: () => void;
}
export interface ITextButtonProps extends IBaseButtonProps {
diff --git a/src/components/uikit/button/index.tsx b/src/components/uikit/button/index.tsx
index 0b762b1..1cd5db2 100644
--- a/src/components/uikit/button/index.tsx
+++ b/src/components/uikit/button/index.tsx
@@ -11,6 +11,7 @@ const Button: React.FC = ({
endIcon,
className,
link,
+ onClick,
...props
}) => {
const wrapperClass = `group bg-primary relative h-12 cursor-pointer rounded-[0.5625rem] p-[0.125rem] flex w-fit ${className || ''}`;
@@ -22,7 +23,12 @@ const Button: React.FC = ({
) : (
-