import {Dialog, IconButton, Stack, Tooltip} from "@mui/material";
import {useTranslations} from "next-intl";
import {useState} from "react";
import UpdateContent from "@/components/dashboard/role-management/Form/UpdateForm/UpdateContent";
import EditIcon from "@mui/icons-material/Edit";

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

    return (
        <Stack direction={"row"} spacing={2}>
            <Tooltip title={t("UpdateDialog.update")} arrow placement="right">
                <IconButton
                    data-testid="dialog_tooltip"
                    color="primary"
                    onClick={() => {
                        setOpenConfirmDialog(true);
                    }}
                >
                    <EditIcon/>
                </IconButton>
            </Tooltip>
            <Dialog maxWidth={"md"} 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'}}}>
                <UpdateContent mutate={mutate} row={row} setOpenConfirmDialog={setOpenConfirmDialog}/>
            </Dialog>
        </Stack>
    )
}
export default UpdateForm