18 lines
642 B
TypeScript
18 lines
642 B
TypeScript
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
|
|
import { QueryKeys } from '@/shared/api/queryKeys';
|
|
|
|
import { editExpenseItem, type EditExpenseItemBody, type EditExpenseItemPath } from '../api/editExpenseItem';
|
|
|
|
export const useEditExpenseItem = (path: EditExpenseItemPath) => {
|
|
const queryClient = useQueryClient();
|
|
|
|
return useMutation({
|
|
mutationFn: async (data: EditExpenseItemBody) => editExpenseItem(path, data),
|
|
mutationKey: [QueryKeys.ExpenseList, path.listId],
|
|
onSuccess: async () => {
|
|
await queryClient.invalidateQueries({ queryKey: [QueryKeys.ExpenseList, path.listId] });
|
|
},
|
|
});
|
|
};
|