2024-04-01 02:16:23 +02:00
|
|
|
import Button from "./Button";
|
|
|
|
import DeleteUser from "./DeleteUser";
|
|
|
|
import UserProjectListAdmin from "./UserProjectListAdmin";
|
|
|
|
import { useState } from "react";
|
|
|
|
import ChangeRoleView from "./ChangeRoleView";
|
|
|
|
|
|
|
|
function MemberInfoModal(props: {
|
2024-04-02 13:14:08 +02:00
|
|
|
projectName: string;
|
2024-04-01 02:16:23 +02:00
|
|
|
username: string;
|
|
|
|
onClose: () => void;
|
|
|
|
}): JSX.Element {
|
|
|
|
const [showRoles, setShowRoles] = useState(false);
|
|
|
|
|
|
|
|
const handleChangeRole = (): void => {
|
|
|
|
if (showRoles) {
|
|
|
|
setShowRoles(false);
|
|
|
|
} else {
|
|
|
|
setShowRoles(true);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className="fixed inset-0 bg-black bg-opacity-30 backdrop-blur-sm
|
|
|
|
flex justify-center items-center"
|
|
|
|
>
|
2024-04-02 13:14:08 +02:00
|
|
|
<div className="border-4 border-black bg-white rounded-lg text-center flex flex-col">
|
|
|
|
<div className="mx-10">
|
|
|
|
<p className="font-bold text-[30px]">{props.username}</p>
|
|
|
|
<p
|
|
|
|
className="hover:font-bold hover:cursor-pointer underline"
|
|
|
|
onClick={handleChangeRole}
|
|
|
|
>
|
|
|
|
(Change Role)
|
|
|
|
</p>
|
|
|
|
{showRoles && (
|
|
|
|
<ChangeRoleView
|
|
|
|
projectName={props.projectName}
|
|
|
|
username={props.username}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
<h2 className="font-bold text-[20px]">Member of these projects:</h2>
|
|
|
|
<UserProjectListAdmin username={props.username} />
|
|
|
|
<div className="items-center space-x-6">
|
|
|
|
<Button
|
|
|
|
text={"Delete"}
|
|
|
|
onClick={function (): void {
|
|
|
|
if (
|
|
|
|
window.confirm("Are you sure you want to delete this user?")
|
|
|
|
) {
|
|
|
|
DeleteUser({
|
|
|
|
usernameToDelete: props.username,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
type="button"
|
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
text={"Close"}
|
|
|
|
onClick={function (): void {
|
|
|
|
setShowRoles(false);
|
|
|
|
props.onClose();
|
|
|
|
}}
|
|
|
|
type="button"
|
|
|
|
/>
|
2024-04-01 02:16:23 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MemberInfoModal;
|