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:
Dejan
2024-10-11 13:24:25 +02:00
parent 7d9d41acfc
commit 562da49806
6 changed files with 39 additions and 42 deletions
+1
View File
@@ -31,6 +31,7 @@ export const useGetEvents = (isFamilyView: boolean) => {
const eventColor: string = profileData?.eventColor || colorMap.pink // Default color if not found
return {
id: doc.id,
title: data.title,
start: new Date(data.startDate.seconds * 1000),
end: new Date(data.endDate.seconds * 1000),
+29
View 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")
}
})
}