From fc233a923a9f86092fa25d20078a03cc098077f6 Mon Sep 17 00:00:00 2001 From: Vula Builder Date: Tue, 28 Jul 2026 12:39:43 +0000 Subject: [PATCH] Deploy --- .../sections/BestsellersGridSection.tsx | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/components/sections/BestsellersGridSection.tsx diff --git a/src/components/sections/BestsellersGridSection.tsx b/src/components/sections/BestsellersGridSection.tsx new file mode 100644 index 0000000..310e4b3 --- /dev/null +++ b/src/components/sections/BestsellersGridSection.tsx @@ -0,0 +1,74 @@ +'use client' +import { useMedusaProducts } from '@/hooks/useMedusaProducts' +import { useMedusaCart } from '@/hooks/useMedusaCart' +import { Card, CardContent, CardFooter, CardHeader, CardTitle } from '@/components/ui/Card' +import Button from '@/components/ui/Button' +import Badge from '@/components/ui/Badge' +import Image from 'next/image' +import Link from 'next/link' +import { ShoppingBag, Zap } from 'lucide-react' + +export default function BestsellersGridSection() { + const { products, isLoading } = useMedusaProducts(4) + const { addToCart } = useMedusaCart() + + const formatPrice = (amount: number, code?: string) => { + const symbols: Record = { zar: 'R', usd: '$', eur: '€', gbp: '£', kes: 'KSh', ngn: '₦', ghs: '₵' } + const sym = symbols[(code ?? '').toLowerCase()] ?? (code?.toUpperCase() ?? '') + return `${sym}${(amount / 100).toFixed(2)}` + } + + if (isLoading) return
+ if (!products || products.length === 0) return null + + const handleAddToCart = (variantId: string) => { + addToCart(variantId, 1) + window.dispatchEvent(new CustomEvent('cart-drawer-open')) + } + + return ( +
+
+
+

Amandla Popular

+

Bestsellers

+

Our community's most-loved rituals – tried, tested, and adored across South Africa.

+
+
+ {products.slice(0, 4).map((product) => { + const variant = product.variants?.[0] + const price = variant?.prices?.[0] + const imgSrc = product.thumbnail || '/placeholder-product.svg' + return ( + +
+ + {product.title} + + + Bestseller + +
+ + +

{product.title}

+ + {price && ( +

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

+ )} +
+ + {variant && ( + + )} + +
+ ) + })} +
+
+
+ ) +} \ No newline at end of file