mirror of
https://github.com/sakaljurgis/best-choice.git
synced 2026-07-08 21:47:40 +00:00
progress
This commit is contained in:
@@ -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) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user