2021-09-27 21:12:55 +00:00
|
|
|
// @see: https://github.com/wojtekmaj/react-daterange-picker/issues/91
|
|
|
|
import { ArrowRightIcon, CalendarIcon } from "@heroicons/react/solid";
|
|
|
|
import "@wojtekmaj/react-daterange-picker/dist/DateRangePicker.css";
|
|
|
|
import PrimitiveDateRangePicker from "@wojtekmaj/react-daterange-picker/dist/entry.nostyle";
|
|
|
|
import React from "react";
|
|
|
|
import "react-calendar/dist/Calendar.css";
|
|
|
|
|
|
|
|
type Props = {
|
2021-09-29 21:33:18 +00:00
|
|
|
startDate: Date;
|
|
|
|
endDate: Date;
|
2021-09-27 21:12:55 +00:00
|
|
|
onDatesChange?: ((arg: { startDate: Date; endDate: Date }) => void) | undefined;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const DateRangePicker = ({ startDate, endDate, onDatesChange }: Props) => {
|
|
|
|
return (
|
|
|
|
<PrimitiveDateRangePicker
|
2022-04-14 14:58:23 +00:00
|
|
|
className="rounded-sm border-gray-300 sm:text-sm"
|
2021-09-27 21:12:55 +00:00
|
|
|
clearIcon={null}
|
|
|
|
calendarIcon={<CalendarIcon className="h-5 w-5 text-gray-500" />}
|
2022-02-01 22:17:37 +00:00
|
|
|
rangeDivider={<ArrowRightIcon className="h-4 w-4 text-gray-400 ltr:mr-2 rtl:ml-2" />}
|
2021-09-27 21:12:55 +00:00
|
|
|
value={[startDate, endDate]}
|
|
|
|
onChange={([startDate, endDate]) => {
|
2022-02-09 00:05:13 +00:00
|
|
|
if (typeof onDatesChange === "function") onDatesChange({ startDate, endDate });
|
2021-09-27 21:12:55 +00:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|