Skip to content

Commit

Permalink
👻 Convert sh & shg to refs on waves to match api
Browse files Browse the repository at this point in the history
  • Loading branch information
ibolton336 committed Oct 2, 2023
1 parent 0275e63 commit 00d40d9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
4 changes: 2 additions & 2 deletions client/src/app/api/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,8 @@ export interface MigrationWave {
startDate: string;
endDate: string;
applications: Ref[];
stakeholders: Stakeholder[];
stakeholderGroups: StakeholderGroup[];
stakeholders: Ref[];
stakeholderGroups: Ref[];
}

export type IssueManagerKind = "jira-cloud" | "jira-onprem";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
import { OptionWithValue, SimpleSelect } from "@app/components/SimpleSelect";
import { NotificationsContext } from "@app/components/NotificationsContext";
import { DEFAULT_SELECT_MAX_HEIGHT } from "@app/Constants";
import { matchItemsToRefs } from "@app/utils/model-utils";

const stakeholderGroupToOption = (
value: StakeholderGroup
Expand Down Expand Up @@ -226,13 +227,26 @@ export const WaveForm: React.FC<WaveFormProps> = ({
: null;

const onSubmit = (formValues: WaveFormValues) => {
const stakeholders = [
...(stakeholdersToRefs(
formValues.stakeholders.map((stakeholder) => stakeholder.name)
) ?? []),
];

const stakeholderGroups = [
...(stakeholderGroupsToRefs(
formValues.stakeholderGroups.map(
(stakeholderGroup) => stakeholderGroup.name
)
) ?? []),
];
const payload: New<MigrationWave> = {
applications: migrationWave?.applications || [],
name: formValues.name?.trim() || "",
startDate: dayjs(formValues.startDateStr).format(),
endDate: dayjs(formValues.endDateStr).format(),
stakeholders: formValues.stakeholders,
stakeholderGroups: formValues.stakeholderGroups,
stakeholders: stakeholders,
stakeholderGroups: stakeholderGroups,
};
if (migrationWave)
updateMigrationWave({
Expand All @@ -259,6 +273,15 @@ export const WaveForm: React.FC<WaveFormProps> = ({
return "";
};

// const stakeholdersToRefs = (name: string | undefined | null) =>
// matchItemsToRef(stakeholders, (i) => i.name, name);

const stakeholdersToRefs = (names: string[] | undefined | null) =>
matchItemsToRefs(stakeholders, (i) => i.name, names);

const stakeholderGroupsToRefs = (names: string[] | undefined | null) =>
matchItemsToRefs(stakeholderGroups, (i) => i.name, names);

return (
<Form onSubmit={handleSubmit(onSubmit)}>
<Grid hasGutter>
Expand Down

0 comments on commit 00d40d9

Please sign in to comment.