From 989ed3c8c0c95d4c38e6b64da86705cad56af509 Mon Sep 17 00:00:00 2001 From: 4Ventures <4ventures@MacBook-Air-de-4Ventures.local> Date: Mon, 21 Sep 2026 12:13:11 +0200 Subject: [PATCH] feat(creatives): wire dashboard list/create to /api/creatives Co-authored-by: Cursor --- src/app/dashboard/creatives/page.tsx | 110 +++++++++++++++++++++++---- 1 file changed, 96 insertions(+), 14 deletions(-) diff --git a/src/app/dashboard/creatives/page.tsx b/src/app/dashboard/creatives/page.tsx index 00b9068..063f85d 100644 --- a/src/app/dashboard/creatives/page.tsx +++ b/src/app/dashboard/creatives/page.tsx @@ -1,12 +1,55 @@ /** - * Stub: workflow de creatividades multi-tenant (upload, review, storage). + * Creatividades multi-tenant — lista vía /api/creatives (RLS). */ -import React from 'react'; -import { Image as ImageIcon, Upload } from 'lucide-react'; +'use client'; -export const revalidate = 0; +import React, { FormEvent, useEffect, useState } from 'react'; +import { Image as ImageIcon, Plus } from 'lucide-react'; + +type Creative = { + id: string; + title: string; + status: string; + created_at?: string; +}; export default function CreativesPage() { + const [creatives, setCreatives] = useState([]); + const [title, setTitle] = useState(''); + const [warning, setWarning] = useState(null); + const [err, setErr] = useState(null); + const [loading, setLoading] = useState(true); + + async function load() { + setLoading(true); + const res = await fetch('/api/creatives'); + const data = await res.json(); + setCreatives(data.creatives ?? []); + setWarning(data.warning ?? null); + setLoading(false); + } + + useEffect(() => { + void load(); + }, []); + + async function create(e: FormEvent) { + e.preventDefault(); + setErr(null); + const res = await fetch('/api/creatives', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ title }), + }); + const data = await res.json(); + if (!res.ok) { + setErr(data.error ?? 'Error al crear'); + return; + } + setTitle(''); + await load(); + } + return (
@@ -14,20 +57,59 @@ export default function CreativesPage() { Creatividades

- Revisión cliente/agencia · roadmap 4Ventures Centro de Mando. + Borradores por tenant · aplica sql/creatives.sql en Studio + antes del primer uso.

-
- -

Próximo sprint

-

- Upload (JPEG/PNG/WebP/MP4/PDF · máx 25MB), estados draft → in_review → - approved/rejected, comentarios y storage por tenant (Supabase Storage). + + {warning && ( +

+ {warning}

-
- docs/CONVERGENCE.md + )} + {err &&

{err}

} + +
+
+ + setTitle(e.target.value)} + placeholder="Video Meta · testimonial" + required + />
-
+ + + + {loading ? ( +

Cargando…

+ ) : creatives.length === 0 ? ( +
+ +

Sin creatividades aún

+
+ ) : ( +
    + {creatives.map((c) => ( +
  • + {c.title} + + {c.status} + +
  • + ))} +
+ )}
); }