import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material";
import { useTranslations } from "next-intl";
import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt";
import { useState } from "react";
import ConfirmContent from "./ConfirmContent";

const Confirm = ({rowId, fetchUrl, mutate}) => {
    const t = useTranslations();
    const [openConfirmDialog, setOpenConfirmDialog] = useState(false);
    return(
        <>
            <Tooltip title={t("ConfirmDialog.confirm")}>
                <IconButton
                    color="primary"
                    onClick={() => {
                        setOpenConfirmDialog(true)
                    }}
                >
                    <ThumbUpAltIcon/>
                </IconButton>
            </Tooltip>
            <Dialog fullWidth 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("ConfirmDialog.confirm")}</DialogTitle>
                <ConfirmContent mutate={mutate} fetchUrl={fetchUrl} rowId={rowId} setOpenConfirmDialog={setOpenConfirmDialog} />
            </Dialog>
        </>
    )

}
export default Confirm;