edit price

This commit is contained in:
Jurgis Sakalauskas
2025-10-14 16:47:20 +03:00
parent 0d97a497ea
commit 677a5a3272
6 changed files with 335 additions and 40 deletions
+24 -1
View File
@@ -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) });
}
}
});
};