diff --git a/src/components/AuthenticationFlow/AuthenticationForm.tsx b/src/components/AuthenticationFlow/AuthenticationForm.tsx new file mode 100644 index 000000000..70f07c5f4 --- /dev/null +++ b/src/components/AuthenticationFlow/AuthenticationForm.tsx @@ -0,0 +1,41 @@ +import { useState } from 'react'; +import { GitHubButton } from './GitHubButton'; +import { GoogleButton } from './GoogleButton'; +import { LinkedInButton } from './LinkedInButton'; +import { EmailLoginForm } from './EmailLoginForm'; +import { EmailSignupForm } from './EmailSignupForm'; + +type AuthenticationFormProps = { + type?: 'login' | 'signup'; +}; + +export function AuthenticationForm(props: AuthenticationFormProps) { + const { type = 'login' } = props; + + const [isDisabled, setIsDisabled] = useState(false); + + return ( + <> +
+ + + +
+ +
+
+ OR +
+
+ + {type === 'login' ? ( + + ) : ( + + )} + + ); +} 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() {