diff --git a/components/ui/modal/SetTimesModal.tsx b/components/ui/modal/SetTimesModal.tsx index ea8d9483..25e20229 100644 --- a/components/ui/modal/SetTimesModal.tsx +++ b/components/ui/modal/SetTimesModal.tsx @@ -2,7 +2,7 @@ import { ClockIcon } from "@heroicons/react/outline"; import { useRef } from "react"; import { useLocale } from "@lib/hooks/useLocale"; - +import showToast from "@lib/notification"; import Button from "@components/ui/Button"; interface SetTimesModalProps { @@ -21,6 +21,18 @@ export default function SetTimesModal(props: SetTimesModalProps) { const endHoursRef = useRef(null!); const endMinsRef = useRef(null!); + const isValidTime = (startTime: number, endTime: number) => { + if (new Date(startTime) > new Date(endTime)) { + showToast(t("error_end_time_before_start_time"), "error"); + return false; + } + if (endTime > 1440) { + showToast(t("error_end_time_next_day"), "error"); + return false; + } + return true; + }; + return (
{t("save")} diff --git a/public/static/locales/en/common.json b/public/static/locales/en/common.json index 8711346e..08751484 100644 --- a/public/static/locales/en/common.json +++ b/public/static/locales/en/common.json @@ -251,6 +251,7 @@ "friday_time_error":"Invalid time on Friday", "saturday_time_error":"Invalid time on Saturday", "error_end_time_before_start_time": "End time cannot be before start time", + "error_end_time_next_day": "End time cannot be greater than 24 hours", "back_to_bookings": "Back to bookings", "free_to_pick_another_event_type": "Feel free to pick another event anytime.", "cancelled": "Cancelled",