import React from "react"; import { Popover, Transition } from "@headlessui/react"; import { CalendarDays, X } from "lucide-react"; // react-datepicker import DatePicker from "react-datepicker"; // import "react-datepicker/dist/react-datepicker.css"; import { renderDateFormat, renderShortDateWithYearFormat } from "helpers/date-time.helper"; type Props = { label: string; maxDate?: Date; minDate?: Date; onChange: (val: string | null) => void; value: string | null; }; export const IssueDateSelect: React.FC = ({ label, maxDate, minDate, onChange, value }) => ( {({ close }) => ( <> {value ? ( <> {renderShortDateWithYearFormat(value)} ) : ( <> {label} )} { if (!val) onChange(""); else onChange(renderDateFormat(val)); close(); }} dateFormat="dd-MM-yyyy" minDate={minDate} maxDate={maxDate} inline /> )} );