import React from "react"; // headless ui import { Popover } from "@headlessui/react"; // lucide icons import { Calendar, X } from "lucide-react"; // react date picker import DatePicker from "react-datepicker"; // mobx import { observer } from "mobx-react-lite"; // components import { Tooltip } from "@plane/ui"; // hooks import useDynamicDropdownPosition from "hooks/use-dynamic-dropdown"; // helpers import { renderDateFormat } from "helpers/date-time.helper"; export interface IIssuePropertyDate { value: any; onChange: (date: any) => void; disabled?: boolean; placeHolder?: string; } export const IssuePropertyDate: React.FC = observer((props) => { const { value, onChange, disabled, placeHolder } = props; const dropdownBtn = React.useRef(null); const dropdownOptions = React.useRef(null); const [isOpen, setIsOpen] = React.useState(false); useDynamicDropdownPosition(isOpen, () => setIsOpen(false), dropdownBtn, dropdownOptions); return ( {({ open }) => { if (open) { if (!isOpen) setIsOpen(true); } else if (isOpen) setIsOpen(false); return ( <>
{value && ( <>
{value}
{ if (onChange) onChange(null); }} >
)}
{({ close }) => ( { if (onChange && val) { onChange(renderDateFormat(val)); close(); } }} dateFormat="dd-MM-yyyy" calendarClassName="h-full" inline /> )}
); }}
); });