Fix login spinner stuck on API error (add try/catch in handleSubmit)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-17 17:04:05 +03:00
parent 56f4d997a2
commit c06f4bf553

View File

@@ -40,10 +40,16 @@ function LoginForm({ onSwitch }: { onSwitch: () => void }) {
e.preventDefault()
setError('')
setLoading(true)
try {
const loggedIn = await login(email, password)
setLoading(false)
if (!loggedIn) { setError('Неверный email или пароль'); return }
navigate('/calendar')
} catch (err) {
const msg = err instanceof Error ? err.message : 'Ошибка соединения'
setError(`Ошибка сервера: ${msg}`)
} finally {
setLoading(false)
}
}
return (