import { useTranslation } from '../hooks/use-translation';
export const FREQUENCIES = {
  HOURLY: 'HOURLY',
  DAILY: 'DAILY',
  WEEKLY: 'WEEKLY',
  MONTHLY: 'MONTHLY',
  QUARTERLY: 'QUARTERLY',
  YEARLY: 'YEARLY'
};
// the api response values are [0..6], representing the days in order
export function useDaysOfWeek() {
  const {
    t
  } = useTranslation();
  return [{
    index: 0,
    key: 'SUNDAY',
    label: t('Sunday')
  }, {
    index: 1,
    key: 'MONDAY',
    label: t('Monday')
  }, {
    index: 2,
    key: 'TUESDAY',
    label: t('Tuesday')
  }, {
    index: 3,
    key: 'WEDNESDAY',
    label: t('Wednesday')
  }, {
    index: 4,
    key: 'THURSDAY',
    label: t('Thursday')
  }, {
    index: 5,
    key: 'FRIDAY',
    label: t('Friday')
  }, {
    index: 6,
    key: 'SATURDAY',
    label: t('Saturday')
  }];
}

// the api response values are [1..12], representing the months in order
export function useMonths() {
  const {
    t
  } = useTranslation();
  return {
    JANUARY: {
      index: 1,
      key: 'JANUARY',
      label: t('January')
    },
    FEBRUARY: {
      index: 2,
      key: 'FEBRUARY',
      label: t('February')
    },
    MARCH: {
      index: 3,
      key: 'MARCH',
      label: t('March')
    },
    APRIL: {
      index: 4,
      key: 'APRIL',
      label: t('April')
    },
    MAY: {
      index: 5,
      key: 'MAY',
      label: t('May')
    },
    JUNE: {
      index: 6,
      key: 'JUNE',
      label: t('June')
    },
    JULY: {
      index: 7,
      key: 'JULY',
      label: t('July')
    },
    AUGUST: {
      index: 8,
      key: 'AUGUST',
      label: t('August')
    },
    SEPTEMBER: {
      index: 9,
      key: 'SEPTEMBER',
      label: t('September')
    },
    OCTOBER: {
      index: 10,
      key: 'OCTOBER',
      label: t('October')
    },
    NOVEMBER: {
      index: 11,
      key: 'NOVEMBER',
      label: t('November')
    },
    DECEMBER: {
      index: 12,
      key: 'DECEMBER',
      label: t('December')
    }
  };
}
export const DEFAULT_SCHEDULES = {
  // every hour at half past
  [FREQUENCIES.HOURLY]: {
    minute: [30],
    hour: ['*'],
    dayOfWeek: ['*'],
    dayOfMonth: ['*'],
    month: ['*']
  },
  // every day at 18:00
  [FREQUENCIES.DAILY]: {
    minute: [0],
    hour: [18],
    dayOfWeek: ['*'],
    dayOfMonth: ['*'],
    month: ['*']
  },
  // every Monday at 18:00
  [FREQUENCIES.WEEKLY]: {
    minute: [0],
    hour: [18],
    dayOfWeek: [1],
    dayOfMonth: ['*'],
    month: ['*']
  },
  // every month on the 1st and 15th days at 18:00
  [FREQUENCIES.MONTHLY]: {
    minute: [0],
    hour: [18],
    dayOfWeek: ['*'],
    dayOfMonth: [1, 15],
    month: ['*']
  },
  // every 1st of january, april, july, and october at 18:00
  [FREQUENCIES.QUARTERLY]: {
    minute: [0],
    hour: [18],
    dayOfWeek: ['*'],
    dayOfMonth: [1],
    month: [1, 4, 7, 10]
  },
  // every 1st of january at 18:00
  [FREQUENCIES.YEARLY]: {
    minute: [0],
    hour: [18],
    dayOfWeek: ['*'],
    dayOfMonth: [1],
    month: [1]
  }
};
export const FIELD_BOUNDARIES = {
  minute: {
    min: 0,
    max: 59
  },
  hour: {
    min: 0,
    max: 23
  },
  dayOfMonth: {
    min: 1,
    max: 31
  },
  month: {
    min: 1,
    max: 12
  },
  dayOfWeek: {
    min: 0,
    // Sunday
    max: 6 // Saturday
  }
};

// arbitrarily selected, we just need some value that guarantees a simple schedule
export const DEFAULT_SCHEDULE = DEFAULT_SCHEDULES[FREQUENCIES.DAILY];
export function useFrequencyOptions() {
  const {
    t
  } = useTranslation();
  return [{
    key: FREQUENCIES.HOURLY,
    title: t('Every hour'),
    testId: 'HOURLY'
  }, {
    key: FREQUENCIES.DAILY,
    title: t('Every day'),
    testId: 'DAILY'
  }, {
    key: FREQUENCIES.WEEKLY,
    title: t('Every week'),
    testId: 'WEEKLY'
  }, {
    key: FREQUENCIES.MONTHLY,
    title: t('Every month'),
    testId: 'MONTHLY'
  }, {
    key: FREQUENCIES.QUARTERLY,
    title: t('Every quarter'),
    testId: 'QUARTERLY'
  }, {
    key: FREQUENCIES.YEARLY,
    title: t('Every year'),
    testId: 'YEARLY'
  }];
}
export const SWITCHER_TYPES = {
  TABS: 'tabs',
  BUTTON: 'button'
};
export const TAB_KEYS = {
  SIMPLE: 'SIMPLE',
  ADVANCED: 'ADVANCED'
};
export const useDefaultTexts = () => {
  const {
    t
  } = useTranslation();
  const defaultSimpleSchedulerToggleButtonText = t('Use simple scheduler');
  const defaultAdvancedSchedulerToggleButtonText = t('Use advanced scheduler');
  const defaultSimpleSchedulerModalTexts = {
    title: t('Use simple scheduler?'),
    confirmButtonText: t('Switch to simple scheduler'),
    dismissButtonText: t('Stay with advanced scheduler'),
    content: t('Switching to the simple scheduler form will clear any schedule you set so far.'),
    labelText: t('Close')
  };
  const defaultLabelTexts = {
    minute: t('Minute'),
    hour: t('Hour'),
    dayOfMonth: t('Day of month'),
    month: t('Month'),
    dayOfWeek: t('Day of week'),
    minutesPastHour: t('Minutes past the hour'),
    time: t('Time'),
    days: t('Days'),
    months: t('Months'),
    frequency: t('Frequency')
  };
  const defaultAdvancedSchedulerInfoTexts = {
    dayOfMonth: t('Accepts values from 1 to 31. Invalid values for a given month will be ignored.'),
    month: t('Accepts values between 1 (January) and 12 (December).'),
    dayOfWeek: t('Accepts values between 0 (Sunday) and 6 (Saturday).')
  };
  const defaultValidationTexts = {
    timeError: t('Value must have both hours and minutes specified'),
    minuteError: t('Value must be a number between 0 and 59')
  };
  const defaultTabTexts = {
    simpleScheduleLabel: t('Simple schedule'),
    advancedScheduleLabel: t('Advanced schedule'),
    simpleScheduleTooltip: t("Switching to the simple scheduler will clear any schedule you've set so far")
  };
  return {
    defaultSimpleSchedulerToggleButtonText,
    defaultAdvancedSchedulerToggleButtonText,
    defaultSimpleSchedulerModalTexts,
    defaultLabelTexts,
    defaultAdvancedSchedulerInfoTexts,
    defaultValidationTexts,
    defaultTabTexts
  };
};