"use client"; /** * Messages (§7): from the church's YouTube channel or playlist automatically, or added by hand with * a YouTube or Spotify link. Each publishes on its own (decision 9); ones from YouTube go live by * themselves. Add the speaker, series and passage afterwards, or hide one. */ import { useState } from "react"; import { api, canEdit } from "@/admin/api"; import { Btn, Field, inputClass, Loading, Notice, Panel, Title, useAction, useAdmin, when } from "@/admin/ui"; type Message = { id: string; title: string; date: string; mediaUrl: string; source: string; speaker: string | null; passage: string | null; notes: string | null; series: string | null; hidden: boolean; published: boolean; thumbnail: string | null }; type Data = { youtube: { source: { kind: string; id: string } | null; lastSync: string | null; lastError: string | null }; items: Message[] }; const blank = { title: "", date: new Date().toISOString().slice(0, 10), mediaUrl: "", speaker: "", passage: "", series: "", notes: "", hidden: false }; function MessageForm({ initial, fromFeed, onSave, onCancel }: { initial: typeof blank; fromFeed: boolean; onSave: (v: typeof blank) => Promise; onCancel: () => void }) { const [v, setV] = useState(initial); const { busy, message, fields, run } = useAction(); const set = (k: keyof typeof blank, x: string | boolean) => setV({ ...v, [k]: x }); return (
set("title", e.target.value)} /> set("date", e.target.value)} /> {!fromFeed && set("mediaUrl", e.target.value)} />} set("speaker", e.target.value)} /> set("series", e.target.value)} /> set("passage", e.target.value)} />