30 lines
963 B
TypeScript
30 lines
963 B
TypeScript
// app/products/page.tsx
|
||
import { getProducts } from '@/public/src/services/products/api';
|
||
import ProductGrid from '@/components/clientProduct';
|
||
|
||
export default async function ProductsPage() {
|
||
// گرفتن تمام محصولات در سرور (چون بکاند شما لیمیت را نادیده میگیرد، همه را دریافت میکنیم)
|
||
const data = await getProducts(1, 100);
|
||
|
||
const products = data.items?.map((p: any) => ({
|
||
id: p.id,
|
||
title: p.title,
|
||
brand: p.brand,
|
||
price: p.calculated_price,
|
||
stock: p.stock,
|
||
slug: p.slug,
|
||
image: p.mainImageUrl || "/src/img/1.jpg",
|
||
attributes: p.attributes
|
||
})) || [];
|
||
|
||
return (
|
||
<div className="container mx-auto px-4 max-w-6xl py-8">
|
||
<h1 className="text-2xl font-bold mb-6">همه محصولات</h1>
|
||
|
||
{/* پاس دادن کل محصولات به کامپوننت کلاینت */}
|
||
<ProductGrid products={products} />
|
||
</div>
|
||
);
|
||
}
|
||
|