-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormEditor.tsx
More file actions
28 lines (24 loc) · 752 Bytes
/
FormEditor.tsx
File metadata and controls
28 lines (24 loc) · 752 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { FunctionComponent } from "react";
import validator from "@rjsf/validator-ajv8";
import { withTheme } from "@rjsf/core";
import { Theme } from "@rjsf/mui";
import { jsonSchema } from "../jsonSchema";
import { getConfig, putConfig } from "../configuration";
const log = (type: any) => console.log.bind(console, type);
const Form = withTheme(Theme);
function saveConf(event: any) {
putConfig(event.formData);
window.alert("Reloading page to reflect changes");
window.location.reload();
}
const FormEditor: FunctionComponent = () => (
<Form
formData={getConfig()}
schema={jsonSchema}
validator={validator}
onChange={log("changed")}
onSubmit={saveConf}
onError={log("errors")}
/>
);
export default FormEditor;