Merge branch 'dev'

This commit is contained in:
Milan Paunovic
2025-01-19 15:28:00 +01:00
3 changed files with 21 additions and 18 deletions

View File

@ -2,7 +2,8 @@ import {
Button, Button,
ButtonSize, ButtonSize,
Colors, Colors,
DateTimePicker, Dialog, DateTimePicker,
Dialog,
LoaderScreen, LoaderScreen,
Modal, Modal,
Picker, Picker,
@ -21,7 +22,6 @@ import {AntDesign, Feather, Ionicons} from "@expo/vector-icons";
import {PickerMultiValue} from "react-native-ui-lib/src/components/picker/types"; import {PickerMultiValue} from "react-native-ui-lib/src/components/picker/types";
import {useCreateEvent} from "@/hooks/firebase/useCreateEvent"; import {useCreateEvent} from "@/hooks/firebase/useCreateEvent";
import {EventData} from "@/hooks/firebase/types/eventData"; import {EventData} from "@/hooks/firebase/types/eventData";
import DropModalIcon from "@/assets/svgs/DropModalIcon";
import {Alert, StyleSheet} from "react-native"; import {Alert, StyleSheet} from "react-native";
import ClockIcon from "@/assets/svgs/ClockIcon"; import ClockIcon from "@/assets/svgs/ClockIcon";
import LockIcon from "@/assets/svgs/LockIcon"; import LockIcon from "@/assets/svgs/LockIcon";
@ -29,17 +29,12 @@ import MenuIcon from "@/assets/svgs/MenuIcon";
import CameraIcon from "@/assets/svgs/CameraIcon"; import CameraIcon from "@/assets/svgs/CameraIcon";
import AssigneesDisplay from "@/components/shared/AssigneesDisplay"; import AssigneesDisplay from "@/components/shared/AssigneesDisplay";
import {useAtom} from "jotai"; import {useAtom} from "jotai";
import { import {eventForEditAtom, isAllDayAtom, selectedNewEventDateAtom,} from "@/components/pages/calendar/atoms";
eventForEditAtom,
selectedNewEventDateAtom,
isAllDayAtom,
} from "@/components/pages/calendar/atoms";
import {useGetFamilyMembers} from "@/hooks/firebase/useGetFamilyMembers"; import {useGetFamilyMembers} from "@/hooks/firebase/useGetFamilyMembers";
import BinIcon from "@/assets/svgs/BinIcon";
import DeleteEventDialog from "./DeleteEventDialog"; import DeleteEventDialog from "./DeleteEventDialog";
import {useDeleteEvent} from "@/hooks/firebase/useDeleteEvent"; import {useDeleteEvent} from "@/hooks/firebase/useDeleteEvent";
import AddPersonIcon from "@/assets/svgs/AddPersonIcon"; import AddPersonIcon from "@/assets/svgs/AddPersonIcon";
import {addHours, format, startOfHour, startOfMinute} from "date-fns"; import {addHours, format, startOfMinute} from "date-fns";
import {ProfileType, useAuthContext} from "@/contexts/AuthContext"; import {ProfileType, useAuthContext} from "@/contexts/AuthContext";
import {Calendar} from "react-native-calendars"; import {Calendar} from "react-native-calendars";
@ -233,6 +228,7 @@ export const ManuallyAddEventModal = () => {
attendees: selectedAttendees, attendees: selectedAttendees,
notes: details, notes: details,
location: location, location: location,
private: isPrivate
}; };
if (editEvent?.id) eventData.id = editEvent?.id; if (editEvent?.id) eventData.id = editEvent?.id;

View File

@ -12,5 +12,6 @@ export interface EventData {
reminders?: string[] reminders?: string[]
id?: string | number, id?: string | number,
attendees?: string[], attendees?: string[],
location?: string location?: string,
private?: boolean
} }

View File

@ -27,9 +27,14 @@ const fetchEvents = async (userId: string, profileData: UserProfile | undefined,
let constraints; let constraints;
let familyId = profileData?.familyId; let familyId = profileData?.familyId;
if (isFamilyView || profileData?.userType === ProfileType.FAMILY_DEVICE) { if (profileData?.userType === ProfileType.FAMILY_DEVICE) {
constraints = [ constraints = [
eventsQuery.where("familyId", "==", familyId).where("private", "==", false), eventsQuery.where("familyId", "==", familyId)
];
} else {
if (isFamilyView) {
constraints = [
eventsQuery.where("familyId", "==", familyId),
eventsQuery.where("creatorId", "==", userId), eventsQuery.where("creatorId", "==", userId),
eventsQuery.where("attendees", "array-contains", userId) eventsQuery.where("attendees", "array-contains", userId)
]; ];
@ -39,6 +44,7 @@ const fetchEvents = async (userId: string, profileData: UserProfile | undefined,
eventsQuery.where("attendees", "array-contains", userId) eventsQuery.where("attendees", "array-contains", userId)
]; ];
} }
}
const snapshots = await Promise.all(constraints.map(query => query.get())); const snapshots = await Promise.all(constraints.map(query => query.get()));