import { secondsToMilliseconds } from 'date-fns';
import { parseAsInteger, parseAsString, parseAsStringEnum } from 'nuqs';

import { LokaliseTFunction } from 'src/utils/i18n';

import { JourneyProgressStatus, JourneyProgressStatusType } from './types';
import {
  JourneyTaskExpirationStatusType,
  JourneyTaskExpirationStatus,
} from './types';

export const EMPLOYEE_LIFECYCLE_STALE_TIME = secondsToMilliseconds(60);
export const PAGE_SIZE = 10;

export const employeeLifecycleFilterState = {
  progressStatus: parseAsStringEnum<JourneyProgressStatusType>(
    Object.values(JourneyProgressStatus),
  ),
  expirationStatus: parseAsStringEnum<JourneyTaskExpirationStatusType>(
    Object.values(JourneyTaskExpirationStatus),
  ),
  search: parseAsString,
  collaborators: parseAsString,
  offset: parseAsInteger.withDefault(0),
  limit: parseAsInteger.withDefault(PAGE_SIZE),
};

export const getJourneyFilterChips = (t: LokaliseTFunction) => {
  return [
    {
      value: 'ALL' as const,
      label: t('journeys.progress_status.ALL'),
    },
    {
      value: JourneyProgressStatus.NOT_STARTED,
      label: t('journeys.progress_status.NOT_STARTED'),
    },
    {
      value: JourneyProgressStatus.IN_PROGRESS,
      label: t('journeys.progress_status.IN_PROGRESS'),
    },
    {
      value: JourneyProgressStatus.DONE,
      label: t('journeys.progress_status.DONE'),
    },
  ];
};

export const getTaskFilterChips = (t: LokaliseTFunction) => {
  return [
    {
      value: 'ALL' as const,
      label: t('expiration_status_filter.ALL'),
    },
    {
      value: JourneyTaskExpirationStatus.NOT_EXPIRED,
      label: t('expiration_status_filter.NOT_EXPIRED'),
    },
    {
      value: JourneyTaskExpirationStatus.EXPIRED,
      label: t('expiration_status_filter.EXPIRED'),
    },
    {
      value: JourneyTaskExpirationStatus.NO_EXPIRATION,
      label: t('expiration_status_filter.NO_EXPIRATION'),
    },
  ];
};
