import React, { useCallback, useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import Link from 'next/link' import { RiContractLine, RiDoorLockLine, RiErrorWarningFill } from '@remixicon/react' import Loading from '@/app/components/base/loading' import MailAndCodeAuth from './components/mail-and-code-auth' import MailAndPasswordAuth from './components/mail-and-password-auth' import SSOAuth from './components/sso-auth' import cn from '@/utils/classnames' import { LicenseStatus } from '@/types/feature' import { IS_CE_EDITION } from '@/config' import { useGlobalPublicStore } from '@/context/global-public-context' const NormalForm = () => { const { t } = useTranslation() const [isLoading, setIsLoading] = useState(true) const { systemFeatures } = useGlobalPublicStore() const [authType, updateAuthType] = useState<'code' | 'password'>('password') const [showORLine, setShowORLine] = useState(false) const [allMethodsAreDisabled, setAllMethodsAreDisabled] = useState(false) const init = useCallback(async () => { try { setAllMethodsAreDisabled(!systemFeatures.enable_social_oauth_login && !systemFeatures.enable_email_code_login && !systemFeatures.enable_email_password_login && !systemFeatures.sso_enforced_for_signin) setShowORLine((systemFeatures.enable_social_oauth_login || systemFeatures.sso_enforced_for_signin) && (systemFeatures.enable_email_code_login || systemFeatures.enable_email_password_login)) updateAuthType(systemFeatures.enable_email_password_login ? 'password' : 'code') } catch (error) { console.error(error) setAllMethodsAreDisabled(true) } finally { setIsLoading(false) } }, [systemFeatures]) useEffect(() => { init() }, [init]) if (isLoading) { return
{t('login.licenseLost')}
{t('login.licenseLostTip')}
{t('login.licenseExpired')}
{t('login.licenseExpiredTip')}
{t('login.licenseInactive')}
{t('login.licenseInactiveTip')}
{t('login.welcome')}
}{t('login.noLoginMethod')}
{t('login.noLoginMethodTip')}