import { useState, useEffect, useRef } from 'react'; import { IconLink, IconDownload } from '@tabler/icons-react'; /** * Модальное окно генератора ссылок для сервера */ function LinkGeneratorModal({ show, server, urlSettings, onUrlSettingsChange, onGenerateUrl, onCopyToClipboard, onClose }) { const modalRef = useRef(null); const [localUrlSettings, setLocalUrlSettings] = useState(urlSettings); useEffect(() => { setLocalUrlSettings(urlSettings); }, [urlSettings]); useEffect(() => { if (window.Tabler && window.Tabler.Modal && modalRef.current) { const modalInstance = window.Tabler.Modal.getOrCreateInstance(modalRef.current); if (show) { modalInstance.show(); } else { modalInstance.hide(); } const handler = () => onClose && onClose(); modalRef.current.addEventListener('hide.bs.modal', handler); return () => { if (modalRef.current) { modalRef.current.removeEventListener('hide.bs.modal', handler); } }; } }, [show, onClose]); const handleSettingChange = (key, value) => { const updated = { ...localUrlSettings, [key]: value }; setLocalUrlSettings(updated); onUrlSettingsChange(updated); }; const handleSaveSettings = () => { onUrlSettingsChange(localUrlSettings); localStorage.setItem('urlSettings', JSON.stringify(localUrlSettings)); }; const generatedUrl = server ? onGenerateUrl(server) : ''; return (