mirror of
https://github.com/urosran/cally.git
synced 2025-07-10 07:07:16 +00:00
24 lines
767 B
TypeScript
24 lines
767 B
TypeScript
import {useMutation, useQueryClient} from "@tanstack/react-query";
|
|
import firestore from "@react-native-firebase/firestore";
|
|
import {EventData} from "@/hooks/firebase/types/eventData";
|
|
|
|
export const useUpdateEvent = () => {
|
|
const queryClients = useQueryClient()
|
|
|
|
return useMutation({
|
|
mutationKey: ["updateEvent"],
|
|
mutationFn: async (eventData: Partial<EventData>) => {
|
|
try {
|
|
await firestore()
|
|
.collection("Events")
|
|
.doc(`${eventData.id}`)
|
|
.update(eventData);
|
|
} catch (e) {
|
|
console.error(e)
|
|
}
|
|
},
|
|
onSuccess: () => {
|
|
queryClients.invalidateQueries({queryKey: ["events"]})
|
|
}
|
|
})
|
|
} |