import { useState } from 'react' import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select' import { EDGE_TYPE_LABELS, type EdgeData, type EdgeType } from '@/types' const EDGE_TYPES = Object.entries(EDGE_TYPE_LABELS) as [EdgeType, string][] interface EdgeModalProps { open: boolean onClose: () => void onSubmit: (data: EdgeData) => void onDelete?: () => void initial?: Partial title?: string } export function EdgeModal({ open, onClose, onSubmit, onDelete, initial, title = 'Connect Nodes' }: EdgeModalProps) { const [type, setType] = useState(initial?.type ?? 'ethernet') const [label, setLabel] = useState(initial?.label ?? '') const [vlanId, setVlanId] = useState(initial?.vlan_id?.toString() ?? '') const handleSubmit = (e: React.FormEvent) => { e.preventDefault() onSubmit({ type, label: label || undefined, vlan_id: type === 'vlan' && vlanId ? parseInt(vlanId) : undefined, }) onClose() } const handleDelete = () => { onDelete?.() onClose() } return ( !o && onClose()}> {title}
{type === 'vlan' && (
setVlanId(e.target.value)} placeholder="e.g. 20" className="bg-[#21262d] border-[#30363d] font-mono text-sm h-8" />
)}
setLabel(e.target.value)} placeholder="e.g. 1G, trunk..." className="bg-[#21262d] border-[#30363d] text-sm h-8" />
{onDelete ? ( ) : }
) }