From 88c6757bd3b982d7d168b455efb0d1ded0e0b64b Mon Sep 17 00:00:00 2001 From: Peter KW Date: Sat, 13 Apr 2024 21:07:08 +0200 Subject: [PATCH] Checks if user already is selected role + minor design change --- frontend/src/Components/ChangeRoleView.tsx | 55 +++++++++++---------- frontend/src/Components/MemberInfoModal.tsx | 11 +++-- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/frontend/src/Components/ChangeRoleView.tsx b/frontend/src/Components/ChangeRoleView.tsx index 782ad8d..9a69e34 100644 --- a/frontend/src/Components/ChangeRoleView.tsx +++ b/frontend/src/Components/ChangeRoleView.tsx @@ -5,6 +5,7 @@ import ChangeRole, { ProjectRoleChange } from "./ChangeRole"; export default function ChangeRoleView(props: { projectName: string; username: string; + currentRole: string; }): JSX.Element { const [selectedRole, setSelectedRole] = useState< "project_manager" | "member" | "" @@ -21,7 +22,12 @@ export default function ChangeRoleView(props: { }; const handleSubmit = (event: React.FormEvent): void => { + console.log("Cur: " + props.currentRole + " " + "new: " + selectedRole); event.preventDefault(); + if (selectedRole === props.currentRole) { + alert(`Already ${props.currentRole}, nothing changed`); + return; + } const roleChangeInfo: ProjectRoleChange = { username: props.username, projectname: props.projectName, @@ -31,34 +37,31 @@ export default function ChangeRoleView(props: { }; return ( -
+

Select role:

-
-
- -
-
- -
+
+ +
+