refactor(web): rewrite mutation with PATCH /v1/admin/apps/:appKey/auth-clients/:appAuthClientId

This commit is contained in:
Ali BARIN
2024-08-27 16:46:10 +00:00
parent b2bda8479e
commit 09bc0bba1e
7 changed files with 40 additions and 63 deletions

View File

@@ -0,0 +1,28 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import api from 'helpers/api';
export default function useAdminUpdateAppAuthClient(appKey, id) {
const queryClient = useQueryClient();
const query = useMutation({
mutationFn: async (payload) => {
const { data } = await api.patch(
`/v1/admin/apps/${appKey}/auth-clients/${id}`,
payload,
);
return data;
},
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: ['admin', 'apps', appKey, 'authClients', id],
});
queryClient.invalidateQueries({
queryKey: ['admin', 'apps', appKey, 'authClients'],
});
},
});
return query;
}