Deploy
This commit is contained in:
@@ -0,0 +1,72 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import { useState } from 'react'
|
||||||
|
import { useVulaContent } from '@/hooks/useVulaContent'
|
||||||
|
import Image from 'next/image'
|
||||||
|
import Link from 'next/link'
|
||||||
|
import Button from '@/components/ui/Button'
|
||||||
|
import Badge from '@/components/ui/Badge'
|
||||||
|
|
||||||
|
export default function HarvestPromoCampaignSection() {
|
||||||
|
const { items, loading } = useVulaContent('campaigns')
|
||||||
|
const [activeIndex, setActiveIndex] = useState(0)
|
||||||
|
|
||||||
|
if (loading) return <div className="flex justify-center py-16"><div className="w-8 h-8 rounded-full border-2 border-[#6b8e23] border-t-transparent animate-spin" /></div>
|
||||||
|
if (items.length === 0) return null
|
||||||
|
|
||||||
|
// Ensure activeIndex is within bounds
|
||||||
|
const safeIndex = Math.min(activeIndex, items.length - 1)
|
||||||
|
const item = items[safeIndex]
|
||||||
|
const d = item.data as { title?: string; headline?: string; body?: string; cta_text?: string; image?: string }
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section id="campaigns" data-vula-section="harvestpromocampaign" data-vula-cms="campaigns" className="py-20 bg-[#f4f5f2]">
|
||||||
|
<div className="max-w-6xl mx-auto px-4">
|
||||||
|
<div className="relative overflow-hidden rounded-[28px] shadow-2xl" style={{ backgroundColor: '#6b8e23' }}>
|
||||||
|
<div className="grid md:grid-cols-2 items-center gap-8 p-8 md:p-12">
|
||||||
|
<div className="text-white">
|
||||||
|
{d.headline && (
|
||||||
|
<Badge variant="accent" className="mb-4 bg-[#ea580c] text-white px-4 py-1 rounded-full text-sm font-semibold">
|
||||||
|
{d.headline}
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
|
{d.title && <h2 className="text-3xl md:text-4xl font-bold mb-4 leading-tight">{d.title}</h2>}
|
||||||
|
{d.body && <p className="text-white/80 mb-6 max-w-md">{d.body}</p>}
|
||||||
|
{d.cta_text && (
|
||||||
|
<Link href="/products">
|
||||||
|
<Button variant="default" size="lg" className="rounded-full bg-white text-[#6b8e23] hover:bg-white/90 transition-all duration-200">
|
||||||
|
{d.cta_text}
|
||||||
|
</Button>
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
|
<div className="mt-6 flex items-center gap-2 text-sm text-white/70">
|
||||||
|
<span className="inline-block w-2 h-2 rounded-full bg-[#ea580c]"></span>
|
||||||
|
Limited time offer
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{d.image && (
|
||||||
|
<div className="relative h-64 md:h-80 rounded-2xl overflow-hidden">
|
||||||
|
<Image src={d.image} alt={d.title || 'Campaign image'} fill className="object-cover" sizes="(max-width: 768px) 100vw, 50vw" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{/* Navigation dots for multiple campaigns */}
|
||||||
|
{items.length > 1 && (
|
||||||
|
<div className="flex justify-center gap-2 pb-6">
|
||||||
|
{items.map((_, idx) => (
|
||||||
|
<button
|
||||||
|
key={idx}
|
||||||
|
onClick={() => setActiveIndex(idx)}
|
||||||
|
className={`w-3 h-3 rounded-full transition-colors duration-200 ${
|
||||||
|
idx === safeIndex ? 'bg-white' : 'bg-white/40 hover:bg-white/60'
|
||||||
|
}`}
|
||||||
|
aria-label={`Go to campaign ${idx + 1}`}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user