V2 Wizard: Fix AWS account id in review step (HMS-3553)

The AWS account id was not displayed correctly in the review step in the
case that a source was being used. This commit fixes the issue. When a
source is used, the AWS account id is fetched as before in order to
display it on the AWS step - but that value is also now dispatched to
the store so it can be referenced later (like in the review step).
This commit is contained in:
lucasgarfield 2024-02-28 14:01:03 +01:00 committed by Lucas Garfield
parent 5b662a39ea
commit a22f0deacc
2 changed files with 16 additions and 18 deletions

View file

@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect } from 'react';
import {
Alert,
@ -8,11 +8,15 @@ import {
FormGroup,
} from '@patternfly/react-core';
import { useAppSelector } from '../../../../../store/hooks';
import { useAppDispatch, useAppSelector } from '../../../../../store/hooks';
import { useGetSourceUploadInfoQuery } from '../../../../../store/provisioningApi';
import { selectAwsSource } from '../../../../../store/wizardSlice';
import {
changeAwsAccountId,
selectAwsSource,
} from '../../../../../store/wizardSlice';
export const AwsAccountId = () => {
const dispatch = useAppDispatch();
const source = useAppSelector((state) => selectAwsSource(state));
const { data, isError } = useGetSourceUploadInfoQuery(
@ -22,6 +26,10 @@ export const AwsAccountId = () => {
{ skip: source === undefined }
);
useEffect(() => {
dispatch(changeAwsAccountId(data?.aws?.account_id || ''));
}, [data?.aws?.account_id, dispatch]);
return (
<>
<FormGroup label="Associated Account ID" isRequired>