From 7a03f14e7ce75912a42744e30f1aea682683e2f4 Mon Sep 17 00:00:00 2001 From: jakubmanczak Date: Thu, 29 Dec 2022 03:10:32 +0100 Subject: [PATCH] add error handling to ui states --- components/Navigation/Navigation.tsx | 40 +++++++++++++++------------- pages/ja.tsx | 20 ++++++-------- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/components/Navigation/Navigation.tsx b/components/Navigation/Navigation.tsx index 412c734..2dec81d 100644 --- a/components/Navigation/Navigation.tsx +++ b/components/Navigation/Navigation.tsx @@ -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 ( <>
@@ -51,25 +51,27 @@ const Navigation = () => { )} + {!isLoading && !error && user && ( + + {user.picture && ( + {`${user.name}'s + )} + {!user.picture && } + {user.nickname} + + )} + {error && ( + + wystąpił błąd! + + )} {!isLoading && user && ( - <> - - {user.picture && ( - {`${user.name}'s - )} - {!user.picture && } - {user.nickname} - - - - - + + + )} {!isLoading && !user && ( { - const { user, isLoading } = useUser(); + const { user, error, isLoading } = useUser(); return ( <> {isLoading && ( @@ -11,22 +11,18 @@ const PageMe = () => {

Sit tight.

)} - {!isLoading && user && ( + {error && ( +
+

Wystąpił błąd.

+

Tyle wiemy.

+
+ )} + {!isLoading && !error && user && (
{`${user.name}'s

{user.name}

- {/*

- mail: {user.email || "no mail"}
- mail verified: {user.email_verified || "no mail verified"}
- name: {user.name || "no name"}
- nickname: {user.nickname || "no nickname"}
- org id: {user.org_id || "no org id"}
- picture: {user.picture || "no picture"}
- sub: {user.sub || "no sub"}
- updated at: {user.updated_at || "no updated at"} -

*/}
)} {!isLoading && !user && (