Skip to content

Commit

Permalink
🐛 Update migration wave app list update to match api changes
Browse files Browse the repository at this point in the history
Signed-off-by: ibolton336 <[email protected]>
  • Loading branch information
ibolton336 committed Oct 3, 2023
1 parent e4dbcf7 commit 93cdb7f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,19 +227,18 @@ export const WaveForm: React.FC<WaveFormProps> = ({
: 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<MigrationWave> = {
applications: migrationWave?.applications || [],
name: formValues.name?.trim() || "",
Expand Down
17 changes: 14 additions & 3 deletions client/src/app/pages/migration-waves/migration-waves.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit 93cdb7f

Please sign in to comment.