diff options
author | polwex <polwex@sortug.com> | 2025-05-29 14:52:38 +0700 |
---|---|---|
committer | polwex <polwex@sortug.com> | 2025-05-29 14:52:38 +0700 |
commit | 490388360a0852bcf8ee054e96fa90e166df5792 (patch) | |
tree | 3940097c5505ff1bb09875dddb7ee0e4881beb77 /src/components | |
parent | f243847216279cbd43879de8b5ef6dcceb3a2f1d (diff) |
fucker actually solved the cookies, love ya man
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/Login2.tsx | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/components/Login2.tsx b/src/components/Login2.tsx index 6c26efc..7adf09c 100644 --- a/src/components/Login2.tsx +++ b/src/components/Login2.tsx @@ -42,17 +42,18 @@ function OOldform({ isReg, toggle }: { isReg: boolean; toggle: () => void }) { else setStrings(logstrings); }, [isReg]); - // const [state, formAction, isPending] = useActionState<FormState, FormData>( - // isReg ? postRegister : postLogin, - // { error: "" }, - // "/login", - // ); const [state, formAction, isPending] = useActionState<FormState, FormData>( - postLogin, + isReg ? postRegister : postLogin, { error: "" }, "/login", ); console.log({ state }); + + // Handle redirect after successful login + if (state.success && state.redirect) { + window.location.href = state.redirect; + } + return ( <form action={formAction}> <div className="flex flex-col gap-6"> @@ -87,8 +88,8 @@ function OOldform({ isReg, toggle }: { isReg: boolean; toggle: () => void }) { {state.password && <p>{state.password}</p>} </Label> </div> - <Button type="submit" className="w-full"> - {strings.button} + <Button type="submit" className="w-full" disabled={isPending}> + {isPending ? "Loading..." : strings.button} </Button> <div className="text-center text-sm"> {strings.toggle} @@ -101,7 +102,8 @@ function OOldform({ isReg, toggle }: { isReg: boolean; toggle: () => void }) { </a> </div> </div> - {state.error && <p className="text-red">{state.error}</p>} + {state.error && <p className="text-red-500">{state.error}</p>} + {state.success && <p className="text-green-500">Login successful! Redirecting...</p>} </CardContent> </Card> <div className="text-balance text-center text-xs text-muted-foreground [&_a]:underline [&_a]:underline-offset-4 [&_a]:hover:text-primary "> |