Update how IP addresses are checked for whitelisting

Correctly handle whitelist data response format in detections page to prevent runtime errors.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: c1ba4b9b-0664-47cc-9e51-47cb707b4948
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/RyXWGQA
This commit is contained in:
marco370 2026-02-16 07:48:48 +00:00
parent 66e110ce4c
commit ee2ba0b3b9

View File

@ -73,13 +73,12 @@ export default function Detections() {
const totalCount = data?.total || 0;
const totalPages = Math.ceil(totalCount / ITEMS_PER_PAGE);
// Fetch whitelist to check if IP is already whitelisted
const { data: whitelistData } = useQuery<Whitelist[]>({
queryKey: ["/api/whitelist"],
const { data: whitelistData } = useQuery<{ items: Whitelist[]; total: number }>({
queryKey: ["/api/whitelist", "all"],
queryFn: () => fetch("/api/whitelist?limit=10000").then(r => r.json()),
});
// Create a Set of whitelisted IPs for fast lookup
const whitelistedIps = new Set(whitelistData?.map(w => w.ipAddress) || []);
const whitelistedIps = new Set(whitelistData?.items?.map(w => w.ipAddress) || []);
// Mutation per aggiungere a whitelist
const addToWhitelistMutation = useMutation({