diff --git a/frontend/src/Components/UserInfoModal.tsx b/frontend/src/Components/UserInfoModal.tsx index eae011c..6caf8d9 100644 --- a/frontend/src/Components/UserInfoModal.tsx +++ b/frontend/src/Components/UserInfoModal.tsx @@ -13,6 +13,7 @@ function UserInfoModal(props: { }): JSX.Element { const [showInput, setShowInput] = useState(false); const [newUsername, setNewUsername] = useState(""); + const [newPassword, setNewPassword] = useState(""); if (!props.isVisible) { return <>; } @@ -26,11 +27,34 @@ function UserInfoModal(props: { }; const handleClickChangeName = (): void => { - const nameChange: StrNameChange = { - prevName: props.username, - newName: newUsername.replace(/ /g, ""), - }; - ChangeUsername({ nameChange: nameChange }); + if (newUsername === "") return; + if ( + confirm( + `Do you really want to change username of ${props.username} to ${newUsername}?`, + ) + ) { + const nameChange: StrNameChange = { + prevName: props.username, + newName: newUsername.replace(/ /g, ""), + }; + ChangeUsername({ nameChange: nameChange }); + } else { + alert("Name was not changed!"); + } + }; + + const handleClickChangePassword = (): void => { + if (newPassword === "") return; + + if ( + confirm(`Are you sure you want to change password of ${props.username}?`) + ) { + //TODO: insert change password functionality + alert("Not implemented yet"); + setNewPassword(""); + } else { + alert("Password was not changed!"); + } }; return ( @@ -38,14 +62,14 @@ function UserInfoModal(props: { className="fixed inset-0 bg-black bg-opacity-30 backdrop-blur-sm flex justify-center items-center" > -
+

{props.username}

- (Change Username) + (Change Username or Password)

{showInput && (
@@ -54,14 +78,25 @@ function UserInfoModal(props: { type={"text"} value={newUsername} onChange={function (e): void { - e.defaultPrevented; setNewUsername(e.target.value); }} + placeholder={"Username"} + /> +
+