mirror of
https://github.com/shankar0123/certctl.git
synced 2026-06-14 00:38:59 +00:00
M-029 Pass 1 batch 3: migrate 3 three-mutation pages to useTrackedMutation
Drains 9 more useMutation sites (42 -> 33). HealthMonitorPage hoists the
shared invalidation pair into a healthCheckInvalidates const so the three
mutations don't repeat the array literal.
Pages migrated:
- HealthMonitorPage.tsx create + delete + acknowledge all invalidate
[['health-checks'], ['health-checks-summary']]
(hoisted to a shared const)
- AgentGroupsPage.tsx delete + create + update all invalidate [['agent-groups']]
(queryClient kept — modal onSuccess props still use it)
- JobsPage.tsx cancel + approve + reject all invalidate [['jobs']]
Verification:
legacy useMutation count 42 -> 33 (-9)
useTrackedMutation count 14 -> 23 (+9)
Closes 23 of 56 sites toward M-029 Pass 1 completion.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { useTrackedMutation } from '../hooks/useTrackedMutation';
|
||||
import { getAgentGroups, deleteAgentGroup, createAgentGroup, updateAgentGroup } from '../api/client';
|
||||
import PageHeader from '../components/PageHeader';
|
||||
import DataTable from '../components/DataTable';
|
||||
@@ -259,23 +260,23 @@ export default function AgentGroupsPage() {
|
||||
queryFn: () => getAgentGroups(),
|
||||
});
|
||||
|
||||
const deleteMutation = useMutation({
|
||||
const deleteMutation = useTrackedMutation({
|
||||
mutationFn: deleteAgentGroup,
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['agent-groups'] }),
|
||||
invalidates: [['agent-groups']],
|
||||
});
|
||||
|
||||
const createMutation = useMutation({
|
||||
const createMutation = useTrackedMutation({
|
||||
mutationFn: createAgentGroup,
|
||||
invalidates: [['agent-groups']],
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['agent-groups'] });
|
||||
setShowCreate(false);
|
||||
},
|
||||
});
|
||||
|
||||
const updateMutation = useMutation({
|
||||
const updateMutation = useTrackedMutation({
|
||||
mutationFn: ({ id, data }: { id: string; data: Partial<AgentGroup> }) => updateAgentGroup(id, data),
|
||||
invalidates: [['agent-groups']],
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['agent-groups'] });
|
||||
setEditingGroup(null);
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user