mirror of
https://github.com/urosran/cally.git
synced 2025-07-16 01:56:16 +00:00
- Added validation for title and attendees when creation/updating event
This commit is contained in:
@ -22,7 +22,7 @@ import { PickerMultiValue } from "react-native-ui-lib/src/components/picker/type
|
||||
import { useCreateEvent } from "@/hooks/firebase/useCreateEvent";
|
||||
import { EventData } from "@/hooks/firebase/types/eventData";
|
||||
import DropModalIcon from "@/assets/svgs/DropModalIcon";
|
||||
import { StyleSheet } from "react-native";
|
||||
import {Alert, StyleSheet} from "react-native";
|
||||
import ClockIcon from "@/assets/svgs/ClockIcon";
|
||||
import LockIcon from "@/assets/svgs/LockIcon";
|
||||
import MenuIcon from "@/assets/svgs/MenuIcon";
|
||||
@ -266,12 +266,29 @@ export const ManuallyAddEventModal = () => {
|
||||
|
||||
if (editEvent?.id) eventData.id = editEvent?.id;
|
||||
|
||||
await createEvent(eventData);
|
||||
setEditEvent(undefined);
|
||||
if (validateEvent()) {
|
||||
await createEvent(eventData);
|
||||
setEditEvent(undefined);
|
||||
|
||||
close();
|
||||
close();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
const validateEvent = () => {
|
||||
if (!title) {
|
||||
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;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const getRepeatLabel = () => {
|
||||
const selectedDays = repeatInterval;
|
||||
const allDays = [
|
||||
|
Reference in New Issue
Block a user