20 lines
641 B
TypeScript
20 lines
641 B
TypeScript
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
|
|
import { QueryKeys } from '@/shared/api/queryKeys';
|
|
|
|
import { deleteExpenseItem } from '../api/deleteExpenseItem';
|
|
|
|
import type { DeleteExpenseItemPath } from '../api/deleteExpenseItem';
|
|
|
|
export const useDeleteExpenseItem = (path: DeleteExpenseItemPath) => {
|
|
const queryClient = useQueryClient();
|
|
|
|
return useMutation({
|
|
mutationFn: async () => deleteExpenseItem(path),
|
|
mutationKey: [QueryKeys.ExpenseList, path.listId],
|
|
onSuccess: async () => {
|
|
await queryClient.invalidateQueries({ queryKey: [QueryKeys.ExpenseList, path.listId] });
|
|
},
|
|
});
|
|
};
|