import { useMemo } from 'react';
import { getStateName } from "../../../utils/election/index.js";
import useDateFormat from "../../../hooks/useDateFormat/index.js";
import { useNowInterval } from "../../../hooks/time/index.js";
export default function useCalendarLabels({
  calendar,
  stateFips
}) {
  const now = useNowInterval(600000); // 10 minutes
  const today = useDateFormat(now, {
    format: '{Y}-{m}-{d}'
  });
  const stateLabel = useMemo(() => {
    if (stateFips) {
      return `${getStateName(stateFips, {
        possessive: true
      })} Elections`;
    }
    return undefined;
  }, [stateFips]);
  const soonLabel = useMemo(() => {
    if (calendar && calendar.electionEvents.some(d => d.date === today)) {
      return 'Voting Today';
    }
    return 'Coming Up';
  }, [now, calendar]);
  return [soonLabel, stateLabel];
}