Skip to content

Commit 20ba832

Browse files
committed
Fix building of createWiki request body
1 parent f1f4cfe commit 20ba832

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

src/components/Cards/CreateWiki.vue

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -136,28 +136,30 @@ export default {
136136
domainToSubmit = this.stepOne.domain
137137
}
138138
139-
const profileJSObject = {
139+
const profileObject = {
140140
purpose: this.stepTwo.purpose,
141141
...(this.stepTwo.otherPurpose && { purpose_other: this.stepTwo.otherPurpose }),
142142
...(this.stepTwo.audience && { audience: this.stepTwo.audience }),
143143
...(this.stepTwo.otherAudience && { audience_other: this.stepTwo.otherAudience }),
144144
temporality: this.stepThree.temporality,
145145
...(this.stepThree.otherTemporality && { temporality_other: this.stepThree.otherTemporality })
146146
}
147-
const profileJsonString = JSON.stringify(profileJSObject)
148147
149-
this.$api.createWiki(
150-
{
151-
domain: domainToSubmit,
152-
sitename: this.stepOne.sitename,
153-
username: this.stepOne.username,
154-
profile: profileJsonString,
155-
knowledgeEquityResponse: {
156-
selectedOption: this.stepFour.selectedOption,
157-
freeTextResponse: this.stepFour.freeTextResponse
158-
}
148+
const requestBody = {
149+
domain: domainToSubmit,
150+
sitename: this.stepOne.sitename,
151+
username: this.stepOne.username,
152+
profile: JSON.stringify(profileObject)
153+
}
154+
155+
if (this.stepThree.temporality == "permanent" && this.stepFour.selectedOption) {
156+
requestBody.knowledgeEquityResponse = {
157+
selectedOption: this.stepFour.selectedOption,
158+
freeTextResponse: this.stepFour.freeTextResponse
159159
}
160-
)
160+
}
161+
162+
this.$api.createWiki(requestBody)
161163
.then(wikiDetails => this.createSuccess(wikiDetails))
162164
.catch(errors => this.createFail(errors))
163165
},

0 commit comments

Comments
 (0)