'use client' import { RiContractLine, RiDoorLockLine, RiErrorWarningFill } from '@remixicon/react' import Link from 'next/link' import * as React from 'react' import { useCallback, useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import Loading from '@/app/components/base/loading' import { IS_CE_EDITION } from '@/config' import { useGlobalPublicStore } from '@/context/global-public-context' import { LicenseStatus } from '@/types/feature' import { cn } from '@/utils/classnames' import MailAndCodeAuth from './components/mail-and-code-auth' import MailAndPasswordAuth from './components/mail-and-password-auth' import SSOAuth from './components/sso-auth' 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('licenseLost', { ns: 'login' })}
{t('licenseLostTip', { ns: 'login' })}
{t('licenseExpired', { ns: 'login' })}
{t('licenseExpiredTip', { ns: 'login' })}
{t('licenseInactive', { ns: 'login' })}
{t('licenseInactiveTip', { ns: 'login' })}
{t('welcome', { ns: 'login' })}
{t('noLoginMethod', { ns: 'login' })}
{t('noLoginMethodTip', { ns: 'login' })}