delete project

This commit is contained in:
Jurgis Sakalauskas
2025-10-16 08:48:31 +03:00
parent 343f48de66
commit cea323ec3b
4 changed files with 74 additions and 0 deletions
+14
View File
@@ -3,6 +3,7 @@ import {
fetchProject,
fetchProjects,
updateProject,
deleteProject,
type CreateProjectPayload,
type ProjectsListResponse,
type UpdateProjectPayload
@@ -116,3 +117,16 @@ export const useUpdateItemMutation = (projectId: string | undefined) => {
}
});
};
export const useDeleteProjectMutation = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (projectId: string) => deleteProject(projectId),
onSuccess: (_, projectId) => {
queryClient.invalidateQueries({ queryKey: projectsKeys.list() });
queryClient.removeQueries({ queryKey: projectsKeys.detail(projectId) });
queryClient.removeQueries({ queryKey: projectsKeys.items(projectId) });
}
});
};