import { type PillsProps } from '@material-hu/components/design-system/Pills/types';

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

import { type SessionDetail, type SessionsTabsType } from './types';

export const getSessionsTabs = (t: LokaliseTFunction) => {
  return [
    {
      label: t('session.status.upcoming'),
      value: 'PUBLISHED',
    },
    {
      label: t('session.status.finished_other'),
      value: 'FINISHED',
    },
  ] as { label: string; value: SessionsTabsType }[];
};

export const getPillStatus = (
  session: SessionDetail,
  t: LokaliseTFunction,
): Pick<PillsProps, 'label' | 'type' | 'hasIcon'> => {
  if (session.status === 'IN_PROGRESS') {
    return {
      label: t('general:states.in_progress'),
      type: 'highlight',
    };
  }

  if (session.status === 'FINISHED') {
    return {
      label: `${t('session.title')} ${t('session.status.finished_one').toLowerCase()}`,
      type: 'info',
    };
  }

  if (session.confirmedAssistance) {
    return {
      label: t('session.attendance.confirmed'),
      type: 'success',
      hasIcon: true,
    };
  }

  return {
    label: t('session.attendance.pending'),
    type: 'warning',
  };
};

export const showCertificate = (session: SessionDetail) => {
  return session.assisted && session.issueCertificate;
};
