From e5c224dc22c01cfaf7d4e1b1b51562b225dd2c03 Mon Sep 17 00:00:00 2001 From: Anibal Olivares Date: Sun, 11 Sep 2022 14:14:10 -0400 Subject: [PATCH] Fix Logout Button design --- modules/Auth/components/LogoutButton.tsx | 8 ---- modules/Auth/firebase/auth.ts | 4 +- modules/shared/components/Menu/Menu.tsx | 54 ++++++++++++++++++------ pages/index.tsx | 2 - 4 files changed, 42 insertions(+), 26 deletions(-) delete mode 100644 modules/Auth/components/LogoutButton.tsx diff --git a/modules/Auth/components/LogoutButton.tsx b/modules/Auth/components/LogoutButton.tsx deleted file mode 100644 index 2317f8e..0000000 --- a/modules/Auth/components/LogoutButton.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import React from "react"; -import { logOut } from "@/modules/Auth/firebase/auth"; - -const LogoutButton: React.FC = () => { - return ; -}; - -export default LogoutButton; diff --git a/modules/Auth/firebase/auth.ts b/modules/Auth/firebase/auth.ts index 918c0b9..11edb0b 100644 --- a/modules/Auth/firebase/auth.ts +++ b/modules/Auth/firebase/auth.ts @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ import { createUserWithEmailAndPassword, signInWithEmailAndPassword, signOut } from "firebase/auth"; import { auth } from "@/firebaseConfig"; @@ -18,7 +19,6 @@ export const logIn = async (email: string, password: string) => { const user = await signInWithEmailAndPassword(auth, email, password); return user; } catch (error) { - // eslint-disable-next-line no-console console.error(error); return null; } @@ -27,7 +27,7 @@ export const logIn = async (email: string, password: string) => { export const logOut = async () => { try { await signOut(auth); - return window.alert("User Logged Out"); + console.log(">>>"); } catch (error) { console.error(error); } diff --git a/modules/shared/components/Menu/Menu.tsx b/modules/shared/components/Menu/Menu.tsx index 9039814..f866ce9 100644 --- a/modules/shared/components/Menu/Menu.tsx +++ b/modules/shared/components/Menu/Menu.tsx @@ -1,8 +1,10 @@ import React from "react"; import Link from "next/link"; +import { logOut } from "@/modules/Auth/firebase/auth"; import { Box, + Button, Drawer, DrawerBody, DrawerCloseButton, @@ -21,6 +23,7 @@ const Links = [ { title: "Sesión de estudio", href: "/study-sessions" }, { title: "Tienda", href: "/Tienda" }, { title: "Perfil", href: "/Perfil" }, + { title: "Cerrar sesión", onClick: logOut }, ]; const Menu = () => { @@ -36,13 +39,20 @@ const Menu = () => { - {Links.map((link) => ( - - - {link.title} - - - ))} + {Links.map((link) => { + if (link.onClick) { + return ; + } + return ( + + + {link.title} + + + ); + })} @@ -57,13 +67,29 @@ const Menu = () => { borderColor="primary.100" borderWidth={2} /> - {Links.map((link) => ( - - - {link.title} - - - ))} + {Links.map((link) => { + if (link.onClick) { + return ( + + ); + } + return ( + + + {link.title} + + + ); + })} diff --git a/pages/index.tsx b/pages/index.tsx index 99e2c98..6e87e19 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -3,7 +3,6 @@ import Head from "next/head"; import nookies from "nookies"; import { verifyIdToken } from "@/firebaseAdminConfig"; -import LogoutButton from "@/modules/Auth/components/LogoutButton"; import MyCollectionsPage from "@/modules/Collections/MyCollectionsPage"; import Menu from "@/modules/shared/components/Menu/Menu"; @@ -17,7 +16,6 @@ const Home: NextPage & { requiresAuthentication: boolean } = () => {
-