From 5aaa5ff7a67c0754ad65053da1c557c6da6585bc Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Sun, 24 Apr 2022 13:27:52 +0200 Subject: [PATCH] Ability to promote and demote admins --- src/client/src/AdminsOverview.js | 49 +++++++++++++++++++++------ src/client/src/components/AsuraBar.js | 2 -- 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/src/client/src/AdminsOverview.js b/src/client/src/AdminsOverview.js index cae1079..7016149 100644 --- a/src/client/src/AdminsOverview.js +++ b/src/client/src/AdminsOverview.js @@ -45,14 +45,16 @@ function AdminCreator(props){ return (
- - {/* */} - +
+ + {/* */} + +
) @@ -72,6 +74,27 @@ function UserList(props){ .catch(error => showError(error)); } + let updateRank = (email) => event => { + let isManager = event.target.value == "manager"; + let formData = new FormData(); + formData.append("isManager", isManager); + formData.append("emailAddress", email); + let body = new URLSearchParams(formData); + fetch(process.env.REACT_APP_API_URL + `/users/changeManagerStatus`, { + method: "POST", + body: body + }) + .then(res => res.json()) + .then(data => { + if(data.status !== "OK"){ + showError(data.data); + return; + } + props.onUserUpdated(); + }) + .catch(error => showError(error)); + } + return(
@@ -95,7 +118,12 @@ function UserList(props){ {user.email} {/* TODO Drop down menu for selecting rank */} - {'user.rank'} + + + {/* {team.members} */} {/* */} @@ -112,7 +140,6 @@ function UserList(props){ export default function Users(props) { const [users, setUsers] = React.useState([]); - const { userId } = useParams(); function getUsers() { fetch(process.env.REACT_APP_API_URL + `/users/getUsers`) @@ -144,7 +171,7 @@ export default function Users(props) { <>
- +
diff --git a/src/client/src/components/AsuraBar.js b/src/client/src/components/AsuraBar.js index f27ce89..0bfeef5 100644 --- a/src/client/src/components/AsuraBar.js +++ b/src/client/src/components/AsuraBar.js @@ -57,8 +57,6 @@ function NotLoggedInButton() { } export default function Appbar(props) { - console.log("Appbar-user:") - console.log(props.user); return ( <>