mirror of
https://github.com/sakaljurgis/best-choice.git
synced 2026-07-08 21:47:40 +00:00
prices panel
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import {
|
||||
createItemPrice,
|
||||
deleteItemPrice,
|
||||
fetchItemPrices,
|
||||
type CreateItemPricePayload,
|
||||
type ItemPricesResponse
|
||||
@@ -50,3 +51,23 @@ export const useCreateItemPriceMutation = (
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeleteItemPriceMutation = (
|
||||
itemId: string | undefined,
|
||||
projectId: string | undefined
|
||||
) => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (priceId: string) => deleteItemPrice(priceId),
|
||||
onSuccess: () => {
|
||||
if (itemId) {
|
||||
queryClient.invalidateQueries({ queryKey: itemPricesKeys.list(itemId) });
|
||||
}
|
||||
if (projectId) {
|
||||
queryClient.invalidateQueries({ queryKey: projectsKeys.items(projectId) });
|
||||
queryClient.invalidateQueries({ queryKey: projectsKeys.detail(projectId) });
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user