From 0279e503ff81cb241cd22e60a1261c5a08b348a0 Mon Sep 17 00:00:00 2001 From: keannu125 Date: Sun, 5 Mar 2023 14:09:10 +0800 Subject: [PATCH] Fixed error prompt and not logged in prompt --- src/Components/Notes/Notes.tsx | 12 ++++++------ src/Routes/UserPage/UserPage.tsx | 20 +++++++++++--------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/Components/Notes/Notes.tsx b/src/Components/Notes/Notes.tsx index 4cccaf2..3a20f1c 100644 --- a/src/Components/Notes/Notes.tsx +++ b/src/Components/Notes/Notes.tsx @@ -22,18 +22,18 @@ export default function Notes() {

Loading Notes...

); + } else if (!logged_in && error) { + return ( +
+

Please login to use Clip Notes

+
+ ); } else if (error) { return (

Error contacting Notes server

); - } else if (!logged_in) { - return ( -
-

Please login to use Clip Notes

-
- ); } else if (notes.length === 0) { return (
diff --git a/src/Routes/UserPage/UserPage.tsx b/src/Routes/UserPage/UserPage.tsx index 33a84c7..6d3be48 100644 --- a/src/Routes/UserPage/UserPage.tsx +++ b/src/Routes/UserPage/UserPage.tsx @@ -4,6 +4,7 @@ import { UserInfo } from "../../Components/Api/Api"; import { useQuery } from "react-query"; import { useSelector } from "react-redux"; import { LoginState } from "../../Interfaces/Interfaces"; +import LoginButton from "../../Components/LoginButton/LoginButton"; export default function UserPage() { const { data, isLoading, error } = useQuery("user", UserInfo, { retry: 0 }); @@ -17,6 +18,16 @@ export default function UserPage() {
); + } else if (!logged_in && error) { + return ( +
+
+
+

Please login to view user info

+ +
+
+ ); } else if (error) { return (
@@ -26,15 +37,6 @@ export default function UserPage() {
); - } else if (!logged_in) { - return ( -
-
-
-

Please login to view user info

-
-
- ); } return (