import { Modal, Box, ButtonGroup, Button, Scrollable, Callout, Margins, Icon } from '@rocket.chat/fuselage'; import { useMutableCallback } from '@rocket.chat/fuselage-hooks'; import React, { useState } from 'react'; import { useToastMessageDispatch } from '../../../contexts/ToastMessagesContext'; import { useTranslation } from '../../../contexts/TranslationContext'; import { useEndpointActionExperimental } from '../../../hooks/useEndpointActionExperimental'; const OfflineLicenseModal = ({ onClose, license, licenseStatus, ...props }) => { const t = useTranslation(); const dispatchToastMessage = useToastMessageDispatch(); const [newLicense, setNewLicense] = useState(license); const [isUpdating, setIsUpdating] = useState(false); const [status, setStatus] = useState(licenseStatus); const [lastSetLicense, setLastSetLicense] = useState(license); const handleNewLicense = (e) => { setNewLicense(e.currentTarget.value); }; const hasChanges = lastSetLicense !== newLicense; const addLicense = useEndpointActionExperimental('POST', 'licenses.add', t('Cloud_License_applied_successfully')); const handlePaste = useMutableCallback(async () => { try { const text = await navigator.clipboard.readText(); setNewLicense(text); } catch (error) { dispatchToastMessage({ type: 'error', message: `${t('Paste_error')}: ${error}` }); } }); const handleApplyLicense = useMutableCallback(async () => { setIsUpdating(true); setLastSetLicense(newLicense); const data = await addLicense({ license: newLicense }); if (data.success) { onClose(); return; } setIsUpdating(false); setStatus('invalid'); }); return ( {t('Cloud_Apply_Offline_License')}

{t('Cloud_register_offline_finish_helper')}

{status === 'invalid' && {t('Cloud_Invalid_license')}}
); }; export default OfflineLicenseModal;