From 8d9f677c4e9ccfcc6dc9297864dc49446fb5ee59 Mon Sep 17 00:00:00 2001
From: Ellie Huxtable <ellie@atuin.sh>
Date: Wed, 10 Jul 2024 15:56:33 +0100
Subject: feat(gui): use fancy new side nav (#2243)

* feat(gui): use fancy new side nav

* compact only sidebar, no expand-collapse

* custom drag region, remove titlebar

* add user popup

* wire up login/logout/register, move user button to bottom and add menu

* link help and feedback to forum
---
 ui/src/components/LoginOrRegister.tsx | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

(limited to 'ui/src/components/LoginOrRegister.tsx')

diff --git a/ui/src/components/LoginOrRegister.tsx b/ui/src/components/LoginOrRegister.tsx
index f05a9a24..97f8a790 100644
--- a/ui/src/components/LoginOrRegister.tsx
+++ b/ui/src/components/LoginOrRegister.tsx
@@ -6,6 +6,7 @@ import { useStore } from "@/state/store";
 
 interface LoginProps {
   toggleRegister: () => void;
+  onClose: () => void;
 }
 
 function Login(props: LoginProps) {
@@ -24,7 +25,7 @@ function Login(props: LoginProps) {
     try {
       await login(username, password, key);
       refreshUser();
-      console.log("Logged in");
+      props.onClose();
     } catch (e: any) {
       console.error(e);
       setErrors(e);
@@ -171,6 +172,7 @@ function Login(props: LoginProps) {
 
 interface RegisterProps {
   toggleLogin: () => void;
+  onClose: () => void;
 }
 
 function Register(props: RegisterProps) {
@@ -185,13 +187,11 @@ function Register(props: RegisterProps) {
     const email = form.email.value;
     const password = form.password.value;
 
-    console.log("Logging in...");
     try {
       await register(username, email, password);
       refreshUser();
-      console.log("Logged in");
+      props.onClose();
     } catch (e: any) {
-      console.error(e);
       setErrors(e);
     }
   };
@@ -330,12 +330,12 @@ function Register(props: RegisterProps) {
   );
 }
 
-export default function LoginOrRegister() {
+export default function LoginOrRegister({ onClose }: { onClose: () => void }) {
   let [login, setLogin] = useState<boolean>(false);
 
   if (login) {
-    return <Login toggleRegister={() => setLogin(false)} />;
+    return <Login onClose={onClose} toggleRegister={() => setLogin(false)} />;
   }
 
-  return <Register toggleLogin={() => setLogin(true)} />;
+  return <Register onClose={onClose} toggleLogin={() => setLogin(true)} />;
 }
-- 
cgit v1.3.1

