From 4fc2655a4486f5c433c59d4a61e0e6d244b7f236 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Thu, 6 Apr 2023 14:49:18 -0400 Subject: [PATCH] fix(striker-ui): reflect GateForm changes in PrepareHostForm --- striker-ui/components/PrepareHostForm.tsx | 38 +++++++++-------------- striker-ui/types/APICommand.d.ts | 8 +++++ 2 files changed, 23 insertions(+), 23 deletions(-) create mode 100644 striker-ui/types/APICommand.d.ts diff --git a/striker-ui/components/PrepareHostForm.tsx b/striker-ui/components/PrepareHostForm.tsx index 7f416cfd..0ea5017e 100644 --- a/striker-ui/components/PrepareHostForm.tsx +++ b/striker-ui/components/PrepareHostForm.tsx @@ -198,7 +198,7 @@ const PrepareHostForm: FC = () => { const accessSection = useMemo( () => ( { } }} onSubmitAppend={( - { getValue: getIdentifier }, - { getValue: getPassphrase }, - setMessage, - setIsSubmitting, + ipAddress, + password, + setGateMessage, + setGateIsSubmitting, ) => { - const identifierValue = getIdentifier?.call(null); - const passphraseValue = getPassphrase?.call(null); + const body = { ipAddress, password }; api - .put<{ - hostName: string; - hostOS: string; - hostUUID: string; - isConnected: boolean; - isInetConnected: boolean; - isOSRegistered: boolean; - }>('/command/inquire-host', { - ipAddress: identifierValue, - password: passphraseValue, - }) + .put( + '/command/inquire-host', + body, + ) .then( ({ data: { @@ -265,14 +257,14 @@ const PrepareHostForm: FC = () => { setIsShowRedhatSection(true); } - setConnectedHostIPAddress(identifierValue); - setConnectedHostPassword(passphraseValue); + setConnectedHostIPAddress(ipAddress); + setConnectedHostPassword(password); setConnectedHostUUID(hostUUID); setIsShowAccessSubmit(false); setIsShowOptionalSection(true); } else { - setMessage?.call(null, { + setGateMessage({ children: `Failed to establish a connection with the given host credentials.`, type: 'error', }); @@ -282,10 +274,10 @@ const PrepareHostForm: FC = () => { .catch((apiError) => { const emsg = handleAPIError(apiError); - setMessage?.call(null, emsg); + setGateMessage?.call(null, emsg); }) .finally(() => { - setIsSubmitting(false); + setGateIsSubmitting(false); }); }} passphraseLabel="Host root password" diff --git a/striker-ui/types/APICommand.d.ts b/striker-ui/types/APICommand.d.ts new file mode 100644 index 00000000..e8a084d6 --- /dev/null +++ b/striker-ui/types/APICommand.d.ts @@ -0,0 +1,8 @@ +type APICommandInquireHostResponseBody = { + hostName: string; + hostOS: string; + hostUUID: string; + isConnected: boolean; + isInetConnected: boolean; + isOSRegistered: boolean; +};