diff --git a/components/pages/calendar/ManuallyAddEventModal.tsx b/components/pages/calendar/ManuallyAddEventModal.tsx index a8c4ece..5ebe038 100644 --- a/components/pages/calendar/ManuallyAddEventModal.tsx +++ b/components/pages/calendar/ManuallyAddEventModal.tsx @@ -2,7 +2,8 @@ import { Button, ButtonSize, Colors, - DateTimePicker, Dialog, + DateTimePicker, + Dialog, LoaderScreen, Modal, 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 {useCreateEvent} from "@/hooks/firebase/useCreateEvent"; import {EventData} from "@/hooks/firebase/types/eventData"; -import DropModalIcon from "@/assets/svgs/DropModalIcon"; import {Alert, StyleSheet} from "react-native"; import ClockIcon from "@/assets/svgs/ClockIcon"; import LockIcon from "@/assets/svgs/LockIcon"; @@ -29,17 +29,12 @@ import MenuIcon from "@/assets/svgs/MenuIcon"; import CameraIcon from "@/assets/svgs/CameraIcon"; import AssigneesDisplay from "@/components/shared/AssigneesDisplay"; import {useAtom} from "jotai"; -import { - eventForEditAtom, - selectedNewEventDateAtom, - isAllDayAtom, -} from "@/components/pages/calendar/atoms"; +import {eventForEditAtom, isAllDayAtom, selectedNewEventDateAtom,} from "@/components/pages/calendar/atoms"; import {useGetFamilyMembers} from "@/hooks/firebase/useGetFamilyMembers"; -import BinIcon from "@/assets/svgs/BinIcon"; import DeleteEventDialog from "./DeleteEventDialog"; import {useDeleteEvent} from "@/hooks/firebase/useDeleteEvent"; 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 {Calendar} from "react-native-calendars"; @@ -233,6 +228,7 @@ export const ManuallyAddEventModal = () => { attendees: selectedAttendees, notes: details, location: location, + private: isPrivate }; if (editEvent?.id) eventData.id = editEvent?.id; diff --git a/hooks/firebase/types/eventData.ts b/hooks/firebase/types/eventData.ts index 9f3a3df..ed7d5f0 100644 --- a/hooks/firebase/types/eventData.ts +++ b/hooks/firebase/types/eventData.ts @@ -12,5 +12,6 @@ export interface EventData { reminders?: string[] id?: string | number, attendees?: string[], - location?: string + location?: string, + private?: boolean } \ No newline at end of file diff --git a/hooks/firebase/useGetEvents.ts b/hooks/firebase/useGetEvents.ts index fe90172..e5147fd 100644 --- a/hooks/firebase/useGetEvents.ts +++ b/hooks/firebase/useGetEvents.ts @@ -27,17 +27,23 @@ const fetchEvents = async (userId: string, profileData: UserProfile | undefined, let constraints; let familyId = profileData?.familyId; - if (isFamilyView || profileData?.userType === ProfileType.FAMILY_DEVICE) { + if (profileData?.userType === ProfileType.FAMILY_DEVICE) { constraints = [ - eventsQuery.where("familyId", "==", familyId).where("private", "==", false), - eventsQuery.where("creatorId", "==", userId), - eventsQuery.where("attendees", "array-contains", userId) + eventsQuery.where("familyId", "==", familyId) ]; } else { - constraints = [ - eventsQuery.where("creatorId", "==", userId), - eventsQuery.where("attendees", "array-contains", userId) - ]; + if (isFamilyView) { + constraints = [ + eventsQuery.where("familyId", "==", familyId), + eventsQuery.where("creatorId", "==", userId), + eventsQuery.where("attendees", "array-contains", userId) + ]; + } else { + constraints = [ + eventsQuery.where("creatorId", "==", userId), + eventsQuery.where("attendees", "array-contains", userId) + ]; + } } const snapshots = await Promise.all(constraints.map(query => query.get()));