mirror of
https://github.com/sakaljurgis/best-choice.git
synced 2026-07-08 21:47:40 +00:00
edit price
This commit is contained in:
@@ -3,8 +3,10 @@ import {
|
||||
createItemPrice,
|
||||
deleteItemPrice,
|
||||
fetchItemPrices,
|
||||
updateItemPrice,
|
||||
type CreateItemPricePayload,
|
||||
type ItemPricesResponse
|
||||
type ItemPricesResponse,
|
||||
type UpdateItemPricePayload
|
||||
} from '../api/item-prices';
|
||||
import { projectsKeys } from './projects';
|
||||
|
||||
@@ -71,3 +73,24 @@ export const useDeleteItemPriceMutation = (
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateItemPriceMutation = (
|
||||
itemId: string | undefined,
|
||||
projectId: string | undefined
|
||||
) => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (variables: { priceId: string; payload: UpdateItemPricePayload }) =>
|
||||
updateItemPrice(variables.priceId, variables.payload),
|
||||
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