diff --git a/client/src/pages/Detections.tsx b/client/src/pages/Detections.tsx index 3f7bc1d..e945bc5 100644 --- a/client/src/pages/Detections.tsx +++ b/client/src/pages/Detections.tsx @@ -44,6 +44,31 @@ export default function Detections() { d.anomalyType.toLowerCase().includes(searchQuery.toLowerCase()) ); + // Mutation per aggiungere a whitelist + const addToWhitelistMutation = useMutation({ + mutationFn: async (detection: Detection) => { + return await apiRequest("POST", "/api/whitelist", { + ipAddress: detection.sourceIp, + reason: `Auto-added from detection: ${detection.anomalyType} (Risk: ${parseFloat(detection.riskScore).toFixed(1)})` + }); + }, + onSuccess: (_, detection) => { + toast({ + title: "IP aggiunto alla whitelist", + description: `${detection.sourceIp} รจ stato aggiunto alla whitelist con successo.`, + }); + queryClient.invalidateQueries({ queryKey: ["/api/whitelist"] }); + queryClient.invalidateQueries({ queryKey: ["/api/detections"] }); + }, + onError: (error: any, detection) => { + toast({ + title: "Errore", + description: error.message || `Impossibile aggiungere ${detection.sourceIp} alla whitelist.`, + variant: "destructive", + }); + } + }); + const getRiskBadge = (riskScore: string) => { const score = parseFloat(riskScore); if (score >= 85) return CRITICO; @@ -253,12 +278,26 @@ export default function Detections() { )} - +
+ + + +