diff --git a/src/components/ModalSelectDate.tsx b/src/components/ModalSelectDate.tsx new file mode 100644 index 0000000..96c8119 --- /dev/null +++ b/src/components/ModalSelectDate.tsx @@ -0,0 +1,142 @@ +"use client"; + +import DatePicker from "react-datepicker"; +import { Dialog, Transition } from "@headlessui/react"; +import { XMarkIcon } from "@heroicons/react/24/solid"; +import React, { FC, Fragment, useEffect, useState } from "react"; +import ButtonPrimary from "@/shared/ButtonPrimary"; +import DatePickerCustomHeaderTwoMonth from "./DatePickerCustomHeaderTwoMonth"; +import DatePickerCustomDay from "./DatePickerCustomDay"; + +interface ModalSelectDateProps { + renderChildren?: (p: { openModal: () => void }) => React.ReactNode; +} + +const ModalSelectDate: FC = ({ renderChildren }) => { + const [showModal, setShowModal] = useState(false); + + const [startDate, setStartDate] = useState( + new Date("2023/02/06") + ); + const [endDate, setEndDate] = useState(new Date("2023/02/23")); + + const onChangeDate = (dates: [Date | null, Date | null]) => { + const [start, end] = dates; + setStartDate(start); + setEndDate(end); + }; + + // FOR RESET ALL DATA WHEN CLICK CLEAR BUTTON + // + function closeModal() { + setShowModal(false); + } + + function openModal() { + setShowModal(true); + } + + const renderButtonOpenModal = () => { + return renderChildren ? ( + renderChildren({ openModal }) + ) : ( + + ); + }; + + return ( + <> + {renderButtonOpenModal()} + + +
+
+ + + <> +
+ +
+ +
+
+
+
+ + {` When's your trip?`} + +
+
+
+ ( + + )} + renderDayContents={(day, date) => ( + + )} + /> +
+
+
+
+
+
+ + { + closeModal(); + }} + > + Save + +
+ +
+
+
+
+
+
+ + ); +}; + +export default ModalSelectDate;