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 "@/components/dashboard/user-management/Form/CreateForm/CreateContent";

const CreateForm = ({mutate, fetchUrl}) => {
    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 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("AddDialog.add")}</DialogTitle>
                <CreateContent mutate={mutate} fetchUrl={fetchUrl} setOpenConfirmDialog={setOpenConfirmDialog}/>
            </Dialog>
        </Stack>
    )
}
export default CreateForm