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