add error handling to ui states

This commit is contained in:
2022-12-29 03:10:32 +01:00
parent b89174d0cb
commit 7a03f14e7c
2 changed files with 29 additions and 31 deletions

View File

@@ -8,7 +8,7 @@ import Link from "next/link";
import { useUser } from "@auth0/nextjs-auth0/client";
const Navigation = () => {
const { user, isLoading } = useUser();
const { user, error, isLoading } = useUser();
return (
<>
<div className={styles.nav}>
@@ -51,25 +51,27 @@ const Navigation = () => {
</Link>
</>
)}
{!isLoading && !error && user && (
<Link href="/ja" className={`${styles.link} ${styles.profile}`}>
{user.picture && (
<img src={user.picture} alt={`${user.name}'s profile picture`} />
)}
{!user.picture && <Icon icon="User" />}
{user.nickname}
</Link>
)}
{error && (
<Link href="/ja" className={`${styles.link} ${styles.profile}`}>
wystąpił błąd!
</Link>
)}
{!isLoading && user && (
<>
<Link href="/ja" className={`${styles.link} ${styles.profile}`}>
{user.picture && (
<img
src={user.picture}
alt={`${user.name}'s profile picture`}
/>
)}
{!user.picture && <Icon icon="User" />}
{user.nickname}
</Link>
<Link
href="/api/auth/logout"
className={`${styles.link} ${styles.partprofile}`}
>
<Icon icon="LogOut" />
</Link>
</>
<Link
href="/api/auth/logout"
className={`${styles.link} ${styles.partprofile}`}
>
<Icon icon="LogOut" />
</Link>
)}
{!isLoading && !user && (
<Link