import { useState, useEffect } from 'react' import { Plus, Trash2, Settings } from 'lucide-react' import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from '@/components/ui/dialog' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { scanApi } from '@/api/client' import { toast } from 'sonner' interface ScanConfigModalProps { open: boolean onClose: () => void onScanNow: () => void } export function ScanConfigModal({ open, onClose, onScanNow }: ScanConfigModalProps) { const [ranges, setRanges] = useState(['']) const [saving, setSaving] = useState(false) useEffect(() => { if (!open) return scanApi.getConfig() .then((res) => setRanges(res.data.ranges.length > 0 ? res.data.ranges : [''])) .catch(() => {/* use defaults */}) }, [open]) const handleScanNow = async () => { const cleaned = ranges.map((r) => r.trim()).filter(Boolean) if (cleaned.length === 0) { toast.error('Add at least one IP range'); return } setSaving(true) try { await scanApi.saveConfig({ ranges: cleaned }) await scanApi.trigger() onScanNow() onClose() } catch { toast.error('Failed to start scan') } finally { setSaving(false) } } return ( !v && onClose()}> Scan Configuration
{/* IP Ranges */}
{ranges.map((r, i) => (
{ const next = [...ranges] next[i] = e.target.value setRanges(next) }} placeholder="192.168.1.0/24" className="font-mono text-sm bg-[#0d1117] border-border" />
))}

Status check interval can be configured in the sidebar Settings.

) }