mirror of
https://github.com/urosran/cally.git
synced 2025-07-17 02:25:10 +00:00
Fix editing events
This commit is contained in:
@ -11,11 +11,30 @@ export const useCreateEvent = () => {
|
||||
mutationKey: ["createEvent"],
|
||||
mutationFn: async (eventData: Partial<EventData>) => {
|
||||
try {
|
||||
if (eventData.id) {
|
||||
const snapshot = await firestore()
|
||||
.collection("Events")
|
||||
.where("id", "==", eventData.id)
|
||||
.get();
|
||||
|
||||
if (!snapshot.empty) {
|
||||
const docId = snapshot.docs[0].id;
|
||||
await firestore()
|
||||
.collection("Events")
|
||||
.doc(docId)
|
||||
.set({
|
||||
...eventData,
|
||||
creatorId: currentUser?.uid,
|
||||
familyId: profileData?.familyId
|
||||
}, {merge: true});
|
||||
return;
|
||||
}
|
||||
}
|
||||
await firestore()
|
||||
.collection("Events")
|
||||
.add({...eventData, creatorId: currentUser?.uid, familyId: profileData?.familyId})
|
||||
.add({...eventData, creatorId: currentUser?.uid, familyId: profileData?.familyId});
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
console.error(e);
|
||||
}
|
||||
},
|
||||
onSuccess: () => {
|
||||
|
Reference in New Issue
Block a user