diff --git a/src/components/sections/KasiSelectSection.tsx b/src/components/sections/KasiSelectSection.tsx new file mode 100644 index 0000000..6498062 --- /dev/null +++ b/src/components/sections/KasiSelectSection.tsx @@ -0,0 +1,89 @@ +'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 Image from 'next/image' +import Link from 'next/link' + +const formatPrice = (amount: number, code?: string) => { + const sym: Record = { + zar: 'R', usd: '$', eur: '€', gbp: '£', + kes: 'KSh', ngn: '₦', ghs: '₵', + } + const s = sym[(code ?? '').toLowerCase()] ?? (code?.toUpperCase() ?? '') + return `${s}${(amount / 100).toFixed(2)}` +} + +export default function KasiSelectSection() { + const { products, isLoading } = useMedusaProducts(8) + const { addToCart } = useMedusaCart() + + if (isLoading) return ( +
+
+
+ ) + if (products.length === 0) return null + + const handleAdd = (variantId: string) => { + addToCart(variantId, 1) + window.dispatchEvent(new CustomEvent('cart-drawer-open')) + } + + return ( +
+
+
+

+ Kasi Select +

+

+ 8 hand-picked limited-edition pieces — each piece iyi-story. +

+
+ +
+ {products.slice(0, 8).map((p) => { + const price = p.variants?.[0]?.prices?.[0] + return ( + + +
+ {p.title} +
+ +

{p.title}

+ {price && ( +

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

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