diff --git a/client/pages/Projects.tsx b/client/pages/Projects.tsx index e0c53a82..8f0de0f8 100644 --- a/client/pages/Projects.tsx +++ b/client/pages/Projects.tsx @@ -3,24 +3,66 @@ import { Badge } from "@/components/ui/badge"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import ShowcaseCard from "@/components/showcase/ShowcaseCard"; -import { SHOWCASE } from "@/data/showcase"; +import { SHOWCASE, type ShowcaseProject } from "@/data/showcase"; +import { useEffect, useMemo, useState } from "react"; +import { fetchBuilderList, getBuilderApiKey } from "@/lib/builder"; +import { useAuth } from "@/contexts/AuthContext"; export default function Projects() { - const hasProjects = Array.isArray(SHOWCASE) && SHOWCASE.length > 0; + const { roles } = useAuth(); + const isOwner = Array.isArray(roles) && roles.includes("owner"); + const [cmsItems, setCmsItems] = useState(null); + const [loading, setLoading] = useState(false); + + useEffect(() => { + const apiKey = getBuilderApiKey(); + if (!apiKey) return; + setLoading(true); + fetchBuilderList("showcase-project", { limit: 50 }) + .then((res) => { + const items: ShowcaseProject[] = (res.results || []).map((r) => ({ + id: r.id, + title: r.data?.title || r.name || "Untitled", + orgUnit: r.data?.orgUnit, + role: r.data?.role, + timeframe: r.data?.timeframe, + description: r.data?.description, + tags: r.data?.tags || [], + links: r.data?.links || [], + contributors: r.data?.contributors || [], + image: r.data?.image, + })); + setCmsItems(items); + }) + .catch(() => setCmsItems(null)) + .finally(() => setLoading(false)); + }, []); + + const items = useMemo(() => (cmsItems && cmsItems.length ? cmsItems : SHOWCASE), [cmsItems]); + const hasProjects = Array.isArray(items) && items.length > 0; return (
- Showcase -

Projects & Testimonials

-

Studio initiatives across AeThex Platform, Labs, and Studio.

+
+
+ Showcase +

Projects & Testimonials

+

Studio initiatives across AeThex Platform, Labs, and Studio.

+
+ {isOwner && ( + + )} +
{hasProjects ? (
- {SHOWCASE.map((p) => ( + {items.map((p) => ( ))}