import { useEffect, useState } from "react"; import { useNavigate, useParams } from "react-router-dom"; import { ArrowLeft, Check } from "lucide-react"; import { getVodById, patchVod } from "../utils/api/vods.ts"; import Box from "../components/Box.tsx"; import PrimaryButton from "../components/buttons/PrimaryButton.tsx"; const inputClass = "border border-hairline bg-fields rounded-md w-full p-2 text-sm focus:outline-none focus:ring-2 focus:ring-muted transition-colors"; const EditVod = () => { const { id } = useParams(); const navigate = useNavigate(); const [title, setTitle] = useState(""); const [description, setDescription] = useState(""); const [loading, setLoading] = useState(true); const [saving, setSaving] = useState(false); const [saved, setSaved] = useState(false); const [error, setError] = useState(null); useEffect(() => { if (!id) return; getVodById(id) .then((vod) => { if (vod) { setTitle(vod.title ?? ""); setDescription(vod.description ?? ""); } }) .catch(() => setError("Failed to load vod.")) .finally(() => setLoading(false)); }, [id]); const handleSave = async () => { if (!id) return; setSaving(true); setError(null); try { await patchVod(Number(id), { title, description }); setSaved(true); setTimeout(() => setSaved(false), 2000); } catch (err) { setError(err instanceof Error ? err.message : "Failed to save."); } finally { setSaving(false); } }; return (

Edit VoD

{loading ? (
Loading...
) : (
setTitle(e.target.value)} placeholder="Enter title" className={inputClass} />