"use client";
import { Button, IconButton, useMediaQuery } from "@mui/material";
import { useTheme } from "@emotion/react";
import { useState } from "react";
import { AddCircle } from "@mui/icons-material";
import OperatorCreateForm from "./Forms";

const OperatorCreate = ({ mutate }) => {
    const theme = useTheme();
    const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
    const [open, setOpen] = useState(false);

    const handleOpen = () => {
        setOpen(true);
    };

    return (
        <>
            {isMobile ? (
                <IconButton aria-label="ثبت فعالیت" color="primary" onClick={handleOpen}>
                    <AddCircle sx={{ fontSize: "25px" }} />
                </IconButton>
            ) : (
                <Button
                    size={"small"}
                    variant="contained"
                    color="primary"
                    startIcon={<AddCircle />}
                    onClick={handleOpen}
                >
                    ثبت فعالیت
                </Button>
            )}
            <OperatorCreateForm open={open} setOpen={setOpen} mutate={mutate} />
        </>
    );
};
export default OperatorCreate;
