'use client'; import { memo } from 'react'; import { Download, X } from 'lucide-react'; import { toast } from 'sonner'; import { Button } from '@/components/ui/button'; import { Dialog, DialogContent, DialogTitle } from '@/components/ui/dialog'; interface ImagePreviewDialogProps { previewImage: string | null; onClose: () => void; title?: string | null; downloadFileName?: string | null; canDownload?: boolean; } export const ImagePreviewDialog = memo(function ImagePreviewDialog({ previewImage, onClose, title, downloadFileName, canDownload = true, }: ImagePreviewDialogProps) { const resolvedDownloadName = downloadFileName || (previewImage ? previewImage.split('/').pop() || 'attachment.png' : 'attachment.png'); return ( !open && onClose()}> { event.stopPropagation(); if (event.key === 'Escape') { event.preventDefault(); onClose(); } }} > {title || 'Image Preview'}
e.stopPropagation()}>

{title || 'Image Preview'}

{canDownload ? ( ) : null}
{previewImage && ( // eslint-disable-next-line @next/next/no-img-element {title e.stopPropagation()} /> )}
); });