import React from 'react'; import { Paper, Grid, Typography, Divider, makeStyles, // eslint-disable-next-line no-unused-vars Theme, } from '@material-ui/core'; import { format, differenceInCalendarMonths } from 'date-fns'; import ArrowRightAlt from '@material-ui/icons/ArrowRightAlt'; import Month from './Month'; import DefinedRanges from './DefinedRanges'; import { // eslint-disable-next-line no-unused-vars DateRange, // eslint-disable-next-line no-unused-vars DefinedRange, // eslint-disable-next-line no-unused-vars Setter, // eslint-disable-next-line no-unused-vars NavigationAction, } from '../types'; import { MARKERS } from './DateRangePicker'; const useStyles = makeStyles((theme: Theme) => ({ header: { padding: '20px 70px', }, headerItem: { flex: 1, textAlign: 'center', }, divider: { borderLeft: `1px solid ${theme.palette.action.hover}`, marginBottom: 20, }, })); interface MenuProps { dateRange: DateRange; ranges: DefinedRange[]; minDate: Date; maxDate: Date; firstMonth: Date; secondMonth: Date; setFirstMonth: Setter; setSecondMonth: Setter; setDateRange: Setter; helpers: { inHoverRange: (day: Date) => boolean; }; handlers: { onDayClick: (day: Date) => void; onDayHover: (day: Date) => void; onMonthNavigate: (marker: symbol, action: NavigationAction) => void; }; } const Menu: React.FunctionComponent = (props: MenuProps) => { const classes = useStyles(); const { ranges, dateRange, minDate, maxDate, firstMonth, setFirstMonth, secondMonth, setSecondMonth, setDateRange, helpers, handlers, } = props; const { startDate, endDate } = dateRange; const canNavigateCloser = differenceInCalendarMonths(secondMonth, firstMonth) >= 2; const commonProps = { dateRange, minDate, maxDate, helpers, handlers, }; return ( {startDate ? format(startDate, 'MMMM DD, YYYY') : 'Start Date'} {endDate ? format(endDate, 'MMMM DD, YYYY') : 'End Date'}
); }; export default Menu;