mirror of
https://github.com/urosran/cally.git
synced 2025-11-26 08:24:55 +00:00
- Default selected attendee when creating events to be the creator of the event
- Added validation to not allow events without any attendees
This commit is contained in:
@ -40,6 +40,7 @@ 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, startOfHour, startOfMinute } from "date-fns";
|
import { addHours, startOfHour, startOfMinute } from "date-fns";
|
||||||
|
import { useAuthContext } from "@/contexts/AuthContext";
|
||||||
|
|
||||||
const daysOfWeek = [
|
const daysOfWeek = [
|
||||||
{ label: "Monday", value: "monday" },
|
{ label: "Monday", value: "monday" },
|
||||||
@ -53,6 +54,7 @@ const daysOfWeek = [
|
|||||||
|
|
||||||
export const ManuallyAddEventModal = () => {
|
export const ManuallyAddEventModal = () => {
|
||||||
const insets = useSafeAreaInsets();
|
const insets = useSafeAreaInsets();
|
||||||
|
const { user } = useAuthContext();
|
||||||
|
|
||||||
const [selectedNewEventDate, setSelectedNewEndDate] = useAtom(
|
const [selectedNewEventDate, setSelectedNewEndDate] = useAtom(
|
||||||
selectedNewEventDateAtom
|
selectedNewEventDateAtom
|
||||||
@ -115,7 +117,7 @@ export const ManuallyAddEventModal = () => {
|
|||||||
editEvent?.end ?? initialDate ?? new Date()
|
editEvent?.end ?? initialDate ?? new Date()
|
||||||
);
|
);
|
||||||
const [selectedAttendees, setSelectedAttendees] = useState<string[]>(
|
const [selectedAttendees, setSelectedAttendees] = useState<string[]>(
|
||||||
editEvent?.attendees ?? []
|
editEvent?.attendees ?? [user?.uid]
|
||||||
);
|
);
|
||||||
const [repeatInterval, setRepeatInterval] = useState<PickerMultiValue>([]);
|
const [repeatInterval, setRepeatInterval] = useState<PickerMultiValue>([]);
|
||||||
|
|
||||||
@ -162,7 +164,7 @@ export const ManuallyAddEventModal = () => {
|
|||||||
|
|
||||||
setStartDate(initialDate ?? new Date());
|
setStartDate(initialDate ?? new Date());
|
||||||
setEndDate(editEvent?.end ?? initialDate ?? new Date());
|
setEndDate(editEvent?.end ?? initialDate ?? new Date());
|
||||||
setSelectedAttendees(editEvent?.attendees ?? []);
|
setSelectedAttendees(editEvent?.attendees ?? [user?.uid]);
|
||||||
setLocation(editEvent?.location ?? "");
|
setLocation(editEvent?.location ?? "");
|
||||||
setRepeatInterval([]);
|
setRepeatInterval([]);
|
||||||
}, [editEvent, selectedNewEventDate]);
|
}, [editEvent, selectedNewEventDate]);
|
||||||
@ -247,10 +249,10 @@ export const ManuallyAddEventModal = () => {
|
|||||||
Alert.alert("Alert", "Title field cannot be empty");
|
Alert.alert("Alert", "Title field cannot be empty");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// if (!selectedAttendees || selectedAttendees?.length === 0) {
|
if (!selectedAttendees || selectedAttendees?.length === 0) {
|
||||||
// Alert.alert('Alert', 'Cannot have an event without any attendees');
|
Alert.alert('Alert', 'Cannot have an event without any attendees');
|
||||||
// return false;
|
return false;
|
||||||
// }
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user