Skip to content

Commit

Permalink
Update Archetype form to work with hub backend
Browse files Browse the repository at this point in the history
Moving from the MSW stub for archetypes to the real hub archetype
endpoint, the create/update form payload needs to be adjusted.

Signed-off-by: Scott J Dickerson <sdickers@redhat.com>
  • Loading branch information
sjd78 committed Sep 20, 2023
1 parent c36b614 commit a1001e6
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import type {
Archetype,
New,
Ref,
Stakeholder,
StakeholderGroup,
Tag,
Expand Down Expand Up @@ -174,14 +175,20 @@ export const ArchetypeForm: React.FC<ArchetypeFormProps> = ({
? undefined
: (values.stakeholders
.map((name) => stakeholders.find((s) => s.name === name))
.filter(Boolean) as Stakeholder[]),
.map<Ref | undefined>((sh) =>
!sh ? undefined : { id: sh.id, name: sh.name }
)
.filter(Boolean) as Ref[]),

stakeholderGroups:
values.stakeholderGroups === undefined
? undefined
: (values.stakeholderGroups
.map((name) => stakeholderGroups.find((s) => s.name === name))
.filter(Boolean) as StakeholderGroup[]),
.map<Ref | undefined>((sg) =>
!sg ? undefined : { id: sg.id, name: sg.name }
)
.filter(Boolean) as Ref[]),
};

if (archetype && !isDuplicating) {
Expand All @@ -190,7 +197,7 @@ export const ArchetypeForm: React.FC<ArchetypeFormProps> = ({
createArchetype(payload);
}
};
console.log("values", getValues(), getFieldState("criteriaTags"), formState);

return (
<Form onSubmit={handleSubmit(onValidSubmit)} id="archetype-form">
<HookFormPFTextInput
Expand Down

0 comments on commit a1001e6

Please sign in to comment.