Skip to content

Commit

Permalink
Fix Logout Button design
Browse files Browse the repository at this point in the history
  • Loading branch information
AnibalDBXD committed Sep 11, 2022
1 parent c23a8c5 commit e5c224d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 26 deletions.
8 changes: 0 additions & 8 deletions modules/Auth/components/LogoutButton.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions modules/Auth/firebase/auth.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
import { createUserWithEmailAndPassword, signInWithEmailAndPassword, signOut } from "firebase/auth";

import { auth } from "@/firebaseConfig";
Expand All @@ -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;
}
Expand All @@ -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);
}
Expand Down
54 changes: 40 additions & 14 deletions modules/shared/components/Menu/Menu.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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 = () => {
Expand All @@ -36,13 +39,20 @@ const Menu = () => {
<Hamburguer />
</Box>
<Box display={{ base: "none", lg: "flex" }}>
{Links.map((link) => (
<Text variant="navbar">
<Link href={link.href}>
<a>{link.title}</a>
</Link>
</Text>
))}
{Links.map((link) => {
if (link.onClick) {
return <Button onClick={link.onClick} variant="link"><Text variant="navbar">
{link.title}
</Text></Button>;
}
return (
<Text key={link.href} variant="navbar">
<Link href={link.href}>
{link.title}
</Link>
</Text>
);
})}
</Box>
</Flex>
<Drawer onClose={onClose} isOpen={isOpen} size={{ base: "full", md: "sm" }}>
Expand All @@ -57,13 +67,29 @@ const Menu = () => {
borderColor="primary.100"
borderWidth={2}
/>
{Links.map((link) => (
<Text variant="drawer">
<Link href={link.href}>
<a>{link.title}</a>
</Link>
</Text>
))}
{Links.map((link) => {
if (link.onClick) {
return (
<Button
position="fixed"
bottom="5vh"
left="2vh"
onClick={link.onClick}
variant="link">
<Text variant="drawer">
{link.title}
</Text>
</Button>
);
}
return (
<Text key={link.href} variant="drawer">
<Link href={link.href || ''}>
{link.title}
</Link>
</Text>
);
})}
</DrawerBody>
</DrawerContent>
</Drawer>
Expand Down
2 changes: 0 additions & 2 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -17,7 +16,6 @@ const Home: NextPage & { requiresAuthentication: boolean } = () => {
</Head>
<div>
<Menu />
<LogoutButton />
<MyCollectionsPage />
</div>
</div>
Expand Down

0 comments on commit e5c224d

Please sign in to comment.