import type { QueryClient } from "@tanstack/react-query"; import { qk } from "./queryKeys"; // Shared bits of the admin's user-management surface, extracted because the SAME two mutations // (activate, resend-verification) are now offered from two places — the pending-access queue and // the account panel — and the second copy quietly dropped half of what the first one does. // // Grouped invalidation lives per domain rather than in `qk` (see the contract note there); // `invalidateDownloads` is the same pattern for the downloads domain. /** Everything that goes stale when an account is LET IN (activate, resend its confirmation). * * Suspend and delete move the same counters and are deliberately NOT wired here yet — they have * their own pre-existing staleness, tracked separately, and widening this in passing would put an * unreviewed change in a review-fix diff. * * `me` is in the set because the admin badge counts pending activations, and `admin-pending-access` * because the queue is exactly the list of accounts this action removes one from — refreshing only * `admin-users` leaves the badge and the queue asserting a person is still stuck after they were * let in. One function so the two call sites cannot drift apart again. */ export function invalidateUserAccess(qc: QueryClient, userId?: number) { qc.invalidateQueries({ queryKey: qk.adminUsers() }); qc.invalidateQueries({ queryKey: qk.adminPendingAccess() }); qc.invalidateQueries({ queryKey: qk.me() }); if (userId !== undefined) qc.invalidateQueries({ queryKey: qk.adminUserAccess(userId) }); }