fixes and bug features

This commit is contained in:
ivic00
2024-11-30 19:05:36 +01:00
parent 92e879c3fc
commit 12b4ce3a70
3 changed files with 54 additions and 13 deletions

View File

@ -0,0 +1,21 @@
import { useMutation, useQueryClient } from "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");
},
});
};