diff --git a/src/components/sections/OffersSection.tsx b/src/components/sections/OffersSection.tsx new file mode 100644 index 0000000..9f09181 --- /dev/null +++ b/src/components/sections/OffersSection.tsx @@ -0,0 +1,67 @@ +'use client' + +import Image from 'next/image' +import Badge from '@/components/ui/Badge' +import { useEmDashContent } from '@/hooks/useEmDashContent' + +const CURRENCY_SYMBOLS: Record = { zar: 'R', usd: '$', eur: '€', gbp: '£', kes: 'KSh', ngn: '₦', ghs: '₵' } + +function formatPrice(amount: number, code?: string) { + const sym = CURRENCY_SYMBOLS[(code ?? '').toLowerCase()] ?? (code?.toUpperCase() ?? '') + return `${sym}${(amount / 100).toFixed(2)}` +} + +export default function OffersSection() { + const { items, loading } = useEmDashContent('offers') + + if (loading) return ( +
+
+
+
+
+ ) + + if (items.length === 0) return null + + return ( +
+
+

Limited-Time Offers

+
+ {items.map((item) => { + const d = item.data as { title?: string; description?: string; price?: number; duration?: string; valid_until?: string; image?: string } + const priceValue = d.price ?? 0 + const formatted = formatPrice(priceValue, 'zar') + return ( +
+ {d.image && ( +
+ {d.title +
+ )} +
+

{d.title}

+

{d.description}

+
+ {formatted} + {d.duration && {d.duration}} +
+ {d.valid_until && ( +

Valid until {new Date(d.valid_until).toLocaleDateString()}

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