27 lines
888 B
TypeScript
27 lines
888 B
TypeScript
import type { Metadata } from "next";
|
|
import { CatalogClient } from "@/components/catalog/catalog-client";
|
|
import { getProducts } from "@/lib/headless/client";
|
|
|
|
export const metadata: Metadata = { title: "Catálogo", description: "Explora todos los productos de Ari Shopping." };
|
|
|
|
type CatalogPageProps = {
|
|
searchParams: Promise<Record<string, string | string[] | undefined>>;
|
|
};
|
|
|
|
function single(value: string | string[] | undefined): string {
|
|
return Array.isArray(value) ? value[0] ?? "" : value ?? "";
|
|
}
|
|
|
|
export default async function CatalogPage({ searchParams }: CatalogPageProps) {
|
|
const params = await searchParams;
|
|
const products = await getProducts();
|
|
return (
|
|
<CatalogClient
|
|
products={products}
|
|
initialCategory={single(params.category) || "Todos"}
|
|
initialCollection={single(params.collection)}
|
|
initialQuery={single(params.q)}
|
|
/>
|
|
);
|
|
}
|