mirror of
https://github.com/urosran/cally.git
synced 2025-07-10 15:17:17 +00:00
22 lines
615 B
TypeScript
22 lines
615 B
TypeScript
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
import firestore from "@react-native-firebase/firestore";
|
|
|
|
export const useDeleteGrocery = () => {
|
|
const queryClient = useQueryClient();
|
|
|
|
return useMutation({
|
|
mutationKey: ["deleteGrocery"],
|
|
mutationFn: async (groceryId: string) => {
|
|
try {
|
|
await firestore().collection("Groceries").doc(groceryId).delete();
|
|
} catch (e) {
|
|
console.error(e);
|
|
throw new Error("Failed to delete the grocery item.");
|
|
}
|
|
},
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries("groceries");
|
|
},
|
|
});
|
|
};
|