From 490388360a0852bcf8ee054e96fa90e166df5792 Mon Sep 17 00:00:00 2001
From: polwex <polwex@sortug.com>
Date: Thu, 29 May 2025 14:52:38 +0700
Subject: fucker actually solved the cookies, love ya man

---
 src/components/Login2.tsx | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

(limited to 'src/components/Login2.tsx')

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  ">
-- 
cgit v1.2.3

