import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"
import { useTranslations } from "next-intl";
import { useState } from "react";
import EditIcon from '@mui/icons-material/Edit';
import UpdateContent from "./UpdateContent";

const Update = ({row, fetchUrl, mutate}) => {
    const t = useTranslations();
    const [openConfirmDialog, setOpenConfirmDialog] = useState(false);
    
    return (
        <>
            <Tooltip title={t("UpdateDialog.update-tooltip")}>
                <IconButton
                    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'}}}>
                <DialogTitle>{t("UpdateDialog.update")}</DialogTitle>
                <UpdateContent row={row} fetchUrl={fetchUrl} mutate={mutate} setOpenConfirmDialog={setOpenConfirmDialog} />
            </Dialog>
        </>
    )
}
export default Update