diff --git a/app/[lang]/page.tsx b/app/[lang]/page.tsx index 90fa216..d5bef57 100644 --- a/app/[lang]/page.tsx +++ b/app/[lang]/page.tsx @@ -1,6 +1,7 @@ import { getDictionary } from "@/get-dictionary"; import type { Locale } from "@/i18n-config"; import HomeClient from "@/components/HomeClient"; +import { getFeaturedProjects } from "../actions"; export async function generateMetadata({ params }: { params: Promise<{ lang: Locale }> }) { const { lang } = await params; @@ -17,6 +18,7 @@ export async function generateMetadata({ params }: { params: Promise<{ lang: Loc export default async function Page({ params }: { params: Promise<{ lang: Locale }> }) { const { lang } = await params; const dict = await getDictionary(lang); + const featuredProjects = await getFeaturedProjects(); - return ; + return ; } diff --git a/app/actions.ts b/app/actions.ts index 7bf35ee..7a56727 100644 --- a/app/actions.ts +++ b/app/actions.ts @@ -19,9 +19,22 @@ export async function getProjects() { } } +export async function getFeaturedProjects() { + try { + return await prisma.project.findMany({ + where: { featured: true }, + orderBy: { num: "asc" }, + take: 4, + }); + } catch (error) { + console.error("Error fetching featured projects:", error); + return []; + } +} + export async function saveProject(data: any) { try { - const { id, num, slug, title, tag, desc, spec, year, client, duration, tech, challenge, solution, results, image, gallery, website } = data; + const { id, num, slug, title, tag, desc, spec, year, client, duration, tech, challenge, solution, results, image, gallery, website, featured } = data; let project; if (id) { @@ -45,6 +58,7 @@ export async function saveProject(data: any) { image: image || "", gallery: gallery || [], website: website || "", + featured: featured || false, }, }); } else { @@ -73,6 +87,7 @@ export async function saveProject(data: any) { image: image || "", gallery: gallery || [], website: website || "", + featured: featured || false, }, }); } diff --git a/components/AdminClient.tsx b/components/AdminClient.tsx index 52e5f1f..6b0f0ad 100644 --- a/components/AdminClient.tsx +++ b/components/AdminClient.tsx @@ -33,6 +33,7 @@ interface ProjectData { image: string; gallery?: string[]; website?: string; + featured?: boolean; } interface PartnerData { @@ -94,6 +95,7 @@ export default function AdminClient({ const [formGallery, setFormGallery] = useState([]); const [newGalleryItem, setNewGalleryItem] = useState(""); const [formWebsite, setFormWebsite] = useState(""); + const [formFeatured, setFormFeatured] = useState(false); const [uploadingImage, setUploadingImage] = useState(false); const [uploadingGallery, setUploadingGallery] = useState(false); @@ -178,6 +180,7 @@ export default function AdminClient({ setFormGallery(p.gallery ? [...p.gallery] : []); setNewGalleryItem(""); setFormWebsite(p.website || ""); + setFormFeatured(p.featured || false); }; // Open modal for project adding @@ -200,6 +203,7 @@ export default function AdminClient({ setFormGallery([]); setNewGalleryItem(""); setFormWebsite(""); + setFormFeatured(false); }; // Save project @@ -237,6 +241,7 @@ export default function AdminClient({ image: formImage, gallery: formGallery, website: formWebsite, + featured: formFeatured, }; const res = await saveProject(projectDataToSave); @@ -1157,6 +1162,18 @@ export default function AdminClient({ className="w-full font-mono text-[11px] bg-[#EDE8E0] border border-[#C8C2B8] focus:border-[#0A0A0A] outline-none px-3 py-2 text-[#0A0A0A]" /> +
+ +
+ setFormFeatured(e.target.checked)} + className="w-4 h-4 cursor-pointer" + /> + Bu bizim kendi projemiz (Ana sayfada göster) +
+
diff --git a/components/HomeClient.tsx b/components/HomeClient.tsx index d02a3a9..45bb84a 100644 --- a/components/HomeClient.tsx +++ b/components/HomeClient.tsx @@ -175,7 +175,7 @@ function Label({ children }: { children: React.ReactNode }) { } // ── MAIN COMPONENT ── -export default function HomeClient({ lang, dict }: { lang: Locale; dict: any }) { +export default function HomeClient({ lang, dict, featuredProjects }: { lang: Locale; dict: any; featuredProjects?: any[] }) { const heroRef = useRef(null); const { scrollYProgress } = useScroll({ target: heroRef, offset: ["start start", "end start"] }); const heroY = useTransform(scrollYProgress, [0, 1], ["0%", "25%"]); @@ -283,7 +283,7 @@ export default function HomeClient({ lang, dict }: { lang: Locale; dict: any })
- + ); } diff --git a/components/HomeClientBelowFold.tsx b/components/HomeClientBelowFold.tsx index 1e0d059..fa3ec1c 100644 --- a/components/HomeClientBelowFold.tsx +++ b/components/HomeClientBelowFold.tsx @@ -146,7 +146,7 @@ function Label({ children }: { children: React.ReactNode }) { ); } -export default function HomeClientBelowFold({ lang, dict }: { lang: Locale; dict: any }) { +export default function HomeClientBelowFold({ lang, dict, featuredProjects }: { lang: Locale; dict: any; featuredProjects?: any[] }) { const [activeFaq, setActiveFaq] = useState(null); const [formSent, setFormSent] = useState(false); const [hoverCase, setHoverCase] = useState(null); @@ -169,9 +169,10 @@ export default function HomeClientBelowFold({ lang, dict }: { lang: Locale; dict })) : []; - const caseStudies = (dict.work.items as any[]).map((item: any, idx: number) => ({ + const rawCases = featuredProjects && featuredProjects.length > 0 ? featuredProjects : (dict.work.items as any[]); + const caseStudies = rawCases.map((item: any, idx: number) => ({ ...item, - tech: [ + tech: item.tech || [ ["Python", "TensorFlow", "Next.js", "PostgreSQL"], ["Solidity", "React", "IPFS", "Node.js"], ["Flutter", "Firebase", "Django", "AWS"], diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 64b0d94..f0458bc 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -27,6 +27,7 @@ model Project { image String @default("") gallery String[] @default([]) website String @default("") + featured Boolean @default(false) } model BlogPost {