"use client";
import Image from "next/image";
import { useState } from "react";
import Link from "next/link";
import { ArrowUpRight } from "lucide-react";
interface ProjectCardProps {
hero_image: string;
category: string;
title: string;
year: string;
client: string;
slug: string;
narrative_desc: string;
index: number;
}
function ProjectCard({ hero_image, category, title, year, client, slug, narrative_desc, index }: ProjectCardProps) {
// Alternating background colors like in the reference screenshot
const bgColors = ["bg-[#e2d1c1]", "bg-[#f9f6ef]", "bg-[#d8c7b8]", "bg-[#f5f1e8]"];
const bgColor = bgColors[index % bgColors.length];
return (
{/* 1. Image Area */}
{/* Floating Title on Image like reference */}
{(() => {
let current = category;
try {
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.join(" / ") : current;
} catch (e) {
return current;
}
})()}
{title}
{/* 2. Description Area */}
{narrative_desc || "Dijital dünyada markanızın sesini duyurmak ve özgün bir kimlik kazandırmak için tasarladığımız özel projelerimizden biri."}
{/* 3. Footer / Client Area */}
Müşteri
{client || "Muğla Dijital"}
{year}
);
}
export default function WorksClient({ projects: initialProjects }: { projects: any[] }) {
const [activeCategory, setActiveCategory] = useState("Hepsi");
const categories = ["Hepsi", ...Array.from(new Set(initialProjects.flatMap(p => {
let current = p.category;
try {
for (let i = 0; i < 3; i++) {
if (typeof current === 'string' && (current.trim().startsWith('[') || current.trim().startsWith('"'))) {
current = JSON.parse(current);
} else {
break;
}
}
} catch (e) { }
return Array.isArray(current) ? current : (typeof current === 'string' && current ? [current] : []);
})))];
const filteredProjects = activeCategory === "Hepsi"
? initialProjects
: initialProjects.filter(p => {
let current = p.category;
try {
for (let i = 0; i < 3; i++) {
if (typeof current === 'string' && (current.trim().startsWith('[') || current.trim().startsWith('"'))) {
current = JSON.parse(current);
} else {
break;
}
}
} catch (e) { }
const cats = Array.isArray(current) ? current : (typeof current === 'string' && current ? [current] : []);
return cats.includes(activeCategory);
});
return (
{/* Header Area */}
Portfolyo
Seçilmiş
Projeler.
Markanızın dijital dünyadaki serüvenini profesyonel dokunuşlarla şekillendiriyoruz. Global vizyon, yerel strateji ile başarı hikayeleri yazıyoruz.
{/* Filter Section */}
{categories.map((cat) => (
))}
{filteredProjects.length} Proje
{filteredProjects.map((project, index) => (
))}
{filteredProjects.length === 0 && (
Bu kategoride henüz bir proje bulunmuyor.
)}
{/* CTA Section Area */}
Sıradaki Başarı Hikayesi
Sizinle Yazılsın.
Projeyi Başlat
);
}