import { createContext, type Dispatch } from 'react' export interface AppState { selectedYear: string selectedMonth: string } export type AppAction = | { type: 'SET_YEAR'; year: string } | { type: 'SET_MONTH'; month: string } export const initialState: AppState = (() => { const now = new Date() return { selectedYear: now.getFullYear().toString(), selectedMonth: (now.getMonth() + 1).toString().padStart(2, '0'), } })() export const AppCtx = createContext<{ state: AppState dispatch: Dispatch }>({ state: initialState, dispatch: () => {} })