From f3ba69851df4464ada826e6b5a63e1a9e2f68673 Mon Sep 17 00:00:00 2001 From: Alessandra Date: Fri, 11 Sep 2020 09:22:40 -0300 Subject: [PATCH] Change custom session keys update for a fetch and remove unnecessary call to session API --- node/resolvers/session/index.ts | 2 +- react/components/FormHandler.tsx | 25 +++++++++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/node/resolvers/session/index.ts b/node/resolvers/session/index.ts index 5fa30c2..a763e56 100644 --- a/node/resolvers/session/index.ts +++ b/node/resolvers/session/index.ts @@ -34,6 +34,6 @@ export const mutations = { ctx.response.set('Set-Cookie', response.headers['set-cookie']) - return queries.getCustomSessionKeys({}, {}, ctx) + return JSON.stringify(sessionData) }, } diff --git a/react/components/FormHandler.tsx b/react/components/FormHandler.tsx index 33c7dda..18bfc2b 100644 --- a/react/components/FormHandler.tsx +++ b/react/components/FormHandler.tsx @@ -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', @@ -58,7 +67,7 @@ export const FormHandler: FC<{ const { onSuccessfulSubmit } = props onSuccessfulSubmit() }) - }) + .catch(e => { setLastErrorFieldValues(data)