// app/components/admin/sidebar-widgets/ImageWidget.tsx
'use client';
import { ImageWidgetProps } from '@/lib/page-builder/container-types';

export default function ImageWidget({ title, src, alt = 'Image', link, caption }: ImageWidgetProps) {
  const img = (
    // eslint-disable-next-line @next/next/no-img-element
    <img src={src} alt={alt} className="w-full rounded-lg object-cover" />
  );

  return (
    <div className="sidebar-widget">
      {title && <h3 className="text-base font-semibold text-gray-900 mb-3 pb-2 border-b">{title}</h3>}
      {link ? <a href={link}>{img}</a> : img}
      {caption && <p className="text-xs text-gray-500 mt-1 text-center">{caption}</p>}
    </div>
  );
}