import { Button } from "@mui/material";
import { useState } from "react";

function ButtonApply({ sendReq, setOpen }) {
  const [loading, setLoading] = useState(false);

  const handleClick = () => {
    setLoading(true);

    setOpen(false);
    sendReq().finally(() => {
      setLoading(false);
    });
  };

  return (
    <div className="flex justify-end w-full">
      <Button
        disabled={loading}
        variant="contained"
        onClick={handleClick}
        className="!px-3 !py-2 !text-[16px] !font-medium"
      >
        اعمال تغییرات
      </Button>
    </div>
  );
}

export default ButtonApply;
