import * as React from 'react';
import { Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, TextField } from '@mui/material';

export default function UserDisableDialog({ open, user, handleDisable, handleClose }) {

    const [reason, setReason] = React.useState('');

    const handlePreDisable = () => {
        console.log(user.EMAIL);
        handleDisable(user.EMAIL, reason);
        handleClose();
    }
    
    return (
        <Dialog open={open} onClose={handleClose}>
            <DialogTitle>Désactiver l&apos;utilisateur {user.USERNAME}</DialogTitle>
            <DialogContent>
                <DialogContentText>
                    Êtes-vous sûr de vouloir désactiver l&apos;utilisateur {user.USERNAME} ?
                </DialogContentText>
                <TextField id="reason" label="Raison" value={reason} onChange={(e) => setReason(e.target.value)} fullWidth />
            </DialogContent>
            <DialogActions>
                <Button variant='text' color='default' onClick={handleClose}>Annuler</Button>
                <Button variant='text' color='primary' onClick={handlePreDisable}>Désactiver</Button>
            </DialogActions>
        </Dialog>
    );
}