"use client"; import { useState, useTransition } from "react"; import Image from "next/image"; import { Film, Save } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; import { useToast } from "@/components/ui/use-toast"; import { updateShotSlate } from "@/actions/shots"; import type { ShotWithDetails } from "@/types"; interface Props { shot: ShotWithDetails; projectName: string; onSaved: () => void; } /** Left-side slate row: label + editable/static value */ function SlateRow({ label, children }: { label: string; children: React.ReactNode }) { return (
{label}
{children}
); } /** Right-side metadata row */ function MetaRow({ label, value }: { label: string; value: string }) { return (
{label} {value || "—"}
); } export function ShotSlateTab({ shot, projectName, onSaved }: Props) { const { toast } = useToast(); const [isPending, startTransition] = useTransition(); const [slateType, setSlateType] = useState(shot.slateType ?? ""); const [slateDescription, setSlateDescription] = useState(shot.slateDescription ?? shot.description ?? ""); const [slateVfxScope, setSlateVfxScope] = useState(shot.slateVfxScope ?? ""); const [slateSubmissionNote, setSlateSubmissionNote] = useState(shot.slateSubmissionNote ?? ""); const today = new Date(); const dateStr = `${today.getFullYear()}/${String(today.getMonth() + 1).padStart(2, "0")}/${String(today.getDate()).padStart(2, "0")}`; const versionName = `${shot.shotCode}_cmp_TT_${shot.shotVersion ?? "v001"}`; const frames = shot.frameStart != null && shot.frameEnd != null ? String(shot.frameEnd - shot.frameStart + 1) : "—"; const handleSave = () => { startTransition(async () => { try { await updateShotSlate(shot.id, { slateType: slateType.trim() || null, slateDescription: slateDescription.trim() || null, slateVfxScope: slateVfxScope.trim() || null, slateSubmissionNote: slateSubmissionNote.trim() || null, }); toast({ title: "Slate saved" }); onSaved(); } catch (e) { toast({ title: "Failed to save", description: e instanceof Error ? e.message : undefined, variant: "destructive" }); } }); }; return (
{/* Slate document */}
{/* Top accent bar */}
{/* ── Left column: editorial data ─────────────────────────────── */}
{/* Header row */}

Show

{projectName.toUpperCase()}

Submitting For

REVIEW
{/* Auto-filled rows */} {versionName} {dateStr} {/* Editable rows */} setSlateType(e.target.value)} placeholder="e.g. 2D COMP" className="h-7 bg-zinc-900 border-zinc-700 text-sm font-medium text-zinc-100 placeholder:text-zinc-600" />