This commit is contained in:
Vula Builder
2026-07-27 17:10:22 +00:00
parent a95fdbbe43
commit ae7380e996
@@ -0,0 +1,72 @@
'use client'
import { useState, useEffect } from 'react';
import { useVulaContent } from '@/hooks/useVulaContent'
import { Card, CardContent } from '@/components/ui/Card'
import Button from '@/components/ui/Button'
import Image from 'next/image'
export default function CampaignsSection() {
const { items, loading } = useVulaContent('campaigns')
const [countdown, setCountdown] = useState('')
// Compute countdown for first campaign with headline containing a date
useEffect(() => {
if (items.length === 0) return
const first = items[0]
const d = first.data as { headline?: string }
if (d.headline && /\d{4}-\d{2}-\d{2}/.test(d.headline)) {
const match = d.headline.match(/(\d{4}-\d{2}-\d{2})/)
const end = new Date(match![1])
const timer = setInterval(() => {
const diff = end.getTime() - Date.now()
if (diff <= 0) { setCountdown('DROP LIVE'); clearInterval(timer); return }
const days = Math.floor(diff / (1000 * 60 * 60 * 24))
const hrs = Math.floor((diff % 86400000) / 3600000)
setCountdown(`${days}d ${hrs}h`)
}, 60000)
return () => clearInterval(timer)
}
}, [items])
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
return (
<section id="drops" data-vula-section="campaigns" data-vula-cms="campaigns" className="bg-[#18181b] py-20">
<div className="container mx-auto px-4">
<h2 className="font-['Archivo_Black'] uppercase text-4xl md:text-5xl text-[#d4af37] mb-12 tracking-tight">
DROPS
</h2>
<div className="grid grid-cols-1 lg:grid-cols-2 gap-8">
{items.slice(0, 4).map((item) => {
const d = item.data as { title?: string; headline?: string; body?: string; cta_text?: string; image?: string }
return (
<Card key={item.id} className="border-3 border-[#d4af37] bg-black rounded-none shadow-[6px_6px_0_0_#d4af37] overflow-hidden">
<div className="relative h-64">
{d.image && (
<Image src={d.image} alt={d.title || ''} fill className="object-cover" sizes="(max-width: 768px) 100vw, 50vw" />
)}
{countdown && (
<div className="absolute top-4 right-4 bg-[#d4af37] text-black px-3 py-1 font-bold text-xs uppercase tracking-widest">
{countdown}
</div>
)}
</div>
<CardContent className="p-6 space-y-4">
{d.title && <h3 className="font-['Archivo_Black'] text-2xl text-white uppercase tracking-tight">{d.title}</h3>}
{d.headline && <p className="text-[#d4af37] text-sm uppercase tracking-widest">{d.headline}</p>}
{d.body && <p className="text-gray-300 text-sm">{d.body}</p>}
{d.cta_text && (
<Button variant="outline" className="border-[#d4af37] text-[#d4af37] hover:bg-[#d4af37] hover:text-black font-bold uppercase tracking-widest">
{d.cta_text}
</Button>
)}
</CardContent>
</Card>
)
})}
</div>
</div>
</section>
)
}