From 593387a672a06f471154fbdbf4d635ecdc0e9ee5 Mon Sep 17 00:00:00 2001 From: Vula Builder Date: Tue, 23 Jun 2026 08:39:11 +0000 Subject: [PATCH] Deploy --- src/components/sections/SpecialsSection.tsx | 62 +++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/components/sections/SpecialsSection.tsx diff --git a/src/components/sections/SpecialsSection.tsx b/src/components/sections/SpecialsSection.tsx new file mode 100644 index 0000000..b71ef1a --- /dev/null +++ b/src/components/sections/SpecialsSection.tsx @@ -0,0 +1,62 @@ +'use client' + +import { useEmDashContent } from '@/hooks/useEmDashContent' +import Image from 'next/image' +import { Clock, Tag } 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)}` +} + +export default function SpecialsSection() { + const { items, loading } = useEmDashContent('specials') + + if (loading) return
+ if (items.length === 0) return null + + const now = new Date() + + return ( +
+
+

Student Steals & Bundles

+

Premium gear without breaking the stash.

+
+ {items.map((item) => { + const d = item.data as { title?: string; description?: string; price?: number; available_until?: string; image?: string } + const isExpired = d.available_until ? new Date(d.available_until) < now : false + return ( +
+ {d.image && ( +
+ {d.title +
+ )} +
+
+ + Special + + {isExpired && Expired} +
+

{d.title}

+ {d.description &&

{d.description}

} + {d.price !== undefined && ( +

{formatPrice(d.price, 'zar')}

+ )} + {d.available_until && !isExpired && ( +

+ Until {new Date(d.available_until).toLocaleDateString("en-ZA", { day: "numeric", month: 'short' })} +

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