import { useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; import { useGetStartupConfig } from 'librechat-data-provider/react-query'; import { GoogleIcon, FacebookIcon, OpenIDIcon, GithubIcon, DiscordIcon } from '~/components'; import { useAuthContext } from '~/hooks/AuthContext'; import { getLoginError } from '~/utils'; import { useLocalize } from '~/hooks'; import LoginForm from './LoginForm'; import SocialButton from './SocialButton'; function Login() { const { login, error, isAuthenticated } = useAuthContext(); const { data: startupConfig } = useGetStartupConfig(); const localize = useLocalize(); const navigate = useNavigate(); useEffect(() => { if (isAuthenticated) { navigate('/c/new', { replace: true }); } }, [isAuthenticated, navigate]); if (!startupConfig) { return null; } const socialLogins = startupConfig.socialLogins ?? []; const providerComponents = { discord: ( ), facebook: ( ), github: ( ), google: ( ), openid: ( startupConfig.openidImageUrl ? ( ) : ( ) } label={startupConfig.openidLabel} id="openid" /> ), }; return ( {localize('com_auth_welcome_back')} {error && ( {localize(getLoginError(error))} )} {startupConfig.emailLoginEnabled && } {startupConfig.registrationEnabled && ( {' '} {localize('com_auth_no_account')}{' '} {localize('com_auth_sign_up')} )} {startupConfig.socialLoginEnabled && ( <> {startupConfig.emailLoginEnabled && ( <> Or > )} {socialLogins.map((provider) => providerComponents[provider] || null)} > )} ); } export default Login;
{' '} {localize('com_auth_no_account')}{' '} {localize('com_auth_sign_up')}