diff --git a/apps/client/pages/login.tsx b/apps/client/pages/login.tsx index aabcc715..57cbfa70 100644 --- a/apps/client/pages/login.tsx +++ b/apps/client/pages/login.tsx @@ -1,6 +1,6 @@ import { useState, type ReactElement } from 'react' import { FullPageLayout } from '@maybe-finance/client/features' -import { Input, InputPassword, Button } from '@maybe-finance/design-system' +import { Input, InputPassword, Button, LoadingSpinner } from '@maybe-finance/design-system' import { signIn, useSession } from 'next-auth/react' import { useRouter } from 'next/router' import { useEffect } from 'react' @@ -10,8 +10,9 @@ import Link from 'next/link' export default function LoginPage() { const [email, setEmail] = useState('') const [password, setPassword] = useState('') - const [isValid, setIsValid] = useState(false) + const [isValid, setIsValid] = useState(true) const [errorMessage, setErrorMessage] = useState(null) + const [isLoading, setIsLoading] = useState(false) const { data: session } = useSession() const router = useRouter() @@ -26,6 +27,7 @@ export default function LoginPage() { e.preventDefault() setErrorMessage(null) setPassword('') + setIsLoading(true) const response = await signIn('credentials', { email, @@ -35,9 +37,16 @@ export default function LoginPage() { if (response && response.error) { setErrorMessage(response.error) + setIsLoading(false) } } + const onPasswordChange = (e: React.ChangeEvent) => { + setErrorMessage(null) + setPassword(e.target.value) + setIsValid(e.target.value.length > 0) + } + return ( <>