import Button from "../ui/button/button.jsx";
import Modal from "../ui/modal/modal.jsx";
import { useState } from "react";
import styles from "./manageMember.module.css"
import DeleteMemberBtn from "./deleteMember/deleteMemberBtn.jsx";
import ModifyRole from "./modifyrole/ModifyRole.jsx";

export default function ManageMember({ user }) {

    const [open, setOpen] = useState(false);


    return <>
        <Button onClick={() => setOpen(true)} variant={"default"} className={styles.manageBtn}>
            <img src="/icons/tools.svg" alt="tools icon" className={styles.icon} />
            <p>Gérer</p>
        </Button>

        <Modal open={open} onClose={() => setOpen(false)} title={`Gestion de l'utilisateur ${user.name}`}>

            <div className={styles.manageSection}>
                <h3>Supprimer le compte</h3>
                <DeleteMemberBtn name={user.name} id={user.id} className={styles.manageBlockContent} />
            </div>

            <div className={styles.manageSection}>
                <h3>Modifier le rôle</h3>
                <ModifyRole user={user} />
            </div>
        </Modal>
    </>
}