fix(striker-ui): reflect GateForm changes in PrepareHostForm

main
Tsu-ba-me 2 years ago
parent 7f826132a4
commit 4fc2655a44
  1. 38
      striker-ui/components/PrepareHostForm.tsx
  2. 8
      striker-ui/types/APICommand.d.ts

@ -198,7 +198,7 @@ const PrepareHostForm: FC = () => {
const accessSection = useMemo(
() => (
<GateForm
formContainer={isShowAccessSubmit}
allowSubmit={isShowAccessSubmit}
gridProps={{
wrapperBoxProps: {
sx: {
@ -218,26 +218,18 @@ const PrepareHostForm: FC = () => {
}
}}
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<APICommandInquireHostResponseBody>(
'/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"

@ -0,0 +1,8 @@
type APICommandInquireHostResponseBody = {
hostName: string;
hostOS: string;
hostUUID: string;
isConnected: boolean;
isInetConnected: boolean;
isOSRegistered: boolean;
};
Loading…
Cancel
Save