diff --git a/src/app/(client-components)/(HeroSearchForm)/(experiences-search-form)/ExperiencesDateSingleInput.tsx b/src/app/(client-components)/(HeroSearchForm)/(experiences-search-form)/ExperiencesDateSingleInput.tsx new file mode 100644 index 0000000..705f222 --- /dev/null +++ b/src/app/(client-components)/(HeroSearchForm)/(experiences-search-form)/ExperiencesDateSingleInput.tsx @@ -0,0 +1,119 @@ +"use client"; + +import React, { Fragment, useState } from "react"; +import { FC } from "react"; +import DatePicker from "react-datepicker"; +import { Popover, Transition } from "@headlessui/react"; +import { CalendarIcon } from "@heroicons/react/24/outline"; +import DatePickerCustomHeaderTwoMonth from "@/components/DatePickerCustomHeaderTwoMonth"; +import DatePickerCustomDay from "@/components/DatePickerCustomDay"; +import ClearDataButton from "../ClearDataButton"; + +export interface ExperiencesDateSingleInputProps { + className?: string; + fieldClassName?: string; +} + +const ExperiencesDateSingleInput: FC = ({ + className = "", + fieldClassName = "[ nc-hero-field-padding ]", +}) => { + const [startDate, setStartDate] = useState( + new Date("2023/03/01") + ); + const [endDate, setEndDate] = useState(new Date("2023/03/16")); + + const onChangeDate = (dates: [Date | null, Date | null]) => { + const [start, end] = dates; + setStartDate(start); + setEndDate(end); + }; + + const renderInput = () => { + return ( + <> +
+ +
+
+ + {startDate?.toLocaleDateString("en-US", { + month: "short", + day: "2-digit", + }) || "Date"} + {endDate + ? " - " + + endDate?.toLocaleDateString("en-US", { + month: "short", + day: "2-digit", + }) + : ""} + + + {startDate ? "Date" : `Add dates`} + +
+ + ); + }; + + return ( + <> + + {({ open }) => ( + <> + + {renderInput()} + {startDate && open && ( + onChangeDate([null, null])} /> + )} + + + {open && ( +
+ )} + + + +
+ ( + + )} + renderDayContents={(day, date) => ( + + )} + /> +
+
+
+ + )} +
+ + ); +}; + +export default ExperiencesDateSingleInput;