Skip to content

Commit

Permalink
fix what id we pass (#520)
Browse files Browse the repository at this point in the history
  • Loading branch information
sharlotta93 authored Nov 13, 2024
1 parent c33b982 commit dcfe647
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,19 @@ export const pushFormResponseToHealthie: Action<
},
},
})
const formAnswerGroupId =
res?.createFormAnswerGroup?.form_answer_group?.id

if (isEmpty(res?.createFormAnswerGroup?.form_answer_group?.id))
if (isEmpty(formAnswerGroupId))
throw new HealthieFormResponseNotCreated(res)

// separate call to lock the form if needed
if (lock) {
if (lock && formAnswerGroupId !== undefined) {
await healthieSdk.client.mutation({
lockFormAnswerGroup: {
__args: {
input: {
id: fields.healthieFormId,
id: formAnswerGroupId,
},
},
form_answer_group: {
Expand All @@ -104,9 +106,7 @@ export const pushFormResponseToHealthie: Action<

await onComplete({
data_points: {
formAnswerGroupId: String(
res.createFormAnswerGroup?.form_answer_group?.id
),
formAnswerGroupId: String(formAnswerGroupId),
},
events: getSubActivityLogs(omittedFormAnswers),
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,19 @@ export const pushFormResponsesToHealthie: Action<
},
},
})
const formAnswerGroupId =
res?.createFormAnswerGroup?.form_answer_group?.id

if (isEmpty(res?.createFormAnswerGroup?.form_answer_group?.id))
if (isEmpty(formAnswerGroupId))
throw new HealthieFormResponseNotCreated(res)

// separate call to lock the form if needed
if (lock) {
if (lock && formAnswerGroupId !== undefined) {
await healthieSdk.client.mutation({
lockFormAnswerGroup: {
__args: {
input: {
id: fields.healthieFormId,
id: formAnswerGroupId,
},
},
form_answer_group: {
Expand All @@ -110,9 +112,7 @@ export const pushFormResponsesToHealthie: Action<
}
await onComplete({
data_points: {
formAnswerGroupId: String(
res.createFormAnswerGroup?.form_answer_group?.id
),
formAnswerGroupId: String(formAnswerGroupId),
},
events: getSubActivityLogs(mergedOmittedFormAnswers),
})
Expand Down

0 comments on commit dcfe647

Please sign in to comment.