"use client"; import { useEffect } from "react"; import Image from "next/image"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { useCaseStudy } from "@/lib/hooks/useCaseStudy"; import { getImageUrl } from "@/lib/imageUtils"; <<<<<<< HEAD import { sanitizeHTML } from "@/lib/security/sanitize"; ======= >>>>>>> d7d7a2757a183aa1abd9dbabff804c45298df4e5 interface CaseSingleProps { slug: string; } const CaseSingle = ({ slug }: CaseSingleProps) => { const router = useRouter(); const { caseStudy, loading, error } = useCaseStudy(slug); const handleGoBack = () => { router.back(); }; // Debug logging useEffect(() => { if (error) { console.error('Error loading case study:', error); } if (caseStudy) { console.log('Case Study Data:', { title: caseStudy.title, hasCategory: !!caseStudy.category, hasClient: !!caseStudy.client, processStepsCount: caseStudy.process_steps?.length || 0, relatedCaseStudiesCount: caseStudy.related_case_studies?.length || 0, hasPosterImage: !!caseStudy.poster_image, hasProjectImage: !!caseStudy.project_image, hasFeaturedImage: !!caseStudy.featured_image, hasProjectOverview: !!caseStudy.project_overview, hasSiteMapContent: !!caseStudy.site_map_content, fullData: caseStudy }); } }, [caseStudy, error]); if (loading) { return (

Loading case study...

); } if (error || !caseStudy) { return (

Case Study Not Found

The case study you're looking for doesn't exist or has been removed.

View All Case Studies
); } return ( <> {/* Hero Banner Section */}
{/* Category Badge */} {caseStudy.category && (
{caseStudy.category.name}
)} {/* Title */}

{caseStudy.title}

{/* Subtitle */} {caseStudy.subtitle && (

{caseStudy.subtitle}

)} {/* Meta Information */}
{caseStudy.client && (
{caseStudy.client.name}
)} {caseStudy.published_at && (
{new Date(caseStudy.published_at).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' })}
)} {caseStudy.views_count !== undefined && (
{caseStudy.views_count} views
)}
{/* Hero Image */} {caseStudy.featured_image && (
{caseStudy.title}
)}
{/* Main Content Section */}
{/* Back Button - Top */}
{/* Project Overview Section */}

Project Overview

{caseStudy.project_overview ? (
) : (
)} {/* Full Description Content */} {caseStudy.description && (
)}
{/* Project Image */} {caseStudy.project_image && (
{`${caseStudy.title}
)} {/* Project Info Card */}

Project Details

{caseStudy.category && (
Category {caseStudy.category.name}
)} {caseStudy.client && (
Client {caseStudy.client.name}
)} {caseStudy.published_at && (
Published {new Date(caseStudy.published_at).toLocaleDateString('en-US', { year: 'numeric', month: 'short' })}
)} {caseStudy.featured && (
Status Featured
)}
{caseStudy.client?.website && ( )}
{/* Statistics/Metrics Section */} {caseStudy.description && caseStudy.description.includes('Key Results') && (

Key Achievements

{(() => { // Extract metrics from description const resultsMatch = caseStudy.description.match(/

Key Results<\/h3>[\s\S]*?
    ([\s\S]*?)<\/ul>/i); if (resultsMatch) { const items = resultsMatch[1].match(/
  • ([^<]+)<\/li>/g); if (items && items.length > 0) { return items.slice(0, 4).map((item, index) => { const text = item.replace(/<[^>]+>/g, ''); const numberMatch = text.match(/(\d+[%$]?)/); const number = numberMatch ? numberMatch[1] : ''; const description = text.replace(/\d+[%$]?\s*/, '').trim(); return (
    {number}
    {description}
    ); }); } } return null; })()}

)} {/* Site Map / Process Section */} {caseStudy.site_map_content && (

Site Map & Process

)} {/* Back Button - Bottom */}
); }; export default CaseSingle;