From 376305371105ee72d6fb6e0d1ac261dffccf09b8 Mon Sep 17 00:00:00 2001
From: Spectralitree <72747870+Spectralitree@users.noreply.github.com>
Date: Sun, 18 Jul 2021 19:11:03 +0200
Subject: [PATCH] fix error message for privated system lists
---
src/Components/Public/ProfileList.js | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/Components/Public/ProfileList.js b/src/Components/Public/ProfileList.js
index 13231dd1..7ea2d220 100644
--- a/src/Components/Public/ProfileList.js
+++ b/src/Components/Public/ProfileList.js
@@ -15,6 +15,7 @@ export default function Memberlist() {
const [isLoading, setIsLoading ] = useState(false);
const [isError, setIsError ] = useState(false);
+ const [isForbidden, setIsForbidden ] = useState(false);
const [currentPage, setCurrentPage] = useState(1);
const [membersPerPage, setMembersPerPage] = useState(25);
@@ -34,15 +35,24 @@ export default function Memberlist() {
fetch(`${API_URL}s/${sysID}/members`,{
method: 'GET',
- }).then ( res => res.json()
+ }).then ( res => {
+ if (res.status === 403) {
+ throw new Error('Access denied!');
+ }
+ res.json()
+ }
).then (data => {
setMembers(data)
setIsLoading(false);
})
- .catch (error => {
+ .catch (error => {
+ if (error.message === 'Access denied!') {
+ setIsForbidden(true);
+ } else {
console.log(error);
setIsError(true);
- setIsLoading(false);
+ }
+ setIsLoading(false);
})
}, [sysID])
@@ -206,7 +216,7 @@ export default function Memberlist() {
{ isLoading ? : isError ?
- Error fetching members. :
+ Error fetching members. : isForbidden ? Member list is private. :
<>
{memberList}