Skip to content

Commit

Permalink
feat: bring header drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoEscaleira committed Feb 4, 2024
1 parent db42008 commit 94e8a9e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
20 changes: 14 additions & 6 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect } from "react";
import { useEffect, useState } from "react";
import { useQuery } from "@apollo/client";
import { CircleUser } from "lucide-react";
import { Link } from "react-router-dom";
import { Drawer, Typography } from "@material-tailwind/react";
import { Menu } from "lucide-react";
import { LoginModal } from "@components/Login/LoginModal.tsx";
import { gql } from "@generated/index.ts";
import { useUserStore } from "@state/userStore.ts";
Expand All @@ -22,7 +22,9 @@ const GET_USER = gql(/* GraphQL */ `
`);

export function Header() {
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
const { user, setUser, setIsSessionLoading } = useUserStore();
const isLoggedIn = !!user.userId;

const { data, loading, refetch } = useQuery(GET_USER);

Expand Down Expand Up @@ -51,12 +53,18 @@ export function Header() {
<>
<header className="absolute left-0 top-0 z-10 w-full px-4 py-2 sm:px-6 sm:py-4">
<div className="flex items-center justify-end">
<Link to={user.userId ? "/profile" : "#login"}>
<CircleUser className="h-10 w-8 cursor-pointer sm:w-10" />
</Link>
<Menu onClick={() => setIsDrawerOpen(true)} className="h-10 w-8 cursor-pointer sm:w-10" />
</div>
</header>

<Drawer open={isDrawerOpen} onClose={() => setIsDrawerOpen(false)} placement="right" className="p-4">
<div className="flex flex-col items-center justify-between">
<Typography variant="h3" color="blue-gray">
Hello explorer!
</Typography>
{!isLoggedIn && <Typography color="blue-gray">Get started and login to your account</Typography>}
</div>
</Drawer>
<LoginModal refetchUser={refetch} />
</>
);
Expand Down
6 changes: 0 additions & 6 deletions src/utils/cn.ts

This file was deleted.

0 comments on commit 94e8a9e

Please sign in to comment.