File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -5,9 +5,11 @@ import { useEffect, useState } from "react";
5
5
const useConfig = ( namespace : string ) => {
6
6
const [ config , setConfig ] = useState < JSONSchema6 > ( ) ;
7
7
8
- Axios . get ( "/api/webinterface/service/" + namespace ) . then ( ( res ) =>
9
- setConfig ( res . data )
10
- ) ;
8
+ useEffect ( ( ) => {
9
+ Axios . get ( "/api/webinterface/service/" + namespace ) . then ( ( res ) =>
10
+ setConfig ( res . data )
11
+ ) ;
12
+ } , [ namespace ] ) ;
11
13
12
14
return [ config , setConfig ] ;
13
15
} ;
Original file line number Diff line number Diff line change @@ -4,13 +4,15 @@ import Form from "react-jsonschema-form";
4
4
import { RouteComponentProps } from "react-router-dom" ;
5
5
import { JSONSchema6 } from "json-schema" ;
6
6
import useConfig from "../../hooks/configHook" ;
7
+ import Axios from "axios" ;
7
8
8
9
type ServiceDetailsProps = {
9
10
namespace : string ;
10
11
} ;
11
12
12
13
const ServiceDetails = ( props : RouteComponentProps < ServiceDetailsProps > ) => {
13
- const [ config , setConfig ] = useConfig ( props . match . params . namespace ) ;
14
+ const namespace = props . match . params . namespace ;
15
+ const [ config , setConfig ] = useConfig ( namespace ) ;
14
16
15
17
return (
16
18
< >
@@ -19,7 +21,9 @@ const ServiceDetails = (props: RouteComponentProps<ServiceDetailsProps>) => {
19
21
< Form
20
22
schema = { config as JSONSchema6 }
21
23
onChange = { ( ) => console . log ( "changed" ) }
22
- onSubmit = { ( ) => console . log ( "submitted" ) }
24
+ onSubmit = { ( e ) =>
25
+ Axios . post ( "/api/webinterface/service/" + namespace , e . formData )
26
+ }
23
27
onError = { ( ) => console . log ( "errors" ) }
24
28
/>
25
29
) }
You can’t perform that action at this time.
0 commit comments