Files
parsshop/app/products/page.tsx
2026-04-07 10:14:56 +03:30

30 lines
963 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 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>
);
}