diff --git a/src/components/AuthenticationFlow/AuthenticationForm.tsx b/src/components/AuthenticationFlow/AuthenticationForm.tsx new file mode 100644 index 000000000..2667a141d --- /dev/null +++ b/src/components/AuthenticationFlow/AuthenticationForm.tsx @@ -0,0 +1,26 @@ +import { GitHubButton } from './GitHubButton'; +import { GoogleButton } from './GoogleButton'; +import { LinkedInButton } from './LinkedInButton'; +import { EmailLoginForm } from './EmailLoginForm'; +import { useState } from 'react'; + +export function AuthenticationForm() { + const [isDisabled, setIsDisabled] = useState(false); + return ( + <> +
+ + + +
+ +
+
+ OR +
+
+ + + + ); +} diff --git a/src/components/AuthenticationFlow/EmailLoginForm.tsx b/src/components/AuthenticationFlow/EmailLoginForm.tsx index 3ba9c7c13..07304f00e 100644 --- a/src/components/AuthenticationFlow/EmailLoginForm.tsx +++ b/src/components/AuthenticationFlow/EmailLoginForm.tsx @@ -4,7 +4,14 @@ import { useState } from 'react'; import { httpPost } from '../../lib/http'; import { TOKEN_COOKIE_NAME } from '../../lib/jwt'; -export function EmailLoginForm() { +type EmailLoginFormProps = { + isDisabled?: boolean; + setIsDisabled?: (isDisabled: boolean) => void; +}; + +export function EmailLoginForm(props: EmailLoginFormProps) { + const { isDisabled, setIsDisabled } = props; + const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(''); @@ -14,6 +21,7 @@ export function EmailLoginForm() { const handleFormSubmit = async (e: FormEvent) => { e.preventDefault(); setIsLoading(true); + setIsDisabled?.(true); setError(''); const { response, error } = await httpPost<{ token: string }>( @@ -45,6 +53,7 @@ export function EmailLoginForm() { } setIsLoading(false); + setIsDisabled?.(false); setError(error?.message || 'Something went wrong. Please try again later.'); }; @@ -92,7 +101,7 @@ export function EmailLoginForm() {