This commit is contained in:
Jurgis Sakalauskas
2025-10-13 18:10:52 +03:00
parent ff18d0daeb
commit 7bc38e9a6e
7 changed files with 253 additions and 76 deletions
+19 -1
View File
@@ -11,8 +11,10 @@ import {
import {
createItem,
fetchProjectItems,
updateItem,
type CreateItemPayload,
type ProjectItemsResponse
type ProjectItemsResponse,
type UpdateItemPayload
} from '../api/items';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
@@ -98,3 +100,19 @@ export const useCreateItemMutation = (projectId: string | undefined) => {
}
});
};
export const useUpdateItemMutation = (projectId: string | undefined) => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: ({ itemId, payload }: { itemId: string; payload: UpdateItemPayload }) =>
updateItem(itemId, payload),
onSuccess: () => {
if (!projectId) {
return;
}
queryClient.invalidateQueries({ queryKey: projectsKeys.items(projectId) });
queryClient.invalidateQueries({ queryKey: projectsKeys.detail(projectId) });
}
});
};