"use client" import { useState } from "react" import { DayPicker } from "react-day-picker" import { useIntl } from "react-intl" import { Lang } from "@/constants/languages" import { dt } from "@/lib/dt" import { ChevronLeftIcon } from "@/components/Icons" import Button from "@/components/TempDesignSystem/Button" import Divider from "@/components/TempDesignSystem/Divider" import Caption from "@/components/TempDesignSystem/Text/Caption" import Subtitle from "@/components/TempDesignSystem/Text/Subtitle" import useLang from "@/hooks/useLang" import styles from "./desktop.module.css" import classNames from "react-day-picker/style.module.css" import type { DatePickerProps } from "@/types/components/datepicker" export default function DatePickerDesktop({ close, handleOnSelect, locales, selectedDate, }: DatePickerProps) { const lang = useLang() const intl = useIntl() const [month, setMonth] = useState(new Date()) /** English is default language and doesn't need to be imported */ const locale = lang === Lang.en ? undefined : locales[lang] const currentDate = dt().toDate() const startOfMonth = dt(currentDate).set("date", 1).toDate() const yesterday = dt(currentDate).subtract(1, "day").toDate() // Max future date allowed to book kept same as of existing prod. const endDate = dt().add(395, "day").toDate() const endOfLastMonth = dt(endDate).endOf("month").toDate() function handleMonthChange(selected: Date) { setMonth(selected) } return ( ) }, Footer(props) { return ( <>
) }, MonthCaption(props) { return (
{props.children}
) }, Nav(props) { if (Array.isArray(props.children)) { const prevButton = props.children?.[0] const nextButton = props.children?.[1] return ( <> {prevButton ? ( ) : null} {nextButton ? ( ) : null} ) } return <> }, }} /> ) }