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>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import type { Metadata } from 'next'
|
||||
import { ProductList10Catalog } from '@/components/sections/feature/product-list10-catalog'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "محصولات",
|
||||
description:
|
||||
"محصولات مستر دکور شامل استند و ملزومات دکور ویترین طلافروشی در دسته های طلا، خردسال، جواهر و مانکن های تخصصی.",
|
||||
}
|
||||
|
||||
type ProductSearchParams =
|
||||
| { category?: string | string[] }
|
||||
| Promise<{ category?: string | string[] }>
|
||||
|
||||
export default async function ProductsPage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams?: ProductSearchParams
|
||||
}) {
|
||||
const resolvedSearchParams =
|
||||
searchParams && typeof (searchParams as Promise<{ category?: string | string[] }>).then === 'function'
|
||||
? await (searchParams as Promise<{ category?: string | string[] }>)
|
||||
: (searchParams as { category?: string | string[] } | undefined)
|
||||
|
||||
const rawCategory = resolvedSearchParams?.category
|
||||
const initialCategory = Array.isArray(rawCategory) ? rawCategory[0] : rawCategory
|
||||
|
||||
return (
|
||||
<main className="min-h-screen">
|
||||
<ProductList10Catalog initialCategory={initialCategory} />
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user