From cec6784eb6b12760af50697de2f9621a68e7f104 Mon Sep 17 00:00:00 2001 From: Vula Builder Date: Sat, 1 Aug 2026 16:26:33 +0000 Subject: [PATCH] Deploy --- .../sections/FreshKasiDropsSection.tsx | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 src/components/sections/FreshKasiDropsSection.tsx diff --git a/src/components/sections/FreshKasiDropsSection.tsx b/src/components/sections/FreshKasiDropsSection.tsx new file mode 100644 index 0000000..016242b --- /dev/null +++ b/src/components/sections/FreshKasiDropsSection.tsx @@ -0,0 +1,116 @@ +'use client' + +import { useMedusaProducts, MedusaProduct } from '@/hooks/useMedusaProducts' +import { useMedusaCart } from '@/hooks/useMedusaCart' +import Button from '@/components/ui/Button' +import Badge from '@/components/ui/Badge' +import { Card, CardContent } from '@/components/ui/Card' +import Image from 'next/image' +import Link from 'next/link' +import { Eye, ShoppingBag } from 'lucide-react' + +const CURRENCY_SYMBOLS: Record = { zar: 'R', usd: '$', eur: '€', gbp: '£', kes: 'KSh', ngn: '₦', ghs: '₵' } +const formatPrice = (amount: number, code?: string) => { + const sym = CURRENCY_SYMBOLS[(code ?? '').toLowerCase()] ?? (code?.toUpperCase() ?? '') + return `${sym}${(amount / 100).toFixed(2)}` +} + +function ProductCard({ product }: { product: MedusaProduct }) { + const { addToCart } = useMedusaCart() + const variant = product.variants?.[0] + const price = variant?.prices?.[0] + const isLimited = Math.random() > 0.7 + + const handleAddToCart = () => { + if (!variant) return + addToCart(variant.id, 1) + window.dispatchEvent(new CustomEvent('cart-drawer-open')) + } + + return ( + + +
+ {product.thumbnail ? ( + {product.title} + ) : ( +
+ +
+ )} +
+ +
+ {isLimited && ( + + Limited stock + + )} +
+ + +

+ {product.title} +

+ {price && ( +

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

+ )} + +
+
+ ) +} + +export default function FreshKasiDropsSection() { + const { products, isLoading } = useMedusaProducts(12) + if (isLoading) { + return ( +
+
+
+ ) + } + if (products.length === 0) return null + + return ( +
+
+
+ + Fresh off the press + +

+ Fresh Kasi Drops +

+
+
+ {products.map((product) => ( + + ))} +
+
+
+ ) +}