"use client"; import * as React from "react"; import { cn } from "./lib/utils"; export interface MonthPickerProps { value?: number; // 0-11 defaultValue?: number; onValueChange?: (value: number) => void; year?: number; onYearChange?: (year: number) => void; className?: string; } const MONTHS = [ "JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER", ]; export function MonthPicker({ value: controlledValue, defaultValue = new Date().getMonth(), onValueChange, year: controlledYear, onYearChange, className, }: MonthPickerProps) { const year = controlledYear ?? new Date().getFullYear(); const month = controlledValue ?? defaultValue; const [internalMonth, setInternalMonth] = React.useState(month); const [internalYear, setInternalYear] = React.useState(year); const isControlled = controlledValue !== undefined; React.useEffect(() => { if (isControlled) { setInternalMonth(controlledValue!); setInternalYear(controlledYear ?? new Date().getFullYear()); } }, [isControlled, controlledValue, controlledYear]); const prevYear = internalYear - 1; const nextYear = internalYear + 1; const handleMonthSelect = (m: number) => { setInternalMonth(m); onValueChange?.(m); }; const handleYearChange = (y: number) => { setInternalYear(y); onYearChange?.(y); }; return (