From f57c38264cdbdeb8b1a641fe56322f2908400edc Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Tue, 21 May 2024 20:33:30 +0300 Subject: [PATCH] get-main-data: fix selectOpportunity --- apps/web/process/hooks/init/get-main-data.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/web/process/hooks/init/get-main-data.js b/apps/web/process/hooks/init/get-main-data.js index fcc734c..a7d3a9f 100644 --- a/apps/web/process/hooks/init/get-main-data.js +++ b/apps/web/process/hooks/init/get-main-data.js @@ -36,9 +36,14 @@ function getMainData({ query }, onCompleted, user) { query: CRMTypes.GetOpportunitiesDocument, variables: { domainname: user.domainName }, }).then(({ data }) => { - onCompleted({ - selectOpportunity: data?.opportunities, - }); + const systemuser = data?.systemusers?.[0]; + + if (systemuser) { + const { opportunities } = systemuser; + onCompleted({ + selectOpportunity: opportunities, + }); + } }); query({ query: CRMTypes.GetTransactionCurrenciesDocument }).then(({ data }) => {