diff --git a/components/Modals/CreateCalendarEvent.tsx b/components/Modals/CreateCalendarEvent.tsx index 512f328..0f9817b 100644 --- a/components/Modals/CreateCalendarEvent.tsx +++ b/components/Modals/CreateCalendarEvent.tsx @@ -44,7 +44,7 @@ export default function CreateCalendarEventModal() { imageUrl, status: imageStatus, } = useImageUpload("event"); - const [error, setError] = useState(""); + const [error, setError] = useState>({}); const [title, setTitle] = useState(""); const [description, setDescription] = useState(""); const [startDate, setStartDate] = useState(now); @@ -81,17 +81,27 @@ export default function CreateCalendarEventModal() { const { currentUser, calendars } = useCurrentUser(); const router = useRouter(); + useEffect(() => { + if (error["title"]) { + if (title) { + setError((prev) => ({ ...prev, title: undefined })); + } + } + }, [title, error]); + async function handleSubmit() { if (!ndk || !currentUser) { alert("MISSING"); return; } - setIsLoading(true); if (!title) { - setError("Please add a title"); + setError({ + title: "Please add a title", + }); return; } + setIsLoading(true); try { const random = randomId(); @@ -169,8 +179,6 @@ export default function CreateCalendarEventModal() { const titleRef = useRef(null); useAutosizeTextArea(titleRef.current, title); - console.log(Intl.DateTimeFormat().resolvedOptions().timeZone); - return (