import Link from "next/link"; import { cookies } from "next/headers"; const API_URL = process.env.NEXT_PUBLIC_API_URL || "http://localhost:8000/api"; interface Product { slug: string; name: string; description: string; category: string; product_type: string; image_url: string; base_price: number; } // Map product types to mockup types function getMockupType(productType: string): string { if (productType.includes("shirt") || productType.includes("tee") || productType.includes("hoodie")) return "shirt"; if (productType.includes("sticker")) return "sticker"; if (productType.includes("print")) return "print"; return "shirt"; } async function getProducts(spaceId: string): Promise { try { const params = new URLSearchParams(); if (spaceId && spaceId !== "default") { params.set("space", spaceId); } const url = `${API_URL}/products${params.toString() ? `?${params}` : ""}`; const res = await fetch(url, { next: { revalidate: 3600 } }); if (!res.ok) return []; return res.json(); } catch { return []; } } export default async function ProductsPage() { const cookieStore = await cookies(); const spaceId = cookieStore.get("space_id")?.value || "default"; const products = await getProducts(spaceId); return (

Products

{products.length === 0 ? (

No products available yet. Check back soon!

) : (
{products.map((product) => (
{product.name}

{product.name}

{product.product_type}

${product.base_price.toFixed(2)}

))}
)}
); }