"use client"; import { useState, useRef, useEffect } from "react"; import Template from "./Template"; import { Textarea } from "@/components/ui/textarea"; import useAutosizeTextArea from "@/lib/hooks/useAutoSizeTextArea"; import { Button } from "@/components/ui/button"; import { HiX } from "react-icons/hi"; import { cn } from "@/lib/utils"; import { addMinutesToDate, convertToTimezoneDate, convertToTimezone, } from "@/lib/utils/dates"; import { DatePicker } from "@/components/ui/date-picker"; import { TimePicker } from "@/components/ui/time-picker"; import { TimezoneSelector } from "../ui/timezone"; import SmallCalendarIcon from "../EventIcons/DateIcon"; import LocationIcon from "../EventIcons/LocationIcon"; import LocationSearchInput from "../LocationSearch"; import { useModal } from "@/app/_providers/modal/provider"; export default function CreateCalendarEventModal() { const modal = useModal(); const now = new Date(new Date().setHours(12, 0, 0, 0)); const [title, setTitle] = useState(""); const [startDate, setStartDate] = useState(now); const startTime = `${ startDate?.getHours().toLocaleString().length === 1 ? "0" + startDate?.getHours().toLocaleString() : startDate?.getHours() }:${ startDate?.getMinutes().toLocaleString().length === 1 ? "0" + startDate?.getMinutes().toLocaleString() : startDate?.getMinutes() }`; const [endDate, setEndDate] = useState( new Date(new Date().setHours(13)), ); const endTime = `${ endDate?.getHours().toLocaleString().length === 1 ? "0" + endDate?.getHours().toLocaleString() : endDate?.getHours() }:${ endDate?.getMinutes().toLocaleString().length === 1 ? "0" + endDate?.getMinutes().toLocaleString() : endDate?.getMinutes() }`; const [timezone, setTimezone] = useState( Intl.DateTimeFormat().resolvedOptions().timeZone, ); const [location, setLocation] = useState<{ address: string; name: string; coordinates: { lat: number; lng: number }; }>(); useEffect(() => { if (startDate && endDate) { if (startDate.getTime() > endDate.getTime()) { setEndDate(addMinutesToDate(startDate, 60)); } } }, [startDate]); const titleRef = useRef(null); useAutosizeTextArea(titleRef.current, title); console.log(Intl.DateTimeFormat().resolvedOptions().timeZone); return (