import React from 'react'; import styles from './Popup.module.css'; import { useLanguage } from '../../../providers/language/LanguageContext'; // Action button interface export interface PopupAction { label: string; icon?: string | React.ReactElement; onClick: () => void; disabled?: boolean; loading?: boolean; variant?: 'primary' | 'secondary' | 'success' | 'danger'; } // Generic popup props export interface PopupProps { isOpen: boolean; title: string; onClose: () => void; children: React.ReactNode; footerContent?: React.ReactNode; className?: string; size?: 'small' | 'medium' | 'large' | 'fullscreen'; closable?: boolean; actions?: PopupAction[]; } // Generic Popup component - can be used for any content export function Popup({ isOpen, title, onClose, children, footerContent, className = '', size = 'medium', closable = true, actions = [] }: PopupProps) { const { t } = useLanguage(); // Handle escape key React.useEffect(() => { const handleEscape = (e: KeyboardEvent) => { if (e.key === 'Escape' && closable) { onClose(); } }; if (isOpen) { document.addEventListener('keydown', handleEscape); // Prevent body scroll when popup is open document.body.style.overflow = 'hidden'; } return () => { document.removeEventListener('keydown', handleEscape); document.body.style.overflow = 'unset'; }; }, [isOpen, closable, onClose]); if (!isOpen) return null; // Handle backdrop click const handleBackdropClick = (e: React.MouseEvent) => { if (e.target === e.currentTarget && closable) { onClose(); } }; return (