diff --git a/frontend/app/page.tsx b/frontend/app/page.tsx index b9edb5f..ae65b55 100644 --- a/frontend/app/page.tsx +++ b/frontend/app/page.tsx @@ -1,6 +1,31 @@ import Link from "next/link"; -export default function HomePage() { +interface Product { + slug: string; + name: string; + description: string; + category: string; + product_type: string; + image_url: string; + base_price: number; +} + +async function getProducts(): Promise { + try { + const res = await fetch( + `${process.env.NEXT_PUBLIC_API_URL || "http://localhost:8000/api"}/products`, + { next: { revalidate: 60 } } // Revalidate every minute + ); + if (!res.ok) return []; + return res.json(); + } catch { + return []; + } +} + +export default async function HomePage() { + const products = await getProducts(); + return (
@@ -18,24 +43,49 @@ export default function HomePage() { > Browse Products + + Design Your Own +
-

Featured

-
-
-
- Coming Soon -
-
-

Build Tools Not Empires

-

Sticker

-

$3.50

-
+

Featured 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)}

+
+
+ + ))}
- {/* More products will be loaded from API */} -
+ )}
);