import { useState } from 'react'; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; // import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { useWagons, useAssignWagonToTrain } from '@/hooks/useWagons'; import { useToast } from '@/hooks/use-toast'; import { Plus } from 'lucide-react'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@edr/ui-common'; export function AssignWagonDialog({ trainId }: { trainId: string }) { const [open, setOpen] = useState(false); const [wagonId, setWagonId] = useState(''); const [sequence, setSequence] = useState(); const { data: wagons } = useWagons(); const assign = useAssignWagonToTrain(); const { toast } = useToast(); const available = wagons?.filter((w:any) => w.status === 'AVAILABLE' || !w.trainId); const handleAssign = async () => { if (!wagonId) return; await assign.mutateAsync({ wagonId, trainId, sequenceNumber: sequence }); toast({ title: 'Assigned', description: 'Wagon attached to train.' }); setOpen(false); }; return ( Assign Wagon to Train
setSequence(parseInt(e.target.value) || undefined)} />
); }