"use client" import { Button } from "@/components/ui/button" import { Card } from "@/components/ui/card" import { Star, Clock, Users, ShieldCheck } from "lucide-react" import Link from "next/link" import { useLanguage } from "@/lib/language-context" import Image from "next/image" import ratingsHu from "@/ratings_hu.json" import ratingsEn from "@/ratings_en.json" import { useEffect, useMemo, useState } from "react" const Hero = () => { const { t, language } = useLanguage() const ratingsData = language === "hu" ? ratingsHu : ratingsEn const ratingValue = ratingsData?.data?.[0]?.rating ?? 0 const ratingCount = ratingsData?.data?.[0]?.userRatingCount ?? 0 const ratingPercent = Math.max(0, Math.min(100, (ratingValue / 5) * 100)) const reviews = ratingsData?.data?.[0]?.reviews ?? [] const [featuredReview, setFeaturedReview] = useState(reviews[0] ?? null) useEffect(() => { if (!reviews.length) return const randomIndex = Math.floor(Math.random() * reviews.length) setFeaturedReview(reviews[randomIndex]) }, [language, reviews.length]) const reviewAuthor = featuredReview?.author ?? t.hero.cards.reviewAuthor const reviewInitials = useMemo(() => { if (!reviewAuthor) return t.hero.cards.reviewInitial const initials = reviewAuthor .split(" ") .filter(Boolean) .slice(0, 2) .map((part) => part[0]?.toUpperCase()) .join("") return initials || t.hero.cards.reviewInitial }, [reviewAuthor, t.hero.cards.reviewInitial]) const reviewRating = Math.max(0, Math.min(5, Math.round(featuredReview?.rating ?? 5))) const reviewTextRaw = featuredReview?.text ?? t.hero.cards.reviewText const reviewText = reviewTextRaw.length > 120 ? `${reviewTextRaw.slice(0, 120).trimEnd()}...` : reviewTextRaw return (
{/* Background with diagonal slice */}
{ratingValue.toFixed(1)}/5.0
({ratingCount}) {t.hero.rating}

{t.hero.title}
{t.hero.titleAccent}

{t.hero.description}

{/* Main Floating Card - Booking Status */}
{t.hero.cards.activeBooking}
{t.hero.cards.fixedPrice}

{t.hero.cards.departure}

{t.hero.cards.fromCity}

{t.hero.cards.destination}

{t.hero.cards.toAirport}

{t.hero.cards.duration}

{t.hero.cards.passengers}

{t.hero.cards.insured}

{/* Overlapping small cards */}
Family Travel
{t.hero.cards.familyTag}

{t.hero.cards.freeChildSeat}

{t.hero.cards.familyDesc}

Premium Fleet

{t.hero.cards.premiumFleet}

{t.hero.cards.mercedes}

{t.hero.cards.nonStop}
{t.hero.cards.supportTime}
{/* Review Snippet */}
{[1, 2, 3, 4, 5].map((i) => ( ))}

{reviewText}

{reviewInitials}
{reviewAuthor}
) } export default Hero