From d1feca9544ac63ad7742a4be5e816f53bd53c81b Mon Sep 17 00:00:00 2001 From: jakubmanczak Date: Wed, 28 Dec 2022 17:05:55 +0100 Subject: [PATCH] add reflection of user's login state to navbar --- components/Navigation/Navigation.module.scss | 18 ++++++- components/Navigation/Navigation.tsx | 55 ++++++++++++++------ 2 files changed, 56 insertions(+), 17 deletions(-) diff --git a/components/Navigation/Navigation.module.scss b/components/Navigation/Navigation.module.scss index 4ae69e4..3b409a8 100644 --- a/components/Navigation/Navigation.module.scss +++ b/components/Navigation/Navigation.module.scss @@ -20,10 +20,24 @@ color: var(--color); } } +.partprofile { + background: rgba(255, 255, 255, 0.1); + display: flex; + flex-direction: row; + align-items: center; + gap: 8px; +} .profile { + background: rgba(255, 255, 255, 0.1); + display: flex; + flex-direction: row; + align-items: center; + gap: 8px; margin-left: auto; - background: var(--color); - color: var(--backdrop); + img { + height: 2.3rem; + border-radius: 50%; + } } .logo { padding: 0 1rem; diff --git a/components/Navigation/Navigation.tsx b/components/Navigation/Navigation.tsx index 5cfa432..f702932 100644 --- a/components/Navigation/Navigation.tsx +++ b/components/Navigation/Navigation.tsx @@ -5,8 +5,10 @@ import { Icon } from "../Icon"; import navigation from "../../data/navigation.json"; import Link from "next/link"; +import { useUser } from "@auth0/nextjs-auth0/client"; + const Navigation = () => { - let username: string = ""; + const { user, isLoading } = useUser(); return ( <>
@@ -42,20 +44,43 @@ const Navigation = () => { })}
- - zaloguj się - - - {username ? username : "twój profil"} - + {isLoading && ( + <> + + fetching danych... + + + )} + {!isLoading && user && ( + <> + + {user.picture && ( + {`${user.name}'s + )} + {!user.picture && } + {user.nickname} + + + + + + )} + {!isLoading && !user && ( + + zaloguj się + + + )} );