import {Button, Dialog, DialogTitle, Stack, Tooltip} from "@mui/material";
import DataSaverOnIcon from "@mui/icons-material/DataSaverOn";
import {useTranslations} from "next-intl";
import {useState} from "react";
import CreateContent from "./CreateContent";

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

    return (
        <Stack direction={"row"} spacing={2}>
            <Tooltip title={t("AddDialog.add")} arrow placement="right">
                <Button
                    color="primary"
                    variant="contained"
                    size="small"
                    sx={{textTransform: "unset", alignSelf: "center"}}
                    startIcon={<DataSaverOnIcon/>}
                    onClick={() => {
                        setOpenConfirmDialog(true)
                    }}
                >
                    {t("AddDialog.add")}
                </Button>
            </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("AddDialog.add")}</DialogTitle>
                <CreateContent mutate={mutate} setOpenConfirmDialog={setOpenConfirmDialog}/>
            </Dialog>
        </Stack>
    )
}
export default CreateForm