From ae7380e996c8cb8ad825080eba46762b842ed2d8 Mon Sep 17 00:00:00 2001 From: Vula Builder Date: Mon, 27 Jul 2026 17:10:22 +0000 Subject: [PATCH] Deploy --- src/components/sections/CampaignsSection.tsx | 72 ++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/components/sections/CampaignsSection.tsx diff --git a/src/components/sections/CampaignsSection.tsx b/src/components/sections/CampaignsSection.tsx new file mode 100644 index 0000000..0172fa4 --- /dev/null +++ b/src/components/sections/CampaignsSection.tsx @@ -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
+ if (items.length === 0) return null + + return ( +
+
+

+ DROPS +

+
+ {items.slice(0, 4).map((item) => { + const d = item.data as { title?: string; headline?: string; body?: string; cta_text?: string; image?: string } + return ( + +
+ {d.image && ( + {d.title + )} + {countdown && ( +
+ {countdown} +
+ )} +
+ + {d.title &&

{d.title}

} + {d.headline &&

{d.headline}

} + {d.body &&

{d.body}

} + {d.cta_text && ( + + )} +
+
+ ) + })} +
+
+
+ ) +} \ No newline at end of file