/* eslint-disable object-curly-newline */ import React from 'react'; import { Divider, Grid, Paper, Typography } from '@mui/material'; import {differenceInCalendarMonths, format} from 'date-fns'; import ArrowRightAlt from '@mui/icons-material/ArrowRightAlt'; import Month from './Month'; import DefinedRanges from './DefinedRanges'; import { DateRange, DefinedRange, Setter, NavigationAction, } from '../types'; import { MARKERS } from './Markers'; interface MenuProps { dateRange: DateRange; ranges: DefinedRange[]; minDate: Date; maxDate: Date; firstMonth: Date; secondMonth: Date; setFirstMonth: Setter; setSecondMonth: Setter; setDateRange: Setter; helpers: { // eslint-disable-next-line no-unused-vars inHoverRange: (day: Date) => boolean; }; handlers: { // eslint-disable-next-line no-unused-vars onDayClick: (day: Date) => void; // eslint-disable-next-line no-unused-vars onDayHover: (day: Date) => void; // eslint-disable-next-line no-unused-vars onMonthNavigate: (marker: symbol, action: NavigationAction) => void; }; locale?: Locale; } const Menu: React.FunctionComponent = (props: MenuProps) => { const { ranges, dateRange, minDate, maxDate, firstMonth, setFirstMonth, secondMonth, setSecondMonth, setDateRange, helpers, handlers, locale } = props; const { startDate, endDate } = dateRange; const canNavigateCloser = differenceInCalendarMonths(secondMonth, firstMonth) >= 2; const commonProps = { dateRange, minDate, maxDate, helpers, handlers, }; return ( {startDate ? format(startDate, 'dd MMMM yyyy', {locale}) : 'Start Date'} {endDate ? format(endDate, 'dd MMMM yyyy', {locale}) : 'End Date'} ); }; export default Menu;