import React, { useState, useEffect } from "react";
import { IMAGE_BASE_URL } from "../../api/config";

interface ImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
  src: string;
}

const CustomImage: React.FC<ImageProps> = ({ src, ...props }) => {

  const [imgSrc, setImgSrc] = useState<any>(src);

  useEffect(() => {
    setImgSrc(src);
  }, [src,props]);



  const newImage = (imgSrc?.replace("public", "/storage"))
//   IMAGE_BASE_URL +

  return (
    <img
      src={newImage}
      {...props}
      alt="there is no image"
    />
  );
};

export default CustomImage;
