mirror of
https://github.com/shankar0123/certctl.git
synced 2026-06-13 06:58:53 +00:00
M-029 Pass 1 batch 2: migrate 5 two-mutation pages to useTrackedMutation
Drains 10 more useMutation sites (52 -> 42). Each migration declares explicit
invalidates per the M-009 contract.
Pages migrated:
- DashboardPage.tsx previewDigest + sendDigest both 'noop' (read-only
preview / fire-and-forget email — no client cache impact)
- DiscoveryPage.tsx claim + dismiss both invalidate
[['discovered-certificates'], ['discovery-summary']]
- NotificationsPage.tsx markRead + requeue both invalidate [['notifications']]
- TargetDetailPage.tsx update + testConnection both invalidate [['target', id]]
- TargetsPage.tsx createTarget + deleteTarget both invalidate [['targets']]
Verification:
legacy useMutation count 52 -> 42 (-10)
useTrackedMutation count 4 -> 14 (+10)
Closes 14 of 56 sites toward M-029 Pass 1 completion.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useState } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { useTrackedMutation } from '../hooks/useTrackedMutation';
|
||||
import { getTargets, createTarget, deleteTarget, getAgents } from '../api/client';
|
||||
import PageHeader from '../components/PageHeader';
|
||||
import DataTable from '../components/DataTable';
|
||||
@@ -242,13 +243,14 @@ function CreateTargetWizard({ onClose, onSuccess }: { onClose: () => void; onSuc
|
||||
return result;
|
||||
};
|
||||
|
||||
const mutation = useMutation({
|
||||
const mutation = useTrackedMutation({
|
||||
mutationFn: () => createTarget({
|
||||
name,
|
||||
type: targetType,
|
||||
agent_id: agentId,
|
||||
config: buildConfigPayload(),
|
||||
}),
|
||||
invalidates: [['targets']],
|
||||
onSuccess: () => onSuccess(),
|
||||
onError: (err: Error) => setError(err.message),
|
||||
});
|
||||
@@ -407,9 +409,9 @@ export default function TargetsPage() {
|
||||
queryFn: () => getTargets(),
|
||||
});
|
||||
|
||||
const deleteMutation = useMutation({
|
||||
const deleteMutation = useTrackedMutation({
|
||||
mutationFn: deleteTarget,
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['targets'] }),
|
||||
invalidates: [['targets']],
|
||||
});
|
||||
|
||||
const columns: Column<Target>[] = [
|
||||
|
||||
Reference in New Issue
Block a user