import type { BoardLabel } from "@vtit-agent-coding/shared"; import { Shuffle } from "lucide-react"; import { useEffect, useState } from "react"; import { LabelChip } from "./LabelChip"; import { Button } from "./ui/button"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "./ui/dialog"; import { Input } from "./ui/input"; import { Label } from "./ui/label"; export type LabelFormMode = "create" | "edit"; const LABEL_COLORS = ["#22D3EE", "#22C55E", "#EAB308", "#EF4444", "#A78BFA", "#F97316", "#38BDF8", "#F472B6"]; function randomLabelColor() { return LABEL_COLORS[Math.floor(Math.random() * LABEL_COLORS.length)]; } interface LabelFormDialogProps { mode: LabelFormMode; open: boolean; initialLabel: BoardLabel | null; pending: boolean; error: string | null; onClose: () => void; onSubmit: (input: BoardLabel) => void; } export function LabelFormDialog(props: LabelFormDialogProps) { const { mode, open, initialLabel, pending, error, onClose, onSubmit } = props; const [name, setName] = useState(""); const [color, setColor] = useState("#71717A"); const [description, setDescription] = useState(""); useEffect(() => { setName(initialLabel?.name ?? ""); setColor(initialLabel?.color ?? "#71717A"); setDescription(initialLabel?.description ?? ""); }, [initialLabel, open]); function submit() { onSubmit({ name: name.trim(), color, description: description.trim() }); } return ( !nextOpen && onClose()}> {mode === "create" ? "Add label" : "Edit label"} Configure board label name, color, and description {error &&

{error}

}
); } interface LabelFormFieldsProps { name: string; color: string; description: string; onName: (value: string) => void; onColor: (value: string) => void; onDescription: (value: string) => void; } function LabelFormFields(props: LabelFormFieldsProps) { const { name, color, description, onName, onColor, onDescription } = props; return (
onName(event.target.value)} />
onColor(event.target.value)} className="h-9 w-14 cursor-pointer p-1" />
onDescription(event.target.value)} />
); } interface DeleteLabelDialogProps { labelName: string | null; pending: boolean; error: string | null; onClose: () => void; onConfirm: () => void; } export function DeleteLabelDialog({ labelName, pending, error, onClose, onConfirm }: DeleteLabelDialogProps) { return ( !open && onClose()}> Delete label Delete {labelName ? `"${labelName}"` : "this label"} from this board and remove it from all tasks. {error &&

{error}

}
); }