mirror of
https://github.com/urosran/cally.git
synced 2025-11-27 17:04:55 +00:00
Editing calendar events
- Added new hook for updating events - Updated the selected event in db - Added document id as id to the event object when fetching events - Removed unused react-native-google sign-in library
This commit is contained in:
29
hooks/firebase/useUpdateEvent.ts
Normal file
29
hooks/firebase/useUpdateEvent.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import {useAuthContext} from "@/contexts/AuthContext";
|
||||
import {useMutation, useQueryClient} from "react-query";
|
||||
import firestore from "@react-native-firebase/firestore";
|
||||
import {EventData} from "@/hooks/firebase/types/eventData";
|
||||
|
||||
export const useUpdateEvent = () => {
|
||||
const {user: currentUser} = useAuthContext()
|
||||
const queryClients = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationKey: ["updateEvent"],
|
||||
mutationFn: async (eventData: Partial<EventData>) => {
|
||||
try {
|
||||
console.log("Update");
|
||||
console.log(eventData.id);
|
||||
console.log(eventData);
|
||||
await firestore()
|
||||
.collection("Events")
|
||||
.doc(eventData.id)
|
||||
.update(eventData);
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClients.invalidateQueries("events")
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user