"use client"; import { useState } from "react"; import { Button } from "../ui/primitives"; import type { Overlay } from "./types"; export interface RenderInput { templateId: "lower_third" | "chyron" | "logo"; fields: { title?: string; subtitle?: string; style?: "dark" | "red"; svg?: string } } function Editor({ overlay, disabled, onRender }: { overlay: Overlay; disabled: boolean; onRender: (id: string, input: RenderInput) => Promise }): React.ReactElement { const [title, setTitle] = useState(""); const [subtitle, setSubtitle] = useState(""); const [style, setStyle] = useState<"dark" | "red">("dark"); const [svg, setSvg] = useState(""); const [busy, setBusy] = useState(false); const [message, setMessage] = useState(""); if (overlay.kind === "clock") return

Clock overlay is server-generated.

; const templateId = overlay.kind; return
{ event.preventDefault(); setBusy(true); setMessage(""); const input: RenderInput = { templateId, fields: templateId === "logo" ? { svg } : { title, subtitle, style } }; void onRender(overlay.id, input).then(() => setMessage("Render accepted. Waiting for the current revision in status.")).catch(error => setMessage(error instanceof Error ? error.message : "Render failed")).finally(() => setBusy(false)); }}>

Template · {templateId}

{templateId === "logo" ?