import { useState } from 'react'; import { useTranslation } from 'react-i18next'; import { ScrollView } from 'react-native'; import { useSessionCtx } from '../lib/session'; import { Button, ErrorBox, Field, H1, Muted, Screen, useErrorText } from '../ui/kit'; export default function LoginScreen() { const { t } = useTranslation(['auth', 'common']); const { server, session, disconnect } = useSessionCtx(); const errorText = useErrorText(); const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const [busy, setBusy] = useState(false); const [error, setError] = useState(null); const submit = async () => { if (!session) return; setBusy(true); setError(null); try { await session.login(username.trim(), password); // переход сделает Gate } catch (e) { setError(e); setPassword(''); } finally { setBusy(false); } }; return (

{t('login.title')}

{server?.replace(/^https?:\/\//, '')} void submit()} /> {error ? errorText(error) : null}