Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Dejan
2024-10-20 18:34:56 +02:00
13 changed files with 130 additions and 351 deletions
+21 -2
View File
@@ -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: () => {
+8
View File
@@ -53,6 +53,13 @@ export const useGetEvents = () => {
index === self.findIndex(e => e.id === event.id)
);
allEvents = allEvents.filter(event => {
if (event.private) {
return event.creatorId === userId;
}
return true;
});
return await Promise.all(
allEvents.map(async (event) => {
const profileSnapshot = await db
@@ -70,6 +77,7 @@ export const useGetEvents = () => {
end: new Date(event.endDate.seconds * 1000),
hideHours: event.allDay,
eventColor: eventColor,
notes: event.notes
};
})
);