Skip to content

Commit

Permalink
Merge pull request #4 from vtex-apps/fix/B2BTEAM-226/error-price-upda…
Browse files Browse the repository at this point in the history
…ting

Change custom session keys update for a fetch and remove unnecessary …
  • Loading branch information
alessandrasap authored Sep 11, 2020
2 parents 660f64f + f3ba698 commit 9b4712f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion node/resolvers/session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ export const mutations = {

ctx.response.set('Set-Cookie', response.headers['set-cookie'])

return queries.getCustomSessionKeys({}, {}, ctx)
return JSON.stringify(sessionData)
},
}
25 changes: 17 additions & 8 deletions react/components/FormHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,22 @@ export const FormHandler: FC<{
}
dispatchSubmitAction({ type: 'SET_LOADING' })

await updateCustomSessionKeyMutation({
variables: {
sessionData: { sessionData: { ...data } },
},
})
.then(async () => {
await updateOrderFormCustomData({
await fetch('/api/sessions/', {
method: 'POST',
body: JSON.stringify({
"public":{
"customSessionKeys":{
"value": JSON.stringify(data)
}
}
}),
credentials: 'same-origin',
headers: {
'Content-type': 'application/json; charset=UTF-8'
}
})

await updateOrderFormCustomData({
variables: {
appId: 'orderConfig',
field: 'values',
Expand All @@ -58,7 +67,7 @@ export const FormHandler: FC<{
const { onSuccessfulSubmit } = props
onSuccessfulSubmit()
})
})

.catch(e => {
setLastErrorFieldValues(data)

Expand Down

0 comments on commit 9b4712f

Please sign in to comment.