"use client" import { Navbar } from "@/components/navbar" import { Footer } from "@/components/footer" import { JobCard } from "@/components/job-card" import { Button } from "@/components/ui/button" import { Card, CardContent } from "@/components/ui/card" import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" import { mockJobs, mockTestimonials } from "@/lib/mock-data" import { FileText, CheckCircle, ArrowRight, Building2, Users, ChevronLeft, ChevronRight, Eye } from "lucide-react" import Link from "next/link" import { motion } from "framer-motion" import Image from "next/image" import { useTranslation } from "@/lib/i18n" import { useConfig } from "@/contexts/ConfigContext" import { useState, useEffect } from "react" import type { Job } from "@/lib/types" export default function HomePage() { const { t } = useTranslation() const config = useConfig() const [featuredJobs, setFeaturedJobs] = useState(mockJobs.slice(0, 31)) const [loading, setLoading] = useState(true) const [featuredIndex, setFeaturedIndex] = useState(0) const [moreJobsIndex, setMoreJobsIndex] = useState(0) const [openFilters, setOpenFilters] = useState({ contractType: false, workMode: false, location: false, salary: false }) const toggleFilter = (filterName: keyof typeof openFilters) => { setOpenFilters(prev => ({ contractType: false, workMode: false, location: false, salary: false, [filterName]: !prev[filterName] })) } useEffect(() => { async function fetchFeaturedJobs() { try { const apiBase = config.apiUrl console.log("[DEBUG] API Base URL:", apiBase) const mapJobs = (jobs: any[]): Job[] => jobs.map((j: any) => ({ id: String(j.id), title: j.title, company: j.companyName || t("jobs.confidential"), location: j.location || t("workMode.remote"), type: j.employmentType || "full-time", salary: j.salaryMin ? `R$ ${j.salaryMin}` : t("jobs.salary.negotiable"), description: j.description, requirements: j.requirements || [], postedAt: j.createdAt, isFeatured: j.isFeatured })) console.log("[DEBUG] Fetching featured jobs from:", `${apiBase}/api/v1/jobs?featured=true&limit=31`) const featuredRes = await fetch(`${apiBase}/api/v1/jobs?featured=true&limit=31`) console.log("[DEBUG] Featured response status:", featuredRes.status) if (!featuredRes.ok) throw new Error("Failed to fetch featured jobs") const featuredData = await featuredRes.json() console.log("[DEBUG] Featured data from API:", featuredData) const featuredList = featuredData.data ? mapJobs(featuredData.data) : [] console.log("[DEBUG] Mapped featured jobs:", featuredList.length, "jobs") if (featuredList.length >= 24) { console.log("[DEBUG] Using featured/API jobs") setFeaturedJobs(featuredList.slice(0, 31)) return } console.log("[DEBUG] Fetching fallback jobs from:", `${apiBase}/api/v1/jobs?limit=31`) const fallbackRes = await fetch(`${apiBase}/api/v1/jobs?limit=31`) console.log("[DEBUG] Fallback response status:", fallbackRes.status) if (!fallbackRes.ok) throw new Error("Failed to fetch fallback jobs") const fallbackData = await fallbackRes.json() console.log("[DEBUG] Fallback data from API:", fallbackData) const fallbackList = fallbackData.data ? mapJobs(fallbackData.data) : [] console.log("[DEBUG] Mapped fallback jobs:", fallbackList.length, "jobs") const combined = [...featuredList, ...fallbackList].slice(0, 31) console.log("[DEBUG] Combined jobs:", combined.length, "jobs") if (combined.length >= 24) { console.log("[DEBUG] Using combined jobs") setFeaturedJobs(combined) } } catch (error) { console.error("[DEBUG] ❌ Error fetching featured jobs:", error) } finally { setLoading(false) } } fetchFeaturedJobs() }, []) return (
{/* Hero Section */}
{/* Mobile Background */}
Background {/* Black overlay with 20% opacity */}
{/* Desktop Background */}
Background
{t('home.hero.title')}
{t('home.hero.titleLine2')}
{t('home.hero.subtitle')}
{/* Search Bar Section */}
{/* Contract Type - Static Expanded */}
{t('home.search.contractType')}
{/* Work Mode - Static Expanded */}
{t('home.search.workMode')}
{/* Location - Static Expanded */}
{t('home.search.location')}
{/* Salary - Static Expanded */}
{t('home.search.salary')}
{/* Filter Button - Unified */}
{/* Featured Jobs */}

{t('home.featuredJobs.title')}

{(featuredJobs.length >= 4 ? featuredJobs.slice(0, 4) : mockJobs.slice(0, 4)) .map((job, index) => { const dates = ['02/06', '05/06', '08/06', '11/06']; const randomDate = dates[index % dates.length]; const levels = [t('home.levels.mid'), t('home.levels.junior'), t('home.levels.senior'), t('home.levels.mid')]; const level = levels[index % levels.length]; const statusLabels = [t('workMode.remote'), t('workMode.hybrid'), t('workMode.onsite'), t('workMode.remote')]; const statusLabel = statusLabels[index % statusLabels.length]; return (
{/* Header */}
{job.company}
{statusLabel}
{/* Content */}

{job.title}

Job Illustration
{/* Footer Section with Separator */}

{level} {job.location}

) })}
{/* More Jobs Section */}

{t('home.moreJobs.title')}

{mockJobs.slice(0, 8) .map((job, index) => { const colors = [ 'bg-cyan-500', 'bg-blue-500', 'bg-indigo-500', 'bg-gray-500', 'bg-teal-500', 'bg-sky-500', 'bg-orange-500', 'bg-purple-500' ]; const bgColor = colors[index % colors.length]; const icons = ['💻', '🎨', '📊', '🚀', '⚙️', '🔧', '📱', '🎯']; const icon = icons[index % icons.length]; const descriptions = [ 'Buscamos um Senior Full Stack para liderar soluções robustas e escaláveis de ponta a ponta.', 'O UX/UI Designer ideal para transformar ideias em experiências visuais incríveis.', 'Faça parte do time como Data Engineer e construa pipelines de dados inteligentes e eficientes.', 'Procuramos um Product Manager para liderar produtos inovadores do conceito ao lançamento.', 'Oportunidade para Mobile Developer criar aplicativos modernos e de alto desempenho.', 'Junte-se a nós como DevOps Engineer e automatize infraestruturas em ambientes de nuvem.', 'Vaga para Backend Developer focado em performance, segurança e APIs escaláveis.', 'Buscamos um QA Analyst atento aos detalhes para garantir a máxima qualidade dos produtos.' ]; const description = descriptions[index % descriptions.length]; return ( {/* Cabeçalho com logo e seta */}
{icon}

{job.title}

{job.company}

{description}

{/* Rodapé com botões */}
) })}
{/* CTA Section */}
{/* Image Layer: Single Image with Seamless Gradient Overlay */}
Woman with Notebook {/* Seamless Blend Gradient: Starts solid gray-900 (matching, container) on left. Fades gradually to transparent on right. This "dyes" the dark background of the photo to match the container. */}
{/* Text Content */}

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

{t('home.cta.subtitle')}

) } function FilterIcon() { return ( ); }