import React from 'react';
import Image from 'next/image';

interface ImageDimensionI {
  width?: number;
  height?: number;
  alt?: string;
  src: string;
  classname?: string;
}

const CommonImage = ({
  src,
  width = 100,
  height = 100,
  alt = '',
  classname = '',
}: ImageDimensionI) => {
  return (
    <Image
      src={src !== '' ? src : '/header/no-image.png'}
      width={width}
      height={height}
      alt={alt}
      title={alt}
      priority={false}
      className={classname}
      onError={(e) => {
        e.currentTarget.src = '/main/cross-arrow.webp';
      }}
    />
  );
};

export default CommonImage;
