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 ( ); } 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 (