import {
    Dialog,
    DialogContent,
    DialogHeader,
    DialogTitle,
} from '@/components/ui/dialog';

type ImagePreviewModalProps = {
    open: boolean;
    onOpenChange: (open: boolean) => void;
    src: string | null;
    title?: string;
    alt?: string;
};

export function ImagePreviewModal({
    open,
    onOpenChange,
    src,
    title,
    alt = 'Preview',
}: ImagePreviewModalProps) {
    return (
        <Dialog open={open} onOpenChange={onOpenChange}>
            <DialogContent showCloseButton>
                {title && (
                    <DialogHeader>
                        <DialogTitle>{title}</DialogTitle>
                    </DialogHeader>
                )}
                {src && (
                    <img
                        src={src}
                        alt={alt}
                        className="max-h-[80vh] w-full rounded-lg object-contain"
                    />
                )}
            </DialogContent>
        </Dialog>
    );
}
