first project version mrDecor
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import type { Metadata } from "next";
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
import { ProductDetailView } from "@/components/sections/feature/product-detail-view";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { getAllProductIds, getProductById, getProductDetail } from "@/lib/catalog-products";
|
||||
|
||||
type PageParams = { productId: string };
|
||||
|
||||
export function generateStaticParams(): PageParams[] {
|
||||
return getAllProductIds().map((productId) => ({ productId }));
|
||||
}
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<PageParams>;
|
||||
}): Promise<Metadata> {
|
||||
const { productId } = await params;
|
||||
const product = getProductById(productId);
|
||||
if (!product) {
|
||||
return { title: "محصول" };
|
||||
}
|
||||
return {
|
||||
title: product.name,
|
||||
description: `${product.name} — ${product.categoryLabel} | مستر دکور`,
|
||||
};
|
||||
}
|
||||
|
||||
export default async function ProductDetailPage({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<PageParams>;
|
||||
}) {
|
||||
const { productId } = await params;
|
||||
const detail = getProductDetail(productId);
|
||||
if (!detail) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="min-h-screen pb-16">
|
||||
<div className="border-b border-border bg-muted/40" dir="rtl">
|
||||
<div className="mx-auto flex max-w-7xl flex-wrap items-center justify-between gap-3 px-4 py-3 sm:px-6">
|
||||
<Button variant="ghost" className="text-body-sm text-gold-300 hover:bg-gold-950/35 hover:text-gold-200" asChild>
|
||||
<Link href={`/product?category=${detail.category}`}>بازگشت به فهرست {detail.categoryLabel}</Link>
|
||||
</Button>
|
||||
<Button variant="ghost" className="text-body-sm text-gold-300 hover:bg-gold-950/35 hover:text-gold-200" asChild>
|
||||
<Link href="/product">همه محصولات</Link>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<ProductDetailView product={detail} />
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user