From 3981190c7a61ef5c1b925e896e5ba80aca27d675 Mon Sep 17 00:00:00 2001 From: Peter KW Date: Mon, 1 Apr 2024 02:16:06 +0200 Subject: [PATCH] Can now change username in this modal + moved some stuff to a separate modal --- frontend/src/Components/UserInfoModal.tsx | 73 ++++++++++++++++------- 1 file changed, 52 insertions(+), 21 deletions(-) diff --git a/frontend/src/Components/UserInfoModal.tsx b/frontend/src/Components/UserInfoModal.tsx index 9d8dc11..7888c6b 100644 --- a/frontend/src/Components/UserInfoModal.tsx +++ b/frontend/src/Components/UserInfoModal.tsx @@ -1,34 +1,38 @@ -import { Link } from "react-router-dom"; import Button from "./Button"; import DeleteUser from "./DeleteUser"; import UserProjectListAdmin from "./UserProjectListAdmin"; +import { useState } from "react"; +import InputField from "./InputField"; +import ChangeUsername from "./ChangeUsername"; +import { StrNameChange } from "../Types/goTypes"; function UserInfoModal(props: { isVisible: boolean; - manageMember: boolean; username: string; onClose: () => void; - onDelete: (username: string) => void; }): JSX.Element { - if (!props.isVisible) return <>; - const ManageUserOrMember = (check: boolean): JSX.Element => { - if (check) { - return ( - -

- (Change Role) -

- - ); + const [showInput, setShowInput] = useState(false); + const [newUsername, setNewUsername] = useState(""); + if (!props.isVisible) { + return <>; + } + + const handleChangeNameView = (): void => { + if (showInput) { + setShowInput(false); + } else { + setShowInput(true); } - return ( - -

- (Change Username) -

- - ); }; + + const handleClickChangeName = (): void => { + const nameChange: StrNameChange = { + prevName: props.username, + newName: newUsername, + }; + ChangeUsername({ nameChange: nameChange }); + }; + return (

{props.username}

- {ManageUserOrMember(props.manageMember)} +

+ (Change Username) +

+ {showInput && ( +
+ +
+ )}

Member of these projects: @@ -62,6 +91,8 @@ function UserInfoModal(props: {