import React from "react";
import { Spin } from "antd";
import "./fullpageLoader.css";
import Lottie from "lottie-react";
import loaderJson from "../../assets/images/loaderJson.json";

const Spinner = (props) => {
  const { spinning = true, children, size = "medium", tip = "", fullscreen = false, ...rest } = props;

  return (
    <>
      {fullscreen ? (
        <div className="loader-overlay">
          <div className="loader-container">
            <Lottie
              animationData={loaderJson} // Pass the JSON animation data
              loop={true} // Loop the animation
              autoplay={true} // Autoplay the animation
              style={{ height: 250, width: 250 }} // Adjust size as needed
            />
          </div>
        </div>
      ) : (
        <Spin spinning={spinning} size={size} tip={tip} {...rest}>
          {children}
        </Spin>
      )}
    </>
  );
};

export default Spinner;
