From ac3b1281796ee98ff838cc085ec73a226c9fb5f3 Mon Sep 17 00:00:00 2001 From: Vula Builder Date: Tue, 28 Jul 2026 07:32:30 +0000 Subject: [PATCH] Deploy --- .../BestsellingBotanicalsGridSection.tsx | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 src/components/sections/BestsellingBotanicalsGridSection.tsx diff --git a/src/components/sections/BestsellingBotanicalsGridSection.tsx b/src/components/sections/BestsellingBotanicalsGridSection.tsx new file mode 100644 index 0000000..9b1ca2f --- /dev/null +++ b/src/components/sections/BestsellingBotanicalsGridSection.tsx @@ -0,0 +1,86 @@ +'use client' + +import { useMedusaProducts } from '@/hooks/useMedusaProducts' +import { useMedusaCart } from '@/hooks/useMedusaCart' +import { Card, CardContent, CardFooter } 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' + +const formatPrice = (amount: number, code?: string) => { + const sym: Record = { zar: 'R', usd: '$', eur: '€', gbp: '£' } + const s = sym[(code || '').toLowerCase()] || (code || '').toUpperCase() + return `${s}${(amount / 100).toFixed(2)}` +} + +export default function BestsellingBotanicalsGridSection() { + const { products, isLoading, error } = useMedusaProducts(6) + const { addToCart } = useMedusaCart() + + if (isLoading) return
+ if (error) return null + if (!products || products.length === 0) return null + + const handleAddToCart = (variantId: string) => { + addToCart(variantId, 1) + window.dispatchEvent(new CustomEvent('cart-drawer-open')) + } + + return ( +
+
+
+

Bestselling Botanicals

+

South Africa's favourite natural skincare picks – restocked weekly.

+
+
+ {products.slice(0, 6).map((product, index) => { + const variant = product.variants?.[0] + const price = variant?.prices?.[0] + const isTopSeller = index < 2 + return ( + + +
+ {product.thumbnail ? ( + {product.title} + ) : ( +
+ +
+ )} + {isTopSeller && ( + + #{index + 1} Best Seller + + )} +
+ + +

{product.title}

+ {price && ( +

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

+ )} +
+ + + +
+ ) + })} +
+
+
+ ) +} \ No newline at end of file