mirror of
https://github.com/urosran/cally.git
synced 2025-11-26 16:34:54 +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 { 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 DropModalIcon from "@/assets/svgs/DropModalIcon";
|
||||||
import { 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";
|
||||||
import MenuIcon from "@/assets/svgs/MenuIcon";
|
import MenuIcon from "@/assets/svgs/MenuIcon";
|
||||||
@ -266,12 +266,29 @@ export const ManuallyAddEventModal = () => {
|
|||||||
|
|
||||||
if (editEvent?.id) eventData.id = editEvent?.id;
|
if (editEvent?.id) eventData.id = editEvent?.id;
|
||||||
|
|
||||||
|
if (validateEvent()) {
|
||||||
await createEvent(eventData);
|
await createEvent(eventData);
|
||||||
setEditEvent(undefined);
|
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 getRepeatLabel = () => {
|
||||||
const selectedDays = repeatInterval;
|
const selectedDays = repeatInterval;
|
||||||
const allDays = [
|
const allDays = [
|
||||||
|
|||||||
Reference in New Issue
Block a user