"use client"; import { useState, useEffect } from "react"; import Link from "next/link"; import { useLocale } from "@/contexts/LocaleContext"; type Service = { id: string; title: string; icon: string; shortDescription: string | null; fullDescription: string | null; active: boolean; order: number; }; export default function ServicosPage() { const { t, locale } = useLocale(); const prefix = locale === 'pt' ? '' : `/${locale}`; const [services, setServices] = useState([]); const [loading, setLoading] = useState(true); // Fallback services usando traduções const fallbackServices = [ { icon: "ri-draft-line", title: t('services.technical.title'), shortDescription: t('services.technical.description'), }, { icon: "ri-truck-line", title: t('services.vehicular.title'), shortDescription: t('services.vehicular.description'), }, { icon: "ri-file-paper-2-line", title: t('services.reports.title'), shortDescription: t('services.reports.description'), }, { icon: "ri-tools-fill", title: t('services.consulting.title'), shortDescription: t('services.consulting.description'), } ]; useEffect(() => { async function fetchServices() { try { const res = await fetch('/api/services'); if (res.ok) { const data = await res.json(); // Filtrar apenas serviços ativos e ordenar const activeServices = data .filter((s: Service) => s.active) .sort((a: Service, b: Service) => a.order - b.order); setServices(activeServices); } } catch (error) { console.error('Erro ao carregar serviços:', error); } finally { setLoading(false); } } fetchServices(); }, []); const displayServices = services.length > 0 ? services : fallbackServices; return (
{/* Hero Section */}

{t('services.hero.title')}

{t('services.hero.subtitle')}

{/* Services List */}
{loading ? (
) : (
{displayServices.map((service, index) => (
0{index + 1}

{service.title}

{service.shortDescription || ''}

))}
)}
{/* CTA */}

{t('services.cta.title')}

{t('services.cta.button')}
); }