Added some alerts and a new password field
This commit is contained in:
parent
1e0b32d32d
commit
2692127fdf
1 changed files with 43 additions and 8 deletions
|
@ -13,6 +13,7 @@ function UserInfoModal(props: {
|
||||||
}): JSX.Element {
|
}): JSX.Element {
|
||||||
const [showInput, setShowInput] = useState(false);
|
const [showInput, setShowInput] = useState(false);
|
||||||
const [newUsername, setNewUsername] = useState("");
|
const [newUsername, setNewUsername] = useState("");
|
||||||
|
const [newPassword, setNewPassword] = useState("");
|
||||||
if (!props.isVisible) {
|
if (!props.isVisible) {
|
||||||
return <></>;
|
return <></>;
|
||||||
}
|
}
|
||||||
|
@ -26,11 +27,34 @@ function UserInfoModal(props: {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClickChangeName = (): void => {
|
const handleClickChangeName = (): void => {
|
||||||
const nameChange: StrNameChange = {
|
if (newUsername === "") return;
|
||||||
prevName: props.username,
|
if (
|
||||||
newName: newUsername.replace(/ /g, ""),
|
confirm(
|
||||||
};
|
`Do you really want to change username of ${props.username} to ${newUsername}?`,
|
||||||
ChangeUsername({ nameChange: nameChange });
|
)
|
||||||
|
) {
|
||||||
|
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 (
|
return (
|
||||||
|
@ -38,14 +62,14 @@ function UserInfoModal(props: {
|
||||||
className="fixed inset-0 bg-black bg-opacity-30 backdrop-blur-sm
|
className="fixed inset-0 bg-black bg-opacity-30 backdrop-blur-sm
|
||||||
flex justify-center items-center"
|
flex justify-center items-center"
|
||||||
>
|
>
|
||||||
<div className="border-4 border-black bg-white rounded-lg text-center flex flex-col">
|
<div className="border-4 border-black bg-white rounded-2xl text-center flex flex-col">
|
||||||
<div className="mx-10">
|
<div className="mx-10">
|
||||||
<p className="font-bold text-[30px]">{props.username}</p>
|
<p className="font-bold text-[30px]">{props.username}</p>
|
||||||
<p
|
<p
|
||||||
className="mb-[10px] hover:font-bold hover:cursor-pointer underline"
|
className="mb-[10px] hover:font-bold hover:cursor-pointer underline"
|
||||||
onClick={handleChangeNameView}
|
onClick={handleChangeNameView}
|
||||||
>
|
>
|
||||||
(Change Username)
|
(Change Username or Password)
|
||||||
</p>
|
</p>
|
||||||
{showInput && (
|
{showInput && (
|
||||||
<div>
|
<div>
|
||||||
|
@ -54,14 +78,25 @@ function UserInfoModal(props: {
|
||||||
type={"text"}
|
type={"text"}
|
||||||
value={newUsername}
|
value={newUsername}
|
||||||
onChange={function (e): void {
|
onChange={function (e): void {
|
||||||
e.defaultPrevented;
|
|
||||||
setNewUsername(e.target.value);
|
setNewUsername(e.target.value);
|
||||||
}}
|
}}
|
||||||
|
placeholder={"Username"}
|
||||||
|
/>
|
||||||
|
<div className="m-4"></div>
|
||||||
|
<InputField
|
||||||
|
label={"New password"}
|
||||||
|
type={"password"}
|
||||||
|
value={newPassword}
|
||||||
|
onChange={function (e): void {
|
||||||
|
setNewPassword(e.target.value);
|
||||||
|
}}
|
||||||
|
placeholder={"Password"}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
text={"Change"}
|
text={"Change"}
|
||||||
onClick={function (): void {
|
onClick={function (): void {
|
||||||
handleClickChangeName();
|
handleClickChangeName();
|
||||||
|
handleClickChangePassword();
|
||||||
}}
|
}}
|
||||||
type={"submit"}
|
type={"submit"}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in a new issue