import Layout from "@/components/Layout"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; import { supabase } from "@/lib/supabase"; import { useAuth } from "@/contexts/AuthContext"; import { useEffect, useState } from "react"; interface Link { label: string; href: string; } interface Contributor { name: string; title?: string; avatar?: string; } export default function ProjectsAdmin() { const { user, roles, loading: authLoading } = useAuth(); const isOwner = Boolean( user?.email?.toLowerCase() === "mrpiglr@gmail.com" || (roles || []).some((r) => ["owner", "admin", "founder", "staff"].includes( String(r).toLowerCase(), ), ), ); const [list, setList] = useState([]); const [loading, setLoading] = useState(false); const [draft, setDraft] = useState({ title: "", org_unit: "Studio", timeframe: "", description: "", tags: "", }); useEffect(() => { if (authLoading) return; if (!isOwner) return; setLoading(true); supabase .from("showcase_projects" as any) .select("id,title,org_unit,role,timeframe,description,tags") .order("created_at", { ascending: false }) .then(({ data }) => setList(data || [])) .finally(() => setLoading(false)); }, [authLoading, isOwner]); const create = async () => { const tags = (draft.tags || "") .split(",") .map((s: string) => s.trim()) .filter(Boolean); const { error } = await supabase .from("showcase_projects" as any) .insert({ title: draft.title, org_unit: draft.org_unit, role: "AeThex", timeframe: draft.timeframe || null, description: draft.description || null, tags, }); if (!error) { setDraft({ title: "", org_unit: "Studio", timeframe: "", description: "", tags: "", }); const { data } = await supabase .from("showcase_projects" as any) .select("id,title,org_unit,role,timeframe,description,tags") .order("created_at", { ascending: false }); setList(data || []); } }; if (authLoading) { return (
Loading Checking access…
); } if (!isOwner) { return (
Access denied Owner account required.
); } return (
Admin

Projects Admin

Create and manage showcase entries (Supabase)

New project Title and basics setDraft({ ...draft, title: e.target.value })} />
setDraft({ ...draft, timeframe: e.target.value }) } />