"use client"; import Image from "next/image"; import Link from "next/link"; export default function WorkDetailClient({ project, nextProject }: { project: any, nextProject: any }) { const isInstagram = (url: string) => { return url.includes('instagram.com'); }; const isVideo = (url: string) => { return url.includes('youtube.com') || url.includes('vimeo.com') || url.endsWith('.mp4'); }; // Ultra-safety check for gallery and category arrays const parseSafe = (data: any) => { let current = data; try { // Aggressively parse up to 3 times to handle double-quotes and double-encoding for (let i = 0; i < 3; i++) { if (typeof current === 'string' && (current.trim().startsWith('[') || current.trim().startsWith('"'))) { current = JSON.parse(current); } else { break; } } return Array.isArray(current) ? current : (typeof current === 'string' && current ? [current] : []); } catch (e) { return Array.isArray(current) ? current : (typeof current === 'string' && current ? [current] : []); } }; const gallery = parseSafe(project.gallery); const categories = parseSafe(project.category); // Helper to get Instagram embed URL const getInstaEmbedUrl = (url: string) => { const cleanUrl = url.split('?')[0]; return `${cleanUrl}${cleanUrl.endsWith('/') ? '' : '/'}embed`; }; return (
{/* 1. Editorial Header Section */}
{/* Top Line */}
{/* Left: Client Name */}
{categories.join(" / ")} / {project.year}

{project.client || project.title}

{/* Middle: Minimalist Line (Reference style) */}
{/* Right: Description */}

{project.narrative_desc || project.subtitle}

Rol

{project.role || "Kreatif Direktörlük"}

Konum

{project.location || "Muğla / Dijital"}
{/* Bottom Line */}
{/* 2. Project Feed (Gallery & Instagram) */}
{/* Hero Image First */}
{project.title}
{/* Gallery / Instagram Feed */}
{gallery.map((item: string, idx: number) => (
0{idx + 1}
{isInstagram(item) ? "INSTAGRAM FEED" : "PRODUCTION VIEW"}
{isInstagram(item) ? (