diff --git a/src/components/labeled-input.tsx b/src/components/labeled-input.tsx index 250dd5f..94563dc 100644 --- a/src/components/labeled-input.tsx +++ b/src/components/labeled-input.tsx @@ -7,12 +7,14 @@ export default function LabeledInput({ placeholder, value, name, + autocomplete, }: { type: 'text' | 'email' | 'password'; label: string; placeholder?: string; value?: string; name?: string; + autocomplete?: string; }) { return (
@@ -24,6 +26,7 @@ export default function LabeledInput({ defaultValue={value} id={name} name={name} + autoComplete={autocomplete} />
); diff --git a/src/components/user/login-form.tsx b/src/components/user/login-form.tsx index a8e6382..2ed61e4 100644 --- a/src/components/user/login-form.tsx +++ b/src/components/user/login-form.tsx @@ -1,19 +1,27 @@ +'use client'; import { signIn } from '@/auth'; import LabeledInput from '@/components/labeled-input'; import { Button } from '@/components/custom-ui/button'; import { AuthError } from 'next-auth'; import { redirect } from 'next/navigation'; +import { useState } from 'react'; const SIGNIN_ERROR_URL = '/error'; export default function LoginForm() { + const [isSignUp, setIsSignUp] = useState(false); + return (
{ - 'use server'; + 'use client'; try { - await signIn('credentials', formData); + if (isSignUp) { + // handle sign up logic here + } else { + await signIn('credentials', formData); + } } catch (error) { if (error instanceof AuthError) { return redirect(`${SIGNIN_ERROR_URL}?error=${error.type}`); @@ -22,24 +30,70 @@ export default function LoginForm() { } }} > - - + {isSignUp ? ( + <> + + + + + + + ) : ( + <> + + + + )}
-