diff --git a/striker-ui/components/StrikerInitForm.tsx b/striker-ui/components/StrikerInitForm.tsx index 7794d7c1..0fdf8c8b 100644 --- a/striker-ui/components/StrikerInitForm.tsx +++ b/striker-ui/components/StrikerInitForm.tsx @@ -1,52 +1,64 @@ -import { FC, useRef, useState } from 'react'; +import { FC, useMemo, useRef, useState } from 'react'; import ContainedButton from './ContainedButton'; import FlexBox from './FlexBox'; import GeneralInitForm, { GeneralInitFormForwardRefContent, } from './GeneralInitForm'; +import mainAxiosInstance from '../lib/singletons/mainAxiosInstance'; import NetworkInitForm, { NetworkInitFormForwardRefContent, } from './NetworkInitForm'; import { Panel, PanelHeader } from './Panels'; -import { BodyText, HeaderText } from './Text'; +import Spinner from './Spinner'; +import { HeaderText } from './Text'; const StrikerInitForm: FC = () => { - const [requestBody, setRequestBody] = useState< - Record | undefined - >(); + const [isSubmittingForm, setIsSubmittingForm] = useState(false); const generalInitFormRef = useRef({}); const networkInitFormRef = useRef({}); - return ( - - - - - - - + const buildSubmitSection = useMemo( + () => + isSubmittingForm ? ( + + ) : ( { - setRequestBody({ + setIsSubmittingForm(true); + + const requestBody: string = JSON.stringify({ ...(generalInitFormRef.current.get?.call(null) ?? {}), ...(networkInitFormRef.current.get?.call(null) ?? {}), }); + + mainAxiosInstance + .put('/command/initialize-striker', requestBody, { + headers: { 'Content-Type': 'application/json' }, + }) + .then(() => { + setIsSubmittingForm(false); + }); }} > Initialize - {requestBody && ( -
-            
-          
- )} + ), + [isSubmittingForm], + ); + + return ( + + + + + + + + {buildSubmitSection} );