import { useRef, useState } from 'react'; import copyToClipboard from 'copy-to-clipboard'; import { channelAPI } from '../../../api'; import { clsm } from '../../../utils'; import { CreateVideo } from '../../../assets/icons'; import { dashboard as $content } from '../../../content'; import { INPUT_BUTTON_GROUP_CLASSES, SETTINGS_SECTION_CLASSES } from '../SettingsTheme'; import { useModal } from '../../../contexts/Modal'; import { useNotif } from '../../../contexts/Notification'; import { useSettingsOrientation } from '../Settings'; import { useUser } from '../../../contexts/User'; import Button from '../../../components/Button'; import CopyTextInput from '../CopyTextInput'; import Input from '../../../components/Input'; import { useResponsiveDevice } from '../../../contexts/ResponsiveDevice'; const StreamSettings = () => { const { isDesktopView } = useResponsiveDevice(); const resetStreamKeyButtonRef = useRef(); const [isResetStreamKeyLoading, setIsResetStreamKeyLoading] = useState(false); const { notifySuccess, notifyError } = useNotif(); const { openModal } = useModal(); const { userData, fetchUserData } = useUser(); const settingsFormOrientation = useSettingsOrientation(); const copyStreamKey = () => { copyToClipboard(userData.streamKeyValue); notifySuccess($content.notification.success.stream_key_copied); }; const handleResetStreamKey = () => { if (isResetStreamKeyLoading) return; const resetStreamKey = async () => { setIsResetStreamKeyLoading(true); const { result, error } = await channelAPI.resetStreamKey(); if (result) { await fetchUserData(); notifySuccess($content.notification.success.stream_key_reset); } if (error) notifyError($content.notification.error.reset_stream_key_failed); setIsResetStreamKeyLoading(false); }; openModal({ content: { confirmText: $content.modal.reset_stream_key_modal.reset_stream_key, isDestructive: true, message: $content.modal.reset_stream_key_modal.confirm_intent_message, subMessage: $content.modal.reset_stream_key_modal.stream_will_terminate }, lastFocusedElement: resetStreamKeyButtonRef, onConfirm: resetStreamKey }); }; return (

{$content.settings_page.stream_settings}

); }; export default StreamSettings;