import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"; import { useState } from "react"; import { CalendarPopover } from "@/components/ActivityCalendar"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import useCurrentUser from "@/hooks/useCurrentUser"; import { useFilteredMemoStats } from "@/hooks/useFilteredMemoStats"; import i18n from "@/i18n"; import { addMonths, formatMonth, getMonthFromDate, getYearFromDate, setYearAndMonth } from "@/lib/calendar-utils"; import type { MonthNavigatorProps } from "@/types/statistics"; export const MonthNavigator = ({ visibleMonth, onMonthChange }: MonthNavigatorProps) => { const currentUser = useCurrentUser(); const [isOpen, setIsOpen] = useState(false); const currentMonth = new Date(visibleMonth); const currentYear = getYearFromDate(visibleMonth); const currentMonthNum = getMonthFromDate(visibleMonth); const { statistics } = useFilteredMemoStats({ userName: currentUser?.name, }); const handlePrevMonth = () => { onMonthChange(addMonths(visibleMonth, -1)); }; const handleNextMonth = () => { onMonthChange(addMonths(visibleMonth, 1)); }; const handleDateClick = (date: string) => { onMonthChange(formatMonth(date)); setIsOpen(false); }; const handleYearChange = (year: number) => { onMonthChange(setYearAndMonth(year, currentMonthNum)); }; return (
{currentMonth.toLocaleString(i18n.language, { year: "numeric", month: "long" })}
); };