import { Button, Dialog, DialogActions, DialogTitle, IconButton, Tooltip } from "@mui/material";
import DirectionsCarIcon from "@mui/icons-material/DirectionsCar";
import { useState } from "react";
import MachinesContent from "./MachinesContent";

const MachinesDialog = ({ rowId }) => {
    const [openMachinesDialog, setOpenMachinesDialog] = useState(false);
    return (
        <>
            <Tooltip title="خودرو">
                <IconButton color="primary" onClick={() => setOpenMachinesDialog(true)}>
                    <DirectionsCarIcon />
                </IconButton>
            </Tooltip>
            <Dialog
                fullWidth
                open={openMachinesDialog}
                onClose={() => setOpenMachinesDialog(false)}
                PaperProps={{
                    sx: {
                        boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
                    },
                }}
                dir="rtl"
                maxWidth={"sm"}
            >
                <DialogTitle sx={{ fontSize: "large" }}>اطلاعات خودرو</DialogTitle>
                {openMachinesDialog && <MachinesContent rowId={rowId} />}
                <DialogActions>
                    <Button onClick={() => setOpenMachinesDialog(false)} variant="outlined" color="secondary" autoFocus>
                        بستن
                    </Button>
                </DialogActions>
            </Dialog>
        </>
    );
};
export default MachinesDialog;
