From bae86947617eb0b9c24576c78f2d96dbbf45022a Mon Sep 17 00:00:00 2001 From: Vula Builder Date: Mon, 27 Jul 2026 17:10:22 +0000 Subject: [PATCH] Deploy --- .../sections/FeaturedProductsSection.tsx | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 src/components/sections/FeaturedProductsSection.tsx diff --git a/src/components/sections/FeaturedProductsSection.tsx b/src/components/sections/FeaturedProductsSection.tsx new file mode 100644 index 0000000..c8fe6ee --- /dev/null +++ b/src/components/sections/FeaturedProductsSection.tsx @@ -0,0 +1,82 @@ +'use client' +import { useFeaturedProducts } from '@/hooks/useFeaturedProducts' +import Link from 'next/link' +import { ShoppingBag } from 'lucide-react' +import { useMedusaCart } from '@/hooks/useMedusaCart' + +const CURRENCY_SYMBOLS: Record = { zar: 'R', usd: '$', eur: '€', gbp: '£', kes: 'KSh', ngn: '₦', ghs: '₵' } +const fmt = (amount: number, code?: string) => { + const sym = CURRENCY_SYMBOLS[(code ?? '').toLowerCase()] ?? (code?.toUpperCase() ?? '') + return `${sym}${(amount / 100).toFixed(2)}` +} + +export default function FeaturedProductsSection() { + const { products, isLoading } = useFeaturedProducts(8) + const { addToCart } = useMedusaCart() + + if (isLoading) { + return ( +
+
+
+ {Array.from({ length: 8 }).map((_, i) => ( +
+ ))} +
+
+
+ ) + } + + if (!products.length) return null + + return ( +
+
+
+
+

Curated for You

+

Featured Products

+
+ View all → +
+
+ {products.map((product) => { + const variant = product.variants?.[0] + const price = variant?.prices?.[0] + return ( +
+ +
+ {product.thumbnail ? ( + {product.title + ) : ( +
+ +
+ )} +
+ +
+ +

{product.title}

+ + {price && ( +

{fmt(price.amount, price.currency_code)}

+ )} + +
+
+ ) + })} +
+
+
+ ) +}