import { ErrorCode } from 'src/constants/exceptions';

import { LokaliseTFunction } from './i18n';

export const getResetPasswordErrorMessage = (
  t: LokaliseTFunction,
  errorCode: string,
) => {
  if (errorCode === ErrorCode.INVALID_DATA) {
    return t('INVITE_CODE_NOT_FOUND');
  }
  if (errorCode === ErrorCode.MISSING_USER_EMAIL) {
    return t('MISSING_USER_EMAIL');
  }
  return t('RESET_PASSWORD_GENERAL_ERROR');
};

export const getMessageToRecoverPassword = (
  t: LokaliseTFunction,
  userHasEmail: boolean,
) =>
  userHasEmail
    ? { title: t('EMAIL_SENT_TO_YOU') }
    : {
        title: t('EMAIL_SENT_TO_ADMIN'),
        description: t('EMAIL_SENT_TO_ADMIN_DESC'),
      };

export const getTermsOfUseAndPrivacyLink: (language: string) => {
  termsOfUseHref: string;
  privacyPolicyHref: string;
} = (language: string) => {
  if (language === 'es') {
    return {
      termsOfUseHref: 'https://humand.co/es/terminos-de-uso/',
      privacyPolicyHref: 'https://humand.co/es/politica-de-privacidad/',
    };
  } else if (language === 'pt' || language === 'pt-BR') {
    return {
      termsOfUseHref: 'https://humand.co/pt/termos-de-uso/',
      privacyPolicyHref: 'https://humand.co/pt/politica-de-privacidade-br/',
    };
  }
  return {
    termsOfUseHref: 'https://humand.co/terms-of-use/',
    privacyPolicyHref: 'https://humand.co/privacy-policy/',
  };
};
