From 93cdb7fed39a9e69a7543c7d36f1846f26c55bdf Mon Sep 17 00:00:00 2001 From: ibolton336 Date: Mon, 2 Oct 2023 16:04:37 -0400 Subject: [PATCH] :bug: Update migration wave app list update to match api changes Signed-off-by: ibolton336 --- .../components/migration-wave-form.tsx | 15 +++++++-------- .../pages/migration-waves/migration-waves.tsx | 17 ++++++++++++++--- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/client/src/app/pages/migration-waves/components/migration-wave-form.tsx b/client/src/app/pages/migration-waves/components/migration-wave-form.tsx index 5735f5e0c6..1097c12183 100644 --- a/client/src/app/pages/migration-waves/components/migration-wave-form.tsx +++ b/client/src/app/pages/migration-waves/components/migration-wave-form.tsx @@ -227,19 +227,18 @@ export const WaveForm: React.FC = ({ : null; const onSubmit = (formValues: WaveFormValues) => { - const stakeholders = [ - ...(stakeholdersToRefs( + const stakeholders = + stakeholdersToRefs( formValues.stakeholders.map((stakeholder) => stakeholder.name) - ) ?? []), - ]; + ) ?? []; - const stakeholderGroups = [ - ...(stakeholderGroupsToRefs( + const stakeholderGroups = + stakeholderGroupsToRefs( formValues.stakeholderGroups.map( (stakeholderGroup) => stakeholderGroup.name ) - ) ?? []), - ]; + ) ?? []; + const payload: New = { applications: migrationWave?.applications || [], name: formValues.name?.trim() || "", diff --git a/client/src/app/pages/migration-waves/migration-waves.tsx b/client/src/app/pages/migration-waves/migration-waves.tsx index e71c81e4e7..7370057484 100644 --- a/client/src/app/pages/migration-waves/migration-waves.tsx +++ b/client/src/app/pages/migration-waves/migration-waves.tsx @@ -67,6 +67,7 @@ import { ConditionalRender } from "@app/components/ConditionalRender"; import { AppPlaceholder } from "@app/components/AppPlaceholder"; import { ToolbarBulkSelector } from "@app/components/ToolbarBulkSelector"; import { ConfirmDialog } from "@app/components/ConfirmDialog"; +import { toRefs } from "@app/utils/model-utils"; export const MigrationWaves: React.FC = () => { const { t } = useTranslation(); @@ -160,10 +161,20 @@ export const MigrationWaves: React.FC = () => { ); const removeApplication = (migrationWave: MigrationWave, id: number) => { - migrationWave.applications = migrationWave.applications.filter( - (application) => application.id !== id + const applicationRefs = toRefs( + migrationWave.applications.filter((application) => application.id !== id) ); - updateMigrationWave(migrationWave); + const payload: MigrationWave = { + id: migrationWave.id, + name: migrationWave.name, + startDate: migrationWave.startDate, + endDate: migrationWave.endDate, + stakeholderGroups: migrationWave.stakeholderGroups, + stakeholders: migrationWave.stakeholders, + applications: applicationRefs || [], + }; + + updateMigrationWave(payload); }; const tableControls = useLocalTableControls({