import { CalendarApi } from '@fullcalendar/core' import { IconButton, Stack } from '@linagora/twake-mui' import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown' import ArrowDropUpIcon from '@mui/icons-material/ArrowDropUp' import MenuIcon from '@mui/icons-material/Menu' import React, { useState } from 'react' import { useI18n } from 'twake-i18n' import SearchBar from './EventSearchBar' import './Menubar.styl' import { DatePickerMobile } from './components/DatePickerMobile' import { Typography } from '@mui/material' import { SmallNavigationControls } from './components/SmallNavigationControls' export type MobileMenubarProps = { calendarRef: React.RefObject currentDate: Date onDateChange?: (date: Date) => void handleNavigation: (action: 'prev' | 'next' | 'today') => void onOpenSidebar: () => void } export const MobileMenubar: React.FC = ({ calendarRef, currentDate, onDateChange, handleNavigation, onOpenSidebar }) => { const { t } = useI18n() const [openDatePicker, setOpenDatePicker] = useState(false) // Use i18n for month names instead of date-fns const monthIndex = currentDate.getMonth() const year = currentDate.getFullYear() const monthName = t(`months.standalone.${monthIndex}`) const dateLabel = `${monthName} ${year}` const onToggleDatePicker = (): void => { setOpenDatePicker(prev => { const newState = !prev setTimeout(() => { calendarRef.current?.updateSize?.() }, 0) return newState }) } return ( <>
{dateLabel} {openDatePicker ? : }
{openDatePicker ? ( setOpenDatePicker(false)} /> ) : null} ) }