/** * Creatividades multi-tenant — lista vía /api/creatives (RLS). */ 'use client'; 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 (

Creatividades

Borradores del cliente en contexto (selector arriba). Con superadmin activo, ves/creas en ese tenant.

{warning && (

{warning}

)} {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}
  • ))}
)}
); }