import { useEffect, useMemo, useState } from 'react' import { Link } from 'react-router-dom' import { AnimatePresence, motion } from 'framer-motion' import homeImg from '../assets/images/usecase-home.webp' import businessImg from '../assets/images/usecase-business.webp' import farmImg from '../assets/images/usecase-farm.webp' import { ArrowButton, Tag } from '../components/ui' import { useContent } from '../context/ContentContext' import api from '../services/api' const DESIGN_IMAGES = [homeImg, businessImg, farmImg] /** * "Powering Homes, Businesses & Beyond" — 3-page slider from the Figma "Use case section". * Published services from the admin dashboard replace the design slides when they exist. */ export default function Solutions() { const c = useContent('solutions') const [services, setServices] = useState(null) const [index, setIndex] = useState(0) useEffect(() => { api.get('/services').then((r) => setServices(r.data)).catch(() => setServices([])) }, []) const slides = useMemo(() => { if (services?.length) { return services.map((s, i) => { const m = /^solar for (.+)$/i.exec(s.title) return { key: `svc-${s.id}`, prefix: m ? s.title.slice(0, s.title.length - m[1].length) : '', highlight: m ? m[1] : s.title, text: s.description || s.short_description || '', image: s.image_url || DESIGN_IMAGES[i % DESIGN_IMAGES.length], thumb: s.thumbnail_url || s.image_url || DESIGN_IMAGES[i % DESIGN_IMAGES.length], link: '/projects', } }) } return c.slides.map((s, i) => ({ key: `design-${i}`, ...s, image: DESIGN_IMAGES[i % DESIGN_IMAGES.length], thumb: DESIGN_IMAGES[i % DESIGN_IMAGES.length], link: s.category ? `/projects?category=${s.category}` : '/projects', })) }, [services, c.slides]) const count = slides.length const current = slides[Math.min(index, count - 1)] || slides[0] const go = (d) => setIndex((i) => (i + d + count) % count) return (
{/* gallery: thumbnails + main image (640 wide in Figma) */}
{slides.slice(0, 3).map((s, i) => ( ))}
View projects →
{/* copy */}
{c.tag}

{c.title}

{current.prefix} {current.highlight}

{current.text}

{count > 1 && (
go(-1)} aria-label="Previous solution" /> go(1)} aria-label="Next solution" />
)}
) }