0
owncast/web/pages/config-public-details.tsx

65 lines
1.7 KiB
TypeScript
Raw Normal View History

import React, { useContext, useEffect } from 'react';
import { Typography, Form } from 'antd';
2020-12-26 19:44:09 -08:00
import TextField, { TEXTFIELD_TYPE_TEXTAREA } from './components/config/form-textfield';
2020-12-26 18:04:23 -08:00
import EditInstanceTags from './components/config/tags';
import { ServerStatusContext } from '../utils/server-status-context';
2020-12-26 18:04:23 -08:00
const { Title } = Typography;
export default function PublicFacingDetails() {
const [form] = Form.useForm();
2020-12-26 18:04:23 -08:00
const serverStatusData = useContext(ServerStatusContext);
const { serverConfig } = serverStatusData || {};
2020-12-26 18:04:23 -08:00
const { instanceDetails = {} } = serverConfig;
console.log(serverConfig)
useEffect(() => {
form.setFieldsValue({...instanceDetails});
}, [instanceDetails]);
const handleResetValue = (fieldName: string) => {
form.setFieldsValue({ [fieldName]: instanceDetails[fieldName]});
}
const extraProps = {
handleResetValue,
initialValues: instanceDetails,
};
2020-12-26 18:04:23 -08:00
return (
<>
<Title level={2}>Edit your public facing instance details</Title>
2020-12-26 18:04:23 -08:00
<div className="config-public-details-container">
2020-12-26 19:44:09 -08:00
<div className="text-fields">
<Form
form={form}
layout="vertical"
>
<TextField fieldName="name" {...extraProps} />
<TextField fieldName="summary" type={TEXTFIELD_TYPE_TEXTAREA} {...extraProps} />
<TextField fieldName="title" {...extraProps} />
<TextField fieldName="streamTitle" {...extraProps} />
2020-12-26 19:44:09 -08:00
</Form>
2020-12-26 18:04:23 -08:00
</div>
2020-12-29 14:47:31 -08:00
<div className="misc-fields">
{/* add social handles comp
2020-12-26 18:04:23 -08:00
<br/>
add tags comp */}
<EditInstanceTags />
2020-12-26 18:04:23 -08:00
</div>
</div>
</>
);
}