import { LazyLoadImage } from 'react-lazy-load-image-component'
import 'react-lazy-load-image-component/src/effects/opacity.css'

/**
 * The `Image` component is used to display lazy-loaded images.
 *
 * @param {Object} props - Props passed to the `Image` component.
 * @param {string} props.src - URL of the image to be displayed.
 * @param {string} props.alt - Alternative text to be displayed if the image is not found.
 * @returns {JSX.Element} - Rendered `Image` component.
 */
const Image = ({ ...props }) => (
  <>
    <LazyLoadImage
      {...props}
      src={props.src || '/images/noimage.jpeg'}
      placeholderSrc='/images/indoteknik-placeholder.png'
      effect='opacity'
      alt={props.src ? props.alt : 'Image Not Found - Indoteknik'}
      wrapperClassName='bg-white'
      loading='eager'
    />
  </>
)

Image.defaultProps = LazyLoadImage.defaultProps

export default Image
