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

const Create = ({mutate}) => {
    const t = useTranslations();
    const [openCreateDialog, setOpenCreateDialog] = useState(false);

    return (
        <>
            <Stack direction={"row"} spacing={2}>
                <Tooltip title={t("ExpertMangement.add")} arrow placement="right">
                    <Button
                        color="primary"
                        variant="contained"
                        size="small"
                        sx={{textTransform: "unset", alignSelf: "center"}}
                        startIcon={<DataSaverOnIcon/>}
                        onClick={() => {
                            setOpenCreateDialog(true)
                        }}
                    >
                        {t("ExpertMangement.add")}
                    </Button>
                </Tooltip>
            </Stack>
            <Dialog fullWidth maxWidth={'lg'} open={openCreateDialog}
                    TransitionProps={{unmountOnExit: true}}
                    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("ExpertMangement.create")}</DialogTitle>
                <CreateContent setOpenCreateDialog={setOpenCreateDialog} mutate={mutate}/>
            </Dialog>
        </>
    );
};

export default Create;
