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(() => { const modalEl = modalRef.current; if (window.Tabler && window.Tabler.Modal && modalEl) { const modalInstance = window.Tabler.Modal.getOrCreateInstance(modalEl); if (show) { modalInstance.show(); } else { modalInstance.hide(); } const handler = () => onClose && onClose(); modalEl.addEventListener('hide.bs.modal', handler); return () => { modalEl.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 (
Генератор ссылок для {server?.ip}
Настройки URL
handleSettingChange('baseUrl', e.target.value)} placeholder="https://functions.yandexcloud.net/d4eno3im0qgsr4tj5hdo" />
handleSettingChange('cloudflare_gateway', e.target.value)} placeholder="SWE-IHOR или IP" />
handleSettingChange('bunny_gateway', e.target.value)} placeholder="SWE-IHOR или IP" />
handleSettingChange('fastly_gateway', e.target.value)} placeholder="SWE-IHOR или IP" />
handleSettingChange('telegram_gateway', e.target.value)} placeholder="IP адрес" />
handleSettingChange('hetzner_gateway', e.target.value)} placeholder="IP адрес" />
handleSettingChange('type', e.target.value)} placeholder="routes" />
handleSettingChange('version', e.target.value)} placeholder="v4.rsc" />
Сгенерированная ссылка
); } export default LinkGeneratorModal;