import {useTranslations} from "next-intl";
import {useState} from "react";
import {Dialog, IconButton, Tooltip} from "@mui/material";
import DeleteIcon from '@mui/icons-material/Delete';
import DeleteContent from "@/components/dashboard/role-management/Form/DeleteForm/DeleteContent";

const DeleteForm = ({rowId, mutate}) => {
    const t = useTranslations();
    const [openConfirmDialog, setOpenConfirmDialog] = useState(false);


    return (
        <>
            <Tooltip title={t("DeleteDialog.delete")}>
                <IconButton
                    data-testid="dialog_tooltip"
                    color="primary"
                    onClick={() => {
                        setOpenConfirmDialog(true)
                    }}
                >
                    <DeleteIcon/>
                </IconButton>
            </Tooltip>
            <Dialog maxWidth="sm" open={openConfirmDialog}
                    PaperProps={{sx: {boxShadow: 'rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px'}}}>
                <DeleteContent rowId={rowId} mutate={mutate} setOpenConfirmDialog={setOpenConfirmDialog}/>
            </Dialog>
        </>
    );
};
export default DeleteForm;