diff --git a/src/components/sections/BestsellersGridSection.tsx b/src/components/sections/BestsellersGridSection.tsx new file mode 100644 index 0000000..2a8a9e8 --- /dev/null +++ b/src/components/sections/BestsellersGridSection.tsx @@ -0,0 +1,73 @@ +'use client'; +import { useMedusaProducts } from '@/hooks/useMedusaProducts'; +import Image from 'next/image'; +import Link from 'next/link'; +import Button from '@/components/ui/Button'; +import { Card, CardHeader, CardTitle, CardContent, CardFooter } from '@/components/ui/Card'; +import Badge from '@/components/ui/Badge'; +import { TrendingUp } from 'lucide-react'; + +const CURRENCY_SYMBOLS: Record = { zar: 'R', usd: '$', eur: '€', gbp: '£' }; +const formatPrice = (amount: number, code?: string) => { + const sym = CURRENCY_SYMBOLS[(code ?? '').toLowerCase()] ?? (code?.toUpperCase() ?? ''); + return `${sym}${(amount / 100).toFixed(2)}`; +}; + +export default function BestsellersGridSection() { + const { products, isLoading } = useMedusaProducts(6); + + if (isLoading) { + return ( +
+
+
+ ); + } + if (!products || products.length === 0) return null; + + return ( +
+
+

Top Picks Loved by Our Community

+

Real results, trusted by thousands across South Africa.

+
+ {products.map((product) => { + const price = product.variants?.[0]?.prices?.[0]; + return ( + +
+ {product.title} + + Bestseller + +
+ + {product.title} + + + {price && ( +

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

+ )} +

Deep hydration & gentle care

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