'use client'; import { yachts } from "../../../data/yachts"; import { notFound } from "next/navigation"; import { Link } from "@/i18n/routing"; import { motion } from "framer-motion"; import { use, useState, useCallback, useEffect } from "react"; import { AnimatePresence } from "framer-motion"; import { CldImage } from "next-cloudinary"; import { useTranslations, useLocale } from "next-intl"; interface PageProps { params: Promise<{ locale: string; slug: string }>; } export default function YachtPage({ params }: PageProps) { const { slug, locale: _locale } = use(params); const yacht = yachts.find((y) => y.slug === slug); const [lightboxIndex, setLightboxIndex] = useState(null); const t = useTranslations('FleetDetail'); const locale = useLocale(); const openLightbox = (index: number) => setLightboxIndex(index); const closeLightbox = () => setLightboxIndex(null); const goNext = useCallback(() => { if (lightboxIndex !== null && yacht) { setLightboxIndex((lightboxIndex + 1) % yacht.gallery.length); } }, [lightboxIndex, yacht]); const goPrev = useCallback(() => { if (lightboxIndex !== null && yacht) { setLightboxIndex((lightboxIndex - 1 + yacht.gallery.length) % yacht.gallery.length); } }, [lightboxIndex, yacht]); useEffect(() => { const handleKey = (e: KeyboardEvent) => { if (lightboxIndex === null) return; if (e.key === 'Escape') closeLightbox(); if (e.key === 'ArrowRight') goNext(); if (e.key === 'ArrowLeft') goPrev(); }; window.addEventListener('keydown', handleKey); return () => window.removeEventListener('keydown', handleKey); }, [lightboxIndex, goNext, goPrev]); if (!yacht) { notFound(); } const fadeInUp = { hidden: { opacity: 0, y: 40 }, visible: { opacity: 1, y: 0, transition: { duration: 0.8, ease: "easeOut" } } }; const staggerContainer = { hidden: { opacity: 0 }, visible: { opacity: 1, transition: { staggerChildren: 0.15 } } }; return (
{/* Editorial Hero Section */}
The Fleet Collection {yacht.name} {yacht.tagline} Explore Specifications
{/* Technical Atelier Bar */}
straighten {t('length')} {yacht.length}
groups {t('guests')} {yacht.guests}
bed {t('cabins')} {yacht.cabins}
support_agent {t('crew')} {yacht.crew}
speed {t('speed')} {yacht.speed}
{/* Editorial Content Section */}
{/* Intro Block - Full Width Centered */} {t('design_engineering')} {t('sanctuary_title1')}
{t('sanctuary_title2')}
{t('builder')} {yacht.builder}
{t('year_refit')} {yacht.year} {yacht.refitYear && `(${yacht.refitYear})`}
{locale === 'tr' && yacht.description_tr ? yacht.description_tr : yacht.description} {t('inquire_btn')}
{/* Specifications Grid - Modern Cards */}
{/* 1. Construction & Design */} {(yacht.construction || yacht.furniture) && ( 01

{t('design_construction').replace(/0\d\s\/\s/, '')}

{yacht.construction && Object.entries(yacht.construction).map(([key, value]) => ( {key.replace(/([A-Z])/g, ' $1').trim()} {value} ))}
)} {/* 2. Equipment on Board */} {yacht.equipment && yacht.equipment.length > 0 && ( 02

{t('tech_equipment').replace(/0\d\s\/\s/, '')}

{yacht.equipment.map((item, idx) => (
check
{item}
))}
)} {/* 3. Tenders & Toys */} {yacht.watersports && yacht.watersports.length > 0 && ( 03

{t('water_toys').replace(/0\d\s\/\s/, '')}

{yacht.watersports.map((item, idx) => (
anchor {item}
))}
)}
{/* Atelier Gallery Section */} {yacht.gallery && yacht.gallery.length > 0 && (
{t('atelier_experience')}

{t('gallery')}

{yacht.gallery.map((imgUrl, index) => { const isLarge = index === 0; return ( openLightbox(index)} className={`relative overflow-hidden group cursor-pointer ${isLarge ? 'md:col-span-2 lg:col-span-2 row-span-2' : 'col-span-1 row-span-1'}`} >
zoom_in
); })}
)} {/* Charter Rates Section */} {yacht.prices && yacht.prices.length > 0 && (
RATES
Charter Investment {t('rates')} {t('rates_desc')}
{yacht.prices.map((p) => ( {p.month} {p.price} ))}

* {t('apa_note')}
* {t('vat_note')}

)} {/* Editorial Navigation */}
{t('journey_title')} {t('ready_title')} {t('start_inquiry_btn')} {t('explore_btn')}
{/* Lightbox Overlay */} {lightboxIndex !== null && yacht.gallery && ( {/* Close Button */} {/* Image Counter */}
{lightboxIndex + 1} / {yacht.gallery.length}
{/* Previous Arrow */} {/* Next Arrow */} {/* Main Image */} e.stopPropagation()} >
)}
); }