This commit is contained in:
Vula Builder
2026-06-23 08:39:11 +00:00
parent 3b2dfaa8c1
commit 593387a672
@@ -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<string, string> = { 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 <div className="flex justify-center py-16"><div className="w-8 h-8 rounded-full border-2 border-current border-t-transparent animate-spin" /></div>
if (items.length === 0) return null
const now = new Date()
return (
<section id="specials" data-vula-section="specials" data-vula-cms="specials" className="bg-[#1a1a2e] py-20 px-6">
<div className="max-w-6xl mx-auto">
<h2 className="text-3xl lg:text-4xl font-bold text-[#F5F5F5] mb-4">Student Steals &amp; Bundles</h2>
<p className="text-[#F5F5F5]/70 mb-12 max-w-2xl">Premium gear without breaking the stash.</p>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{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 (
<div key={item.id} className="rounded-xl overflow-hidden bg-white shadow-md hover:shadow-[var(--shadow-lifted)] hover:-translate-y-0.5 transition-all duration-200 ease-out relative">
{d.image && (
<div className="relative h-48 w-full">
<Image src={d.image} alt={d.title ?? ''} fill className="object-cover" sizes="(max-width: 768px) 100vw, 50vw" />
</div>
)}
<div className="p-5">
<div className="flex items-center gap-2 mb-2">
<span className="inline-flex items-center gap-1 bg-[#FFB74D] text-gray-900 text-xs font-semibold px-2 py-0.5 rounded-full">
<Tag className="w-3 h-3" /> Special
</span>
{isExpired && <span className="text-xs text-gray-500 line-through">Expired</span>}
</div>
<h3 className="text-lg font-semibold text-gray-900 mb-1">{d.title}</h3>
{d.description && <p className="text-sm text-gray-600 mb-3 line-clamp-2">{d.description}</p>}
{d.price !== undefined && (
<p className="text-2xl font-bold text-[#4A9EFF]">{formatPrice(d.price, 'zar')}</p>
)}
{d.available_until && !isExpired && (
<p className="text-xs text-gray-400 mt-2 flex items-center gap-1">
<Clock className="w-3 h-3" /> Until {new Date(d.available_until).toLocaleDateString("en-ZA", { day: "numeric", month: 'short' })}
</p>
)}
</div>
</div>
)
})}
</div>
</div>
</section>
)
}