mirror of
https://github.com/urosran/cally.git
synced 2025-07-10 15:17:17 +00:00
24 lines
726 B
TypeScript
24 lines
726 B
TypeScript
import { useMutation, useQueryClient } from "react-query";
|
|
import firestore from "@react-native-firebase/firestore";
|
|
import { IToDo } from "@/hooks/firebase/types/todoData";
|
|
|
|
export const useUpdateTodo = () => {
|
|
const queryClients = useQueryClient()
|
|
|
|
return useMutation({
|
|
mutationKey: ["updateTodo"],
|
|
mutationFn: async (todoData: Partial<IToDo>) => {
|
|
try {
|
|
await firestore()
|
|
.collection("Todos")
|
|
.doc(todoData.id)
|
|
.update(todoData);
|
|
} catch (e) {
|
|
console.error(e)
|
|
}
|
|
},
|
|
onSuccess: () => {
|
|
queryClients.invalidateQueries("todos")
|
|
}
|
|
})
|
|
} |