"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 } from "lucide-react" import Link from "next/link" import { motion } from "framer-motion" import Image from "next/image" import { useTranslation } from "@/lib/i18n" import { useState, useEffect } from "react" import type { Job } from "@/lib/types" export default function HomePage() { const { t } = useTranslation() const [featuredJobs, setFeaturedJobs] = useState([]) const [loading, setLoading] = useState(true) useEffect(() => { async function fetchFeaturedJobs() { try { const apiBase = process.env.NEXT_PUBLIC_API_URL || "http://localhost:8521" 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 })) const featuredRes = await fetch(`${apiBase}/api/v1/jobs?featured=true&limit=6`) if (!featuredRes.ok) throw new Error("Failed to fetch featured jobs") const featuredData = await featuredRes.json() const featuredList = featuredData.data ? mapJobs(featuredData.data) : [] if (featuredList.length === 6) { setFeaturedJobs(featuredList) return } const fallbackRes = await fetch(`${apiBase}/api/v1/jobs?limit=6`) if (!fallbackRes.ok) throw new Error("Failed to fetch fallback jobs") const fallbackData = await fallbackRes.json() const fallbackList = fallbackData.data ? mapJobs(fallbackData.data) : [] const combined = [...featuredList, ...fallbackList].slice(0, 6) if (combined.length === 6) { setFeaturedJobs(combined) } else if (combined.length > 0) { setFeaturedJobs(combined) } else { setFeaturedJobs(mockJobs.slice(0, 6)) } } catch (error) { console.error("Error fetching featured jobs:", error) // Fallback to mock data if API fails? Or just empty. // For MVP let's leave empty or maybe keep mock as fallback if needed. setFeaturedJobs(mockJobs.slice(0, 6)) } finally { setLoading(false) } } fetchFeaturedJobs() }, []) return (
{/* Hero Section */}
{t('home.hero.title')} {t('home.hero.subtitle')}
Professional Workspace
{/* Featured Jobs */}

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

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

{featuredJobs.map((job, index) => ( ))}
{/* How it Works */}

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

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

{t('home.howItWorks.step1.title')}

{t('home.howItWorks.step1.description')}

{t('home.howItWorks.step2.title')}

{t('home.howItWorks.step2.description')}

{t('home.howItWorks.step3.title')}

{t('home.howItWorks.step3.description')}

{/* Testimonials */}

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

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

{mockTestimonials.map((testimonial, index) => (

{testimonial.name}

{testimonial.role}

{testimonial.content}

))}
{/* CTA Section */}
{/* Text Content */}

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

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

{/* Image */}
Professional smiling at laptop
) }