import React, { useContext, useState } from 'react'; import { Table, Space, Button, Typography, Alert, Input, Form } from 'antd'; import dynamic from 'next/dynamic'; import { ServerStatusContext } from '../../../../utils/server-status-context'; import { fetchData, UPDATE_STREAM_KEYS } from '../../../../utils/apis'; const { Paragraph } = Typography; const { Item } = Form; // Lazy loaded components const DeleteOutlined = dynamic(() => import('@ant-design/icons/DeleteOutlined'), { ssr: false, }); const EyeOutlined = dynamic(() => import('@ant-design/icons/EyeOutlined'), { ssr: false, }); const PlusOutlined = dynamic(() => import('@ant-design/icons/PlusOutlined'), { ssr: false, }); const saveKeys = async (keys, setError) => { try { await fetchData(UPDATE_STREAM_KEYS, { method: 'POST', auth: true, data: { value: keys }, }); } catch (error) { console.error(error); setError(error); } }; const AddKeyForm = ({ setShowAddKeyForm, setFieldInConfigState, streamKeys, setError }) => { const handleAddKey = (newkey: any) => { const updatedKeys = [...streamKeys, newkey]; setFieldInConfigState({ fieldName: 'streamKeys', value: updatedKeys, }); saveKeys(updatedKeys, setError); setShowAddKeyForm(false); }; return (
The key you provide your broadcasting software. Please note that the key must be a minimum of eight characters and must include at least one uppercase letter, at least one lowercase letter, at least one special character, and at least one number.

} rules={[ { min: 8, message: '- minimum 8 characters' }, { max: 192, message: '- maximum 192 characters' }, { pattern: /^(?=.*[a-z])/, message: '- at least one lowercase letter', }, { pattern: /^(?=.*[A-Z])/, message: '- at least one uppercase letter', }, { pattern: /\d/, message: '- at least one digit', }, { pattern: /^(?=.*?[#?!@$%^&*-])/, message: '- at least one special character: !@#$%^&*', }, ]} >
); }; const AddKeyButton = ({ setShowAddKeyForm }) => ( ); const StreamKeys = () => { const serverStatusData = useContext(ServerStatusContext); const { serverConfig, setFieldInConfigState } = serverStatusData || {}; const { streamKeys } = serverConfig; const [showAddKeyForm, setShowAddKeyForm] = useState(false); const [showKeyMap, setShowKeyMap] = useState({}); const [error, setError] = useState(null); const handleDeleteKey = keyToRemove => { const newKeys = streamKeys.filter(k => k !== keyToRemove); setFieldInConfigState({ fieldName: 'streamKeys', value: newKeys, }); saveKeys(newKeys, setError); }; const handleToggleShowKey = key => { setShowKeyMap({ ...showKeyMap, [key]: !showKeyMap[key], }); }; const columns = [ { title: 'Key', dataIndex: 'key', key: 'key', render: text => ( {showKeyMap[text] ? text : '**********'}