import React, { useContext, useEffect } from 'react'; import { Typography, Form } from 'antd'; import TextField, { TEXTFIELD_TYPE_NUMBER, TEXTFIELD_TYPE_PASSWORD, TEXTFIELD_TYPE_TEXTAREA } from './components/config/form-textfield'; import { ServerStatusContext } from '../utils/server-status-context'; import { TEXTFIELD_DEFAULTS } from './components/config/constants'; const { Title } = Typography; export default function ConfigServerDetails() { const [form] = Form.useForm(); const serverStatusData = useContext(ServerStatusContext); const { serverConfig } = serverStatusData || {}; const { ffmpegPath, streamKey, webServerPort, rtmpServerPort } = serverConfig; const initialValues = { ffmpegPath, streamKey, webServerPort, rtmpServerPort, }; useEffect(() => { form.setFieldsValue(initialValues); }, [serverStatusData]); const handleResetValue = (fieldName: string) => { const defaultValue = TEXTFIELD_DEFAULTS[fieldName] && TEXTFIELD_DEFAULTS[fieldName].defaultValue || ''; form.setFieldsValue({ [fieldName]: initialValues[fieldName] || defaultValue }); } const extraProps = { handleResetValue, initialValues, configPath: '', }; return ( <> Edit your Server's details
); }