"use client"; import { useEffect, useState } from "react"; import Link from "next/link"; import { usePageContent } from "@/hooks/usePageContent"; import { PartnerBadge } from "@/components/PartnerBadge"; type PortfolioProject = { id: string; title: string; category: string; coverImage: string | null; galleryImages: string[]; status: string; createdAt?: string; }; type FallbackProject = { id: string; title: string; category: string; image: string; }; const FALLBACK_PROJECTS: FallbackProject[] = [ { id: "fallback-1", title: "Projeto de Adequação - Coca-Cola", category: "Engenharia Veicular", image: "https://images.unsplash.com/photo-1616401784845-180882ba9ba8?q=80&w=2070&auto=format&fit=crop", }, { id: "fallback-2", title: "Laudo de Guindaste Articulado", category: "Inspeção Técnica", image: "https://images.unsplash.com/photo-1581092335397-9583eb92d232?q=80&w=2070&auto=format&fit=crop", }, { id: "fallback-3", title: "Dispositivo de Içamento Especial", category: "Projeto Mecânico", image: "https://images.unsplash.com/photo-1504917595217-d4dc5ebe6122?q=80&w=2070&auto=format&fit=crop", }, ]; export default function Home() { // Português é o idioma padrão - busca diretamente sem tradução const { content, loading } = usePageContent('home', 'pt'); const [latestProjects, setLatestProjects] = useState([]); // Usar conteúdo do banco ou fallback const hero = content?.hero || { title: 'Engenharia de Excelência para Seus Projetos', subtitle: 'Soluções completas em engenharia veicular, mecânica e segurança do trabalho com mais de 15 anos de experiência.', buttonText: 'Conheça Nossos Serviços' }; const features = content?.features || { pretitle: 'Por que nos escolher', title: 'Nossos Diferenciais', items: [ { icon: 'ri-shield-star-line', title: 'Qualidade Garantida', description: 'Processos certificados e equipe altamente qualificada.' }, { icon: 'ri-settings-4-line', title: 'Soluções Personalizadas', description: 'Atendimento sob medida para suas necessidades.' }, { icon: 'ri-truck-line', title: 'Especialização Veicular', description: 'Expertise em engenharia automotiva.' } ] as Array<{ icon: string; title: string; description: string }> }; const services = content?.services || { pretitle: 'Nossos Serviços', title: 'O Que Fazemos', items: [ { icon: 'ri-draft-line', title: 'Projetos Técnicos', description: 'Desenvolvimento de projetos de engenharia.' }, { icon: 'ri-file-paper-2-line', title: 'Laudos e Perícias', description: 'Emissão de laudos técnicos.' }, { icon: 'ri-alert-line', title: 'Segurança do Trabalho', description: 'Implementação de normas de segurança.' }, { icon: 'ri-truck-fill', title: 'Engenharia Veicular', description: 'Modificações e adaptações de veículos.' } ] as Array<{ icon: string; title: string; description: string }> }; const about = content?.about || { pretitle: 'Conheça a OCCTO', title: 'Sobre Nós', description: 'Com mais de 15 anos de experiência, a OCCTO Engenharia se consolidou como referência em soluções de engenharia.', highlights: [ 'Mais de 500 clientes atendidos', 'Equipe técnica qualificada', 'Parceiro oficial de grandes empresas' ] as string[] }; const testimonials = content?.testimonials || { pretitle: 'Depoimentos', title: 'O Que Dizem Nossos Clientes', items: [ { name: 'Ricardo Mendes', role: 'Gerente de Frota', text: 'Excelente trabalho!' }, { name: 'Fernanda Costa', role: 'Diretora de Operações', text: 'Parceria de confiança.' }, { name: 'Paulo Oliveira', role: 'Engenheiro Chefe', text: 'Conhecimento técnico incomparável.' } ] as Array<{ name: string; role: string; text: string }> }; const stats = content?.stats || { clients: '500+', projects: '1200+', years: '15' }; const cta = content?.cta || { title: 'Pronto para tirar seu projeto do papel?', text: 'Entre em contato com nossa equipe de especialistas.', button: 'Fale Conosco' }; useEffect(() => { let isMounted = true; const controller = new AbortController(); const fetchProjects = async () => { try { const response = await fetch('/api/projects', { method: 'GET', cache: 'no-store', credentials: 'same-origin', signal: controller.signal, }); if (!response.ok) { throw new Error(`Falha ao buscar projetos recentes (status ${response.status})`); } const data = await response.json(); if (isMounted && Array.isArray(data)) { const published = data .filter((project: PortfolioProject) => project.status !== 'Rascunho') .sort((a, b) => { const dateA = a.createdAt ? new Date(a.createdAt).getTime() : 0; const dateB = b.createdAt ? new Date(b.createdAt).getTime() : 0; return dateB - dateA; }) .slice(0, 3); setLatestProjects(published); } } catch (err) { if ((err as Error).name !== 'AbortError') { console.error('Erro ao buscar projetos recentes:', err); } } }; fetchProjects(); return () => { isMounted = false; controller.abort(); }; }, []); return (
{/* Hero Section */}
{/* Placeholder for Hero Image - Industrial/Truck context */}

{hero.title}

{hero.subtitle}

{hero.buttonText} Ver Soluções
{/* Features Section - Por que nos escolher */}

{features.pretitle}

{features.title}

{features.items.map((feature: { icon: string; title: string; description: string }, index: number) => (

{feature.title}

{feature.description}

))}
{/* Services Section */}

{services.pretitle}

{services.title}

{services.items.map((service: { icon: string; title: string; description: string }, index: number) => (

{service.title}

{service.description}

))}
Ver todos os serviços
{/* About Preview */}
{/* Placeholder for About Image - Engineer inspecting */}

{about.pretitle}

{about.title}

{about.description}

    {about.highlights.map((highlight: string, index: number) => (
  • {highlight}
  • ))}
Conheça nossa expertise
{/* Latest Projects Section */}

Portfólio

Projetos Recentes

Ver todos os projetos
{(latestProjects.length > 0 ? latestProjects.map((project) => ({ id: project.id, title: project.title, category: project.category, image: project.coverImage || project.galleryImages?.[0] || FALLBACK_PROJECTS[0].image, })) : FALLBACK_PROJECTS ).map((project) => (
{project.category}

{project.title}

Ver detalhes
))}
{/* Testimonials Section */}

{testimonials.pretitle}

{testimonials.title}

{testimonials.items.map((testimonial: { text: string; name: string; role: string }, index: number) => (

"{testimonial.text}"

{testimonial.name}

{testimonial.role}

))}
{/* CTA Section */}

{cta.title}

{cta.text}

{cta.button}
); }