Deploy
This commit is contained in:
@@ -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<string, string> = { 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 (
|
||||
<section className="bg-white py-20">
|
||||
<div className="flex justify-center">
|
||||
<div className="w-8 h-8 rounded-full border-2 border-[#000080] border-t-transparent animate-spin" />
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
|
||||
if (items.length === 0) return null
|
||||
|
||||
return (
|
||||
<section id="offers" data-vula-section="offers" data-vula-cms="offers" className="bg-white py-20">
|
||||
<div className="max-w-7xl mx-auto px-4">
|
||||
<h2 className="text-3xl font-bold text-[#000080] text-center mb-12">Limited-Time Offers</h2>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
|
||||
{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 (
|
||||
<div key={item.id} className="bg-white rounded-xl border border-[#e5e7eb] shadow-[var(--shadow-card)] overflow-hidden hover:shadow-[var(--shadow-lifted)] hover:-translate-y-0.5 transition-all duration-200">
|
||||
{d.image && (
|
||||
<div className="relative h-48 w-full overflow-hidden">
|
||||
<Image
|
||||
src={d.image}
|
||||
alt={d.title || ''}
|
||||
fill
|
||||
className="object-cover hover:scale-105 transition-transform duration-500"
|
||||
sizes="(max-width: 768px) 100vw, 50vw"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div className="p-6">
|
||||
<h3 className="text-xl font-bold text-[#000080] mb-2">{d.title}</h3>
|
||||
<p className="text-gray-600 mb-4">{d.description}</p>
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-2xl font-bold text-[#800000]">{formatted}</span>
|
||||
{d.duration && <Badge className="bg-[#d4af37] text-white">{d.duration}</Badge>}
|
||||
</div>
|
||||
{d.valid_until && (
|
||||
<p className="text-sm text-gray-400 mt-2">Valid until {new Date(d.valid_until).toLocaleDateString()}</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user