import { useState, useCallback } from 'react'

const DEFAULT_MONTH = '2026-04'

export function useMonthParam() {
  const [month, setMonth] = useState(DEFAULT_MONTH)

  const monthParam = useCallback(() => {
    return { month }
  }, [month])

  const monthForApi = month.length === 7 ? month : month.substring(0, 7)

  return { month: monthForApi, setMonth, monthParam }
}

export type RangeMode = 'month' | 'quarter' | 'halfyear' | 'year' | 'custom'

export function useRangeMode() {
  const [rangeMode, setRangeMode] = useState<RangeMode>('month')
  return { rangeMode, setRangeMode }
}
