@verii/components-organizations-registrar 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/dist/chunks/{AuthContext.C48b4cSH.js → AuthContext.7b-sPPn_.js} +1 -1
- package/dist/chunks/{AuthContext.C48b4cSH.js.map → AuthContext.7b-sPPn_.js.map} +1 -1
- package/dist/chunks/{AuthContext.BNXy_XPt.js → AuthContext.xLW3Bdji.js} +1 -1
- package/dist/chunks/{AuthContext.BNXy_XPt.js.map → AuthContext.xLW3Bdji.js.map} +1 -1
- package/dist/chunks/{ConsentProvider.D2w-DK30.js → ConsentProvider.CgVMDKWr.js} +11 -7
- package/dist/chunks/{ConsentProvider.D2w-DK30.js.map → ConsentProvider.CgVMDKWr.js.map} +1 -1
- package/dist/chunks/{ConsentProvider.DS28WRmZ.js → ConsentProvider.Dq52xEkc.js} +12 -8
- package/dist/chunks/{ConsentProvider.DS28WRmZ.js.map → ConsentProvider.Dq52xEkc.js.map} +1 -1
- package/dist/chunks/{CreateOrganizationUtils.IHpfMpyX.js → CreateOrganizationUtils.BhCGAWVR.js} +2 -2
- package/dist/chunks/{CreateOrganizationUtils.IHpfMpyX.js.map → CreateOrganizationUtils.BhCGAWVR.js.map} +1 -1
- package/dist/chunks/{CreateOrganizationUtils.BAL1YBx4.js → CreateOrganizationUtils.z-XS18wQ.js} +2 -2
- package/dist/chunks/{CreateOrganizationUtils.BAL1YBx4.js.map → CreateOrganizationUtils.z-XS18wQ.js.map} +1 -1
- package/dist/chunks/{CustomAppBar.DG1liP8F.js → CustomAppBar.BXQSOkgw.js} +6 -7
- package/dist/chunks/CustomAppBar.BXQSOkgw.js.map +1 -0
- package/dist/chunks/{CustomAppBar.BpYFlIj1.js → CustomAppBar.DFiez_ky.js} +5 -6
- package/dist/chunks/CustomAppBar.DFiez_ky.js.map +1 -0
- package/dist/chunks/{CustomDropDown.CLKrHWGm.js → CustomDropDown.Bpfc8Ss9.js} +1 -1
- package/dist/chunks/{CustomDropDown.CLKrHWGm.js.map → CustomDropDown.Bpfc8Ss9.js.map} +1 -1
- package/dist/chunks/{CustomDropDown.B3x3Io5r.js → CustomDropDown.C01uqzSx.js} +1 -1
- package/dist/chunks/{CustomDropDown.B3x3Io5r.js.map → CustomDropDown.C01uqzSx.js.map} +1 -1
- package/dist/chunks/{CustomImageInput.B5JIgeLe.js → CustomImageInput.B_CbtJOV.js} +1 -1
- package/dist/chunks/{CustomImageInput.B5JIgeLe.js.map → CustomImageInput.B_CbtJOV.js.map} +1 -1
- package/dist/chunks/{CustomImageInput.BgKRRx4F.js → CustomImageInput.kYJ7FIs_.js} +1 -1
- package/dist/chunks/{CustomImageInput.BgKRRx4F.js.map → CustomImageInput.kYJ7FIs_.js.map} +1 -1
- package/dist/chunks/{DataItem.BQTAc2c8.js → DataItem.CwU4z2mm.js} +1 -1
- package/dist/chunks/{DataItem.BQTAc2c8.js.map → DataItem.CwU4z2mm.js.map} +1 -1
- package/dist/chunks/{DataItem.CNXW-9z1.js → DataItem.vYeyIb1d.js} +1 -1
- package/dist/chunks/{DataItem.CNXW-9z1.js.map → DataItem.vYeyIb1d.js.map} +1 -1
- package/dist/chunks/{HolderWalletSelection.BBJmVA_8.js → HolderWalletSelection.chvw6wHM.js} +4 -4
- package/dist/chunks/{HolderWalletSelection.BBJmVA_8.js.map → HolderWalletSelection.chvw6wHM.js.map} +1 -1
- package/dist/chunks/{HolderWalletSelection.DYli1Fb4.js → HolderWalletSelection.ss6I0ByU.js} +4 -4
- package/dist/chunks/{HolderWalletSelection.DYli1Fb4.js.map → HolderWalletSelection.ss6I0ByU.js.map} +1 -1
- package/dist/chunks/{LinkedInRegistrationInput.BKKWLC6D.js → LinkedInRegistrationInput.B4ZsJ0Oj.js} +3 -3
- package/dist/chunks/{LinkedInRegistrationInput.BKKWLC6D.js.map → LinkedInRegistrationInput.B4ZsJ0Oj.js.map} +1 -1
- package/dist/chunks/{LinkedInRegistrationInput.I3lGQbyu.js → LinkedInRegistrationInput.DgQozJrq.js} +3 -3
- package/dist/chunks/{LinkedInRegistrationInput.I3lGQbyu.js.map → LinkedInRegistrationInput.DgQozJrq.js.map} +1 -1
- package/dist/chunks/{ListItem.Tphj_-7Y.js → ListItem.Bu6sypFO.js} +1 -1
- package/dist/chunks/{ListItem.Tphj_-7Y.js.map → ListItem.Bu6sypFO.js.map} +1 -1
- package/dist/chunks/{ListItem.9viaiVcl.js → ListItem.CW3vFgIN.js} +1 -1
- package/dist/chunks/{ListItem.9viaiVcl.js.map → ListItem.CW3vFgIN.js.map} +1 -1
- package/dist/chunks/{MainLayout.B5WA0LOr.js → MainLayout.D1IQuXeV.js} +3 -3
- package/dist/chunks/{MainLayout.B5WA0LOr.js.map → MainLayout.D1IQuXeV.js.map} +1 -1
- package/dist/chunks/{MainLayout.BpleAJVW.js → MainLayout.D_uwYBiK.js} +3 -3
- package/dist/chunks/{MainLayout.BpleAJVW.js.map → MainLayout.D_uwYBiK.js.map} +1 -1
- package/dist/chunks/{PlusButtonBlock.CnRxLx_a.js → PlusButtonBlock.0p1aXdUs.js} +1 -1
- package/dist/chunks/{PlusButtonBlock.CnRxLx_a.js.map → PlusButtonBlock.0p1aXdUs.js.map} +1 -1
- package/dist/chunks/{PlusButtonBlock.CJ83gFYt.js → PlusButtonBlock.BCCCUPSi.js} +1 -1
- package/dist/chunks/{PlusButtonBlock.CJ83gFYt.js.map → PlusButtonBlock.BCCCUPSi.js.map} +1 -1
- package/dist/chunks/{SecretKeysPopup.dEI2kM66.js → SecretKeysPopup.CiV18z83.js} +8 -8
- package/dist/chunks/SecretKeysPopup.CiV18z83.js.map +1 -0
- package/dist/chunks/{SecretKeysPopup.D_ws7IBv.js → SecretKeysPopup.uZJqJbUI.js} +8 -8
- package/dist/chunks/SecretKeysPopup.uZJqJbUI.js.map +1 -0
- package/dist/chunks/{ServiceTypeSelection.DvgqE5zG.js → ServiceTypeSelection.D9xRkLEG.js} +31 -20
- package/dist/chunks/ServiceTypeSelection.D9xRkLEG.js.map +1 -0
- package/dist/chunks/{ServiceTypeSelection.DCwp_z1y.js → ServiceTypeSelection.q2JBCXHz.js} +31 -20
- package/dist/chunks/ServiceTypeSelection.q2JBCXHz.js.map +1 -0
- package/dist/chunks/{ServicesEdit.BAALHnnd.js → ServicesEdit.DzLVgpbe.js} +3 -3
- package/dist/chunks/{ServicesEdit.BAALHnnd.js.map → ServicesEdit.DzLVgpbe.js.map} +1 -1
- package/dist/chunks/{ServicesEdit.pf4DIwgT.js → ServicesEdit.qKiSeS-Y.js} +3 -3
- package/dist/chunks/{ServicesEdit.pf4DIwgT.js.map → ServicesEdit.qKiSeS-Y.js.map} +1 -1
- package/dist/chunks/{SetInvitationService.BTRii8c9.js → SetInvitationService.Bfh1MkUd.js} +11 -11
- package/dist/chunks/{SetInvitationService.BTRii8c9.js.map → SetInvitationService.Bfh1MkUd.js.map} +1 -1
- package/dist/chunks/{SetInvitationService.BZx0fnE7.js → SetInvitationService.C1WSzv_b.js} +8 -8
- package/dist/chunks/{SetInvitationService.BZx0fnE7.js.map → SetInvitationService.C1WSzv_b.js.map} +1 -1
- package/dist/chunks/{StatusPopup.BKW9GTd1.js → StatusPopup.BLm58Ucw.js} +1 -1
- package/dist/chunks/{StatusPopup.BKW9GTd1.js.map → StatusPopup.BLm58Ucw.js.map} +1 -1
- package/dist/chunks/{StatusPopup.BbHgkDqs.js → StatusPopup.DFd8LRAd.js} +1 -1
- package/dist/chunks/{StatusPopup.BbHgkDqs.js.map → StatusPopup.DFd8LRAd.js.map} +1 -1
- package/dist/chunks/{TermsAndConditionsPdf.CjCNnsnk.js → TermsAndConditionsPdf.C7p5izyt.js} +2 -2
- package/dist/chunks/{TermsAndConditionsPdf.CjCNnsnk.js.map → TermsAndConditionsPdf.C7p5izyt.js.map} +1 -1
- package/dist/chunks/{TermsAndConditionsPdf.CmndIjUk.js → TermsAndConditionsPdf.zKtMNvGE.js} +2 -2
- package/dist/chunks/{TermsAndConditionsPdf.CmndIjUk.js.map → TermsAndConditionsPdf.zKtMNvGE.js.map} +1 -1
- package/dist/chunks/{chainNames.Dyy12xsR.js → chainNames.B3STBHcv.js} +1 -1
- package/dist/chunks/{chainNames.C2rIdk41.js.map → chainNames.B3STBHcv.js.map} +1 -1
- package/dist/chunks/{chainNames.C2rIdk41.js → chainNames.DrELy1P1.js} +1 -1
- package/dist/chunks/{chainNames.Dyy12xsR.js.map → chainNames.DrELy1P1.js.map} +1 -1
- package/dist/chunks/{organizations.CUcriLs3.js → organizations.BVNH7tMu.js} +9 -9
- package/dist/chunks/{organizations.CUcriLs3.js.map → organizations.BVNH7tMu.js.map} +1 -1
- package/dist/chunks/{organizations.DeFUX0wU.js → organizations.CvYw0UmD.js} +9 -9
- package/dist/chunks/{organizations.DeFUX0wU.js.map → organizations.CvYw0UmD.js.map} +1 -1
- package/dist/chunks/{participantAgreementState.DiAxsPlf.js → participantAgreementState.DQ8ocSKu.js} +1 -1
- package/dist/chunks/{participantAgreementState.DiAxsPlf.js.map → participantAgreementState.DQ8ocSKu.js.map} +1 -1
- package/dist/chunks/{participantAgreementState.CoTcIfWF.js → participantAgreementState.DUiYi4Yt.js} +1 -1
- package/dist/chunks/{participantAgreementState.CoTcIfWF.js.map → participantAgreementState.DUiYi4Yt.js.map} +1 -1
- package/dist/chunks/{refreshAccessTokens.CYYr4dl1.js → refreshAccessTokens.Dga-gvw4.js} +1 -1
- package/dist/chunks/{refreshAccessTokens.C9boTp4h.js.map → refreshAccessTokens.Dga-gvw4.js.map} +1 -1
- package/dist/chunks/{refreshAccessTokens.C9boTp4h.js → refreshAccessTokens.NjcJCCzc.js} +1 -1
- package/dist/chunks/{refreshAccessTokens.CYYr4dl1.js.map → refreshAccessTokens.NjcJCCzc.js.map} +1 -1
- package/dist/chunks/{serviceTypes.DCgfBtsd.js → serviceTypes.B756lm0D.js} +1 -1
- package/dist/chunks/{serviceTypes.DCgfBtsd.js.map → serviceTypes.B756lm0D.js.map} +1 -1
- package/dist/chunks/{serviceTypes.DkHyHv7r.js → serviceTypes.BI0gVdmu.js} +1 -1
- package/dist/chunks/{serviceTypes.DkHyHv7r.js.map → serviceTypes.BI0gVdmu.js.map} +1 -1
- package/dist/chunks/tracing.DXTabOAg.js +8 -0
- package/dist/chunks/tracing.DXTabOAg.js.map +1 -0
- package/dist/chunks/tracing.FIthFNhJ.js +13 -0
- package/dist/chunks/tracing.FIthFNhJ.js.map +1 -0
- package/dist/chunks/{utils.7s5-Uywi.js → utils.BDiFYUJC.js} +5 -5
- package/dist/chunks/{utils.7s5-Uywi.js.map → utils.BDiFYUJC.js.map} +1 -1
- package/dist/chunks/{utils.CD2cMeOV.js → utils.D7BeVF1I.js} +2 -2
- package/dist/chunks/{utils.CD2cMeOV.js.map → utils.D7BeVF1I.js.map} +1 -1
- package/dist/components/AppBar.cjs +1 -1
- package/dist/components/AppBar.js +1 -1
- package/dist/components/common.cjs +6 -6
- package/dist/components/common.cjs.map +1 -1
- package/dist/components/common.js +6 -6
- package/dist/components/common.js.map +1 -1
- package/dist/components/invitations.cjs +1 -1
- package/dist/components/invitations.js +1 -1
- package/dist/components/organizations.cjs +2 -2
- package/dist/components/organizations.js +2 -2
- package/dist/components/services.cjs +1 -1
- package/dist/components/services.js +1 -1
- package/dist/components.cjs +1 -1
- package/dist/components.js +1 -1
- package/dist/index.cjs +113 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +129 -36
- package/dist/index.js.map +1 -1
- package/dist/layouts.cjs +1 -1
- package/dist/layouts.js +1 -1
- package/dist/pages/individuals.cjs +4 -4
- package/dist/pages/individuals.js +4 -4
- package/dist/pages/invitations.cjs +105 -35
- package/dist/pages/invitations.cjs.map +1 -1
- package/dist/pages/invitations.js +106 -36
- package/dist/pages/invitations.js.map +1 -1
- package/dist/pages/organizations.cjs +565 -491
- package/dist/pages/organizations.cjs.map +1 -1
- package/dist/pages/organizations.js +567 -493
- package/dist/pages/organizations.js.map +1 -1
- package/dist/pages/services.cjs +11 -14
- package/dist/pages/services.cjs.map +1 -1
- package/dist/pages/services.js +11 -14
- package/dist/pages/services.js.map +1 -1
- package/dist/pages.cjs +2 -2
- package/dist/pages.js +8 -8
- package/dist/pages.js.map +1 -1
- package/package.json +4 -3
- package/dist/chunks/CustomAppBar.BpYFlIj1.js.map +0 -1
- package/dist/chunks/CustomAppBar.DG1liP8F.js.map +0 -1
- package/dist/chunks/SecretKeysPopup.D_ws7IBv.js.map +0 -1
- package/dist/chunks/SecretKeysPopup.dEI2kM66.js.map +0 -1
- package/dist/chunks/ServiceTypeSelection.DCwp_z1y.js.map +0 -1
- package/dist/chunks/ServiceTypeSelection.DvgqE5zG.js.map +0 -1
package/README.md
CHANGED
|
@@ -13,5 +13,19 @@ Style is maintained in eslint based on the monorepo root styles
|
|
|
13
13
|
## How to develop
|
|
14
14
|
`> vite build:watch`
|
|
15
15
|
|
|
16
|
+
## Auth contract
|
|
17
|
+
Host applications provide authentication through `AuthContext`. The component
|
|
18
|
+
library expects the host to provide the current auth state, token retrieval, and
|
|
19
|
+
login/logout functions.
|
|
20
|
+
|
|
21
|
+
`PrivateAppRoot` also reads `auth.isLogoutInProgress`. When this value is true,
|
|
22
|
+
`PrivateAppRoot` enters its internal `resolvingLogout` state, renders the
|
|
23
|
+
loading screen, and does not trigger the automatic login redirect. This prevents
|
|
24
|
+
an explicit logout from racing against login and re-authenticating the user from
|
|
25
|
+
an existing identity-provider session.
|
|
26
|
+
|
|
27
|
+
Host apps should set `isLogoutInProgress` synchronously before starting provider
|
|
28
|
+
logout. If omitted, it is treated as false.
|
|
29
|
+
|
|
16
30
|
## See how to use it
|
|
17
31
|
[Sample Registrar App](../../samples/sample-registrar-app)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthContext.
|
|
1
|
+
{"version":3,"file":"AuthContext.7b-sPPn_.js","names":[],"sources":["../../src/utils/auth/AuthContext.js"],"sourcesContent":["/*\n * Copyright 2025 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\nimport { createContext, useContext } from 'react';\n\nexport const AuthContext = createContext(null);\nexport const useAuth = () => useContext(AuthContext);\n"],"mappings":";;;AAkBA,IAAa,eAAA,GAAA,MAAA,eAA4B,KAAK;AAC9C,IAAa,iBAAA,GAAA,MAAA,YAA2B,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthContext.
|
|
1
|
+
{"version":3,"file":"AuthContext.xLW3Bdji.js","names":[],"sources":["../../src/utils/auth/AuthContext.js"],"sourcesContent":["/*\n * Copyright 2025 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\nimport { createContext, useContext } from 'react';\n\nexport const AuthContext = createContext(null);\nexport const useAuth = () => useContext(AuthContext);\n"],"mappings":";;AAkBA,IAAa,cAAc,cAAc,KAAK;AAC9C,IAAa,gBAAgB,WAAW,YAAY"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
const require_Loading = require("./Loading.C6QWcMb4.js");
|
|
2
|
-
const require_utils = require("./utils.
|
|
2
|
+
const require_utils = require("./utils.D7BeVF1I.js");
|
|
3
3
|
const require_selectedOrganizationState = require("./selectedOrganizationState.1hFVZLSS.js");
|
|
4
|
-
const require_AuthContext = require("./AuthContext.
|
|
4
|
+
const require_AuthContext = require("./AuthContext.7b-sPPn_.js");
|
|
5
5
|
const require_remoteDataProvider = require("./remoteDataProvider.BOdk5HJ0.js");
|
|
6
6
|
const require_theme = require("./theme.CDJgjq8Q.js");
|
|
7
|
-
const require_TermsAndConditionsPdf = require("./TermsAndConditionsPdf.
|
|
7
|
+
const require_TermsAndConditionsPdf = require("./TermsAndConditionsPdf.C7p5izyt.js");
|
|
8
8
|
const require_Popup = require("./Popup.BYl8db7s.js");
|
|
9
9
|
const require_ConfigContext = require("./ConfigContext.C5_wchSF.js");
|
|
10
10
|
let react = require("react");
|
|
11
11
|
let react_admin = require("react-admin");
|
|
12
|
+
let react_router = require("react-router");
|
|
12
13
|
let prop_types = require("prop-types");
|
|
13
14
|
prop_types = require_Loading.__toESM(prop_types, 1);
|
|
14
15
|
let _mui_material = require("@mui/material");
|
|
15
|
-
let react_router = require("react-router");
|
|
16
16
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
17
17
|
let _mui_material_List = require("@mui/material/List");
|
|
18
18
|
_mui_material_List = require_Loading.__toESM(_mui_material_List, 1);
|
|
@@ -274,7 +274,11 @@ var ConsentProvider = ({ children }) => {
|
|
|
274
274
|
if (lastAgreedVersion < "8") setIsShouldAgreeWithNewVersion(true);
|
|
275
275
|
};
|
|
276
276
|
const handleConsentError = (e) => {
|
|
277
|
-
if (e.error && logoutErrors.includes(e.error)) logout({
|
|
277
|
+
if (e.error && logoutErrors.includes(e.error)) logout({
|
|
278
|
+
source: "consent-error",
|
|
279
|
+
details: { error: e.error },
|
|
280
|
+
logoutParams: { returnTo: window.location.origin }
|
|
281
|
+
});
|
|
278
282
|
};
|
|
279
283
|
(async () => {
|
|
280
284
|
try {
|
|
@@ -346,7 +350,7 @@ var ConsentProvider = ({ children }) => {
|
|
|
346
350
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TermsOfUsePopup, {
|
|
347
351
|
isOpen: isShouldAgreeWithNewVersion,
|
|
348
352
|
onClose: () => {
|
|
349
|
-
logout();
|
|
353
|
+
logout({ source: "terms-popup-close" });
|
|
350
354
|
},
|
|
351
355
|
onProceed: onAgreeWithNewVersion,
|
|
352
356
|
title: isNewUser ? "Terms of use" : "The terms of use were updated",
|
|
@@ -381,4 +385,4 @@ Object.defineProperty(exports, "TermsOfUsePopup", {
|
|
|
381
385
|
}
|
|
382
386
|
});
|
|
383
387
|
|
|
384
|
-
//# sourceMappingURL=ConsentProvider.
|
|
388
|
+
//# sourceMappingURL=ConsentProvider.CgVMDKWr.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConsentProvider.D2w-DK30.js","names":[],"sources":["../../src/components/Dashboard.jsx","../../src/components/Footer.jsx","../../src/components/TermsOfUsePopup.jsx","../../src/components/ConsentProvider.jsx"],"sourcesContent":["/**\n * Copyright 2023 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect } from 'react';\nimport { useRedirect } from 'react-admin';\nimport useSelectedOrganization from '../state/selectedOrganizationState.js';\nimport Loading from './Loading.jsx';\n\nconst Dashboard = () => {\n const redirect = useRedirect();\n const [did] = useSelectedOrganization();\n\n useEffect(() => {\n if (!did) {\n return;\n }\n redirect('show', 'organizations', did);\n }, [did, redirect]);\n\n return <Loading sx={{ pt: '60px' }} />;\n};\n\nexport default Dashboard;\n","/**\n * Copyright 2023 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport List from '@mui/material/List';\nimport ListItemButton from '@mui/material/ListItemButton';\nimport ListItemText from '@mui/material/ListItemText';\n\nimport theme, { FOOTER_HEIGHT } from '../theme/theme.js';\n\nconst Footer = () => {\n return (\n <footer style={styles.footer}>\n <List sx={styles.list} component=\"nav\" aria-label=\"footer navigation\">\n <ListItemButton disabled>\n <ListItemText slotProps={{ primary: { sx: styles.listText } }} primary=\"CONTACT US\" />\n </ListItemButton>\n <ListItemButton\n onClick={() => window.open(`${window.location.origin}/terms-and-conditions`, '_blank')}\n >\n <ListItemText slotProps={{ primary: { sx: styles.listText } }} primary=\"TERMS OF USE\" />\n </ListItemButton>\n <ListItemButton\n onClick={() => window.open(`${window.location.origin}/privacy-policy`, '_blank')}\n >\n <ListItemText slotProps={{ primary: { sx: styles.listText } }} primary=\"PRIVACY POLICY\" />\n </ListItemButton>\n </List>\n <div style={styles.text}>\n All rights reserved {new Date().getFullYear()}\n <img\n src=\"/assets/images/logo.svg\"\n alt=\"Velocity\"\n width={98}\n height={20}\n style={styles.icon}\n />\n </div>\n </footer>\n );\n};\n\nexport default Footer;\n\nconst styles = {\n footer: {\n position: 'absolute',\n right: 0,\n bottom: 0,\n left: 0,\n zIndex: 100,\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'center',\n height: FOOTER_HEIGHT,\n paddingRight: 10,\n backgroundColor: theme.palette.background.default,\n borderTop: `1px solid ${theme.palette.divider.main}`,\n },\n list: {\n display: 'flex',\n color: theme.palette.secondary.light,\n },\n listText: {\n fontWeight: 600,\n fontSize: '12px',\n lineHeight: '16px',\n letterSpacing: '0.5px',\n fontFamily: theme.typography.fontFamily,\n },\n text: {\n fontWeight: 300,\n fontSize: '14px',\n lineHeight: '16px',\n letterSpacing: '0.1px',\n color: theme.palette.secondary.light,\n fontFamily: theme.typography.fontFamily,\n },\n icon: {\n verticalAlign: 'middle',\n color: theme.palette.secondary.light,\n paddingLeft: 30,\n filter:\n 'invert(68%) sepia(13%) saturate(102%) hue-rotate(185deg) brightness(89%) contrast(87%)', // filter for #989A9F\n },\n};\n","/*\n * Copyright 2025 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nimport PropTypes from 'prop-types';\nimport { Button, Typography, Stack, Box } from '@mui/material';\nimport { Link } from 'react-router';\n\nimport { Download } from '@mui/icons-material';\nimport Popup from './common/Popup.jsx';\nimport theme from '../theme/theme.js';\n\nconst TermsOfUsePopup = ({ onClose, isOpen, onProceed, title, onDownload }) => {\n return (\n <Popup title={title} onClose={onClose} isOpen={isOpen} titleStyles={sx.title}>\n <Stack justifyContent=\"center\" pt=\"8px\">\n <Typography alignSelf=\"center\">\n By clicking PROCEED you agree to the{' '}\n <Link target=\"_blank\" to=\"/terms-and-conditions\" role=\"link\" style={sx.link}>\n terms of use\n </Link>\n </Typography>\n <Box sx={sx.box}>\n <Button onClick={onProceed} variant=\"outlined\" sx={[sx.button, sx.proceed]} autoFocus>\n Proceed\n </Button>\n <Button onClick={onDownload} variant=\"outlined\" sx={sx.button} endIcon={<Download />}>\n Download PDF\n </Button>\n </Box>\n </Stack>\n </Popup>\n );\n};\n\nconst sx = {\n button: {\n width: 'fit-content',\n alignSelf: 'center',\n px: 4,\n py: 1,\n mt: '40px',\n mr: 2,\n '&:last-child': {\n mr: 0,\n },\n color: theme.palette.primary.main,\n borderColor: theme.palette.primary.main,\n '&:hover': {\n borderColor: theme.palette.primary.main,\n },\n },\n box: {\n display: 'flex',\n justifyContent: 'center',\n },\n link: { color: theme.palette.primary.main },\n title: { textAlign: 'center' },\n proceed: {\n color: theme.palette.text.primary,\n borderColor: theme.palette.secondary.light,\n '&:hover': {\n borderColor: theme.palette.secondary.light,\n },\n },\n};\n\n// eslint-disable-next-line better-mutation/no-mutation\nTermsOfUsePopup.propTypes = {\n onClose: PropTypes.func,\n onProceed: PropTypes.func,\n isOpen: PropTypes.bool,\n title: PropTypes.string,\n onDownload: PropTypes.func,\n};\n\nexport default TermsOfUsePopup;\n","/**\n * Copyright 2023 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { pdf } from '@react-pdf/renderer';\n\nimport { dataResources } from '../utils/remoteDataProvider.js';\nimport { parseJwt } from '../utils/index.jsx';\nimport { TERMS_AND_CONDITIONS_VERSION } from '../pages/TermsAndConditions.jsx';\nimport TermsAndConditionsPdf from '../pages/TermsAndConditionsPdf.jsx';\nimport TermsOfUsePopup from './TermsOfUsePopup.jsx';\nimport Loading from './Loading.jsx';\nimport { useAuth } from '../utils/auth/AuthContext.js';\nimport { useConfig } from '../utils/ConfigContext.js';\n\nconst logoutErrors = ['Unauthorized', 'missing_refresh_token', 'invalid_grant'];\n\nconst ConsentProvider = ({ children }) => {\n const [agreedVersion, setAgreedVersion] = useState(null);\n const [isShouldAgreeWithNewVersion, setIsShouldAgreeWithNewVersion] = useState(false);\n const [isNewUser, setIsNewUser] = useState(false);\n const [isNewUserHasScope, setIsNewUserHasScope] = useState(false);\n const [isLoading, setIsLoading] = useState(false);\n const { logout, getAccessToken } = useAuth();\n const config = useConfig();\n\n useEffect(() => {\n const checkIfUserScope = (token) => {\n const tokenDecoded = parseJwt(token);\n return tokenDecoded.scope.includes('read:organizations');\n };\n const handleNewUser = (token) => {\n const newUserScope = checkIfUserScope(token);\n setIsNewUser(true);\n setAgreedVersion('');\n setIsShouldAgreeWithNewVersion(newUserScope);\n setIsNewUserHasScope(newUserScope);\n setIsLoading(false);\n };\n const handleExistingUser = (data) => {\n const sortedConsents = [...data].sort(\n (consent1, consent2) => new Date(consent2.version) - new Date(consent1.version),\n );\n const lastAgreedVersion = sortedConsents[0].version;\n setAgreedVersion(lastAgreedVersion);\n\n if (lastAgreedVersion < TERMS_AND_CONDITIONS_VERSION) {\n setIsShouldAgreeWithNewVersion(true);\n }\n };\n\n const handleConsentError = (e) => {\n if (e.error && logoutErrors.includes(e.error)) {\n logout({ logoutParams: { returnTo: window.location.origin } });\n }\n };\n\n (async () => {\n try {\n const token = await getAccessToken();\n setIsLoading(true);\n const response = await fetch(`${config.registrarApi}/${dataResources.CONSENTS}`, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n Authorization: `Bearer ${token}`,\n },\n });\n const data = await response.json();\n if (data.error) {\n handleConsentError(data);\n } else if (!data || data.length === 0) {\n handleNewUser(token);\n } else {\n handleExistingUser(data);\n }\n\n setIsLoading(false);\n } catch (e) {\n handleConsentError(e);\n setIsLoading(false);\n setIsShouldAgreeWithNewVersion(false); // BE response 404, when `!consents.length`\n }\n })();\n }, [getAccessToken, logout, config.registrarApi, config]);\n\n const onAgreeWithNewVersion = async () => {\n try {\n const token = await getAccessToken();\n await fetch(`${config.registrarApi}/${dataResources.CONSENTS}`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n Authorization: `Bearer ${token}`,\n },\n body: JSON.stringify({\n version: TERMS_AND_CONDITIONS_VERSION,\n }),\n });\n setAgreedVersion(TERMS_AND_CONDITIONS_VERSION);\n setIsShouldAgreeWithNewVersion(false);\n } catch (e) {\n console.error('set consent', e);\n }\n };\n\n const skipTerms = useMemo(() => {\n const newUserWithScope = isNewUser ? isNewUserHasScope : true;\n return (\n !isLoading && isShouldAgreeWithNewVersion !== true && (agreedVersion || !newUserWithScope)\n );\n }, [isNewUser, isNewUserHasScope, isLoading, isShouldAgreeWithNewVersion, agreedVersion]);\n\n const downloadPdf = useCallback(async () => {\n const blob = await pdf(<TermsAndConditionsPdf />).toBlob();\n const link = document.createElement('a');\n link.setAttribute('href', URL.createObjectURL(blob));\n link.setAttribute('download', 'Terms and Conditions');\n document.body.append(link);\n\n link.click();\n link.remove();\n }, []);\n return (\n <>\n {skipTerms && children}\n {isLoading && <Loading sx={{ pt: '60px' }} />}\n <TermsOfUsePopup\n isOpen={isShouldAgreeWithNewVersion}\n onClose={() => {\n logout();\n }}\n onProceed={onAgreeWithNewVersion}\n title={isNewUser ? 'Terms of use' : 'The terms of use were updated'}\n onDownload={downloadPdf}\n />\n </>\n );\n};\n\nexport default ConsentProvider;\n\n// eslint-disable-next-line better-mutation/no-mutation\nConsentProvider.propTypes = {\n children: PropTypes.node,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAM,kBAAkB;CACtB,MAAM,YAAA,GAAA,YAAA,cAAwB;CAC9B,MAAM,CAAC,OAAO,kCAAA,yBAAyB;AAEvC,EAAA,GAAA,MAAA,iBAAgB;AACd,MAAI,CAAC,IACH;AAEF,WAAS,QAAQ,iBAAiB,IAAI;IACrC,CAAC,KAAK,SAAS,CAAC;AAEnB,QAAO,iBAAA,GAAA,kBAAA,KAAC,gBAAA,SAAD,EAAS,IAAI,EAAE,IAAI,QAAQ,EAAI,CAAA;;;;;;;;;;;;;;;;;;;ACVxC,IAAM,eAAe;AACnB,QACE,iBAAA,GAAA,kBAAA,MAAC,UAAD;EAAQ,OAAO,OAAO;YAAtB,CACE,iBAAA,GAAA,kBAAA,MAAC,mBAAA,S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SAAS;KACP,gBAAgB;KAChB,QAAQ;KACR,eAAe,UAAU;KAC1B;IACD,MAAM,KAAK,UAAU,EACnB,SAAA,KACD,CAAC;IACH,CAAC;AACF,oBAAA,IAA8C;AAC9C,kCAA+B,MAAM;WAC9B,GAAG;AACV,WAAQ,MAAM,eAAe,EAAE;;;CAInC,MAAM,aAAA,GAAA,MAAA,eAA0B;AAE9B,SACE,CAAC,aAAa,gCAAgC,SAAS,iBAAiB,EAFjD,YAAY,oBAAoB;IAIxD;EAAC;EAAW;EAAmB;EAAW;EAA6B;EAAc,CAAC;CAEzF,MAAM,eAAA,GAAA,MAAA,aAA0B,YAAY;EAC1C,MAAM,OAAO,OAAA,GAAA,oBAAA,KAAU,iBAAA,GAAA,kBAAA,KAAC,8BAAA,uBAAD,EAAyB,CAAA,CAAC,CAAC,QAAQ;EAC1D,MAAM,OAAO,SAAS,cAAc,IAAI;AACxC,OAAK,aAAa,QAAQ,IAAI,gBAAgB,KAAK,CAAC;AACpD,OAAK,aAAa,YAAY,uBAAuB;AACrD,WAAS,KAAK,OAAO,KAAK;AAE1B,OAAK,OAAO;AACZ,OAAK,QAAQ;IACZ,EAAE,CAAC;AACN,QACE,iBAAA,GAAA,kBAAA,MAAA,kBAAA,UAAA,EAAA,UAAA;EACG,aAAa;EACb,aAAa,iBAAA,GAAA,kBAAA,KAAC,gBAAA,SAAD,EAAS,IAAI,EAAE,IAAI,QAAQ,EAAI,CAAA;EAC7C,iBAAA,GAAA,kBAAA,KAAC,iBAAD;GACE,QAAQ;GACR,eAAe;AACb,YAAQ;;GAEV,WAAW;GACX,OAAO,YAAY,iBAAiB;GACpC,YAAY;GACZ,CAAA;EACD,EAAA,CAAA;;AAOP,gBAAgB,YAAY,EAC1B,UAAU,WAAA,QAAU,MACrB"}
|
|
1
|
+
{"version":3,"file":"ConsentProvider.CgVMDKWr.js","names":[],"sources":["../../src/components/Dashboard.jsx","../../src/components/Footer.jsx","../../src/components/TermsOfUsePopup.jsx","../../src/components/ConsentProvider.jsx"],"sourcesContent":["/**\n * Copyright 2023 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect } from 'react';\nimport { useRedirect } from 'react-admin';\nimport useSelectedOrganization from '../state/selectedOrganizationState.js';\nimport Loading from './Loading.jsx';\n\nconst Dashboard = () => {\n const redirect = useRedirect();\n const [did] = useSelectedOrganization();\n\n useEffect(() => {\n if (!did) {\n return;\n }\n redirect('show', 'organizations', did);\n }, [did, redirect]);\n\n return <Loading sx={{ pt: '60px' }} />;\n};\n\nexport default Dashboard;\n","/**\n * Copyright 2023 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport List from '@mui/material/List';\nimport ListItemButton from '@mui/material/ListItemButton';\nimport ListItemText from '@mui/material/ListItemText';\n\nimport theme, { FOOTER_HEIGHT } from '../theme/theme.js';\n\nconst Footer = () => {\n return (\n <footer style={styles.footer}>\n <List sx={styles.list} component=\"nav\" aria-label=\"footer navigation\">\n <ListItemButton disabled>\n <ListItemText slotProps={{ primary: { sx: styles.listText } }} primary=\"CONTACT US\" />\n </ListItemButton>\n <ListItemButton\n onClick={() => window.open(`${window.location.origin}/terms-and-conditions`, '_blank')}\n >\n <ListItemText slotProps={{ primary: { sx: styles.listText } }} primary=\"TERMS OF USE\" />\n </ListItemButton>\n <ListItemButton\n onClick={() => window.open(`${window.location.origin}/privacy-policy`, '_blank')}\n >\n <ListItemText slotProps={{ primary: { sx: styles.listText } }} primary=\"PRIVACY POLICY\" />\n </ListItemButton>\n </List>\n <div style={styles.text}>\n All rights reserved {new Date().getFullYear()}\n <img\n src=\"/assets/images/logo.svg\"\n alt=\"Velocity\"\n width={98}\n height={20}\n style={styles.icon}\n />\n </div>\n </footer>\n );\n};\n\nexport default Footer;\n\nconst styles = {\n footer: {\n position: 'absolute',\n right: 0,\n bottom: 0,\n left: 0,\n zIndex: 100,\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'center',\n height: FOOTER_HEIGHT,\n paddingRight: 10,\n backgroundColor: theme.palette.background.default,\n borderTop: `1px solid ${theme.palette.divider.main}`,\n },\n list: {\n display: 'flex',\n color: theme.palette.secondary.light,\n },\n listText: {\n fontWeight: 600,\n fontSize: '12px',\n lineHeight: '16px',\n letterSpacing: '0.5px',\n fontFamily: theme.typography.fontFamily,\n },\n text: {\n fontWeight: 300,\n fontSize: '14px',\n lineHeight: '16px',\n letterSpacing: '0.1px',\n color: theme.palette.secondary.light,\n fontFamily: theme.typography.fontFamily,\n },\n icon: {\n verticalAlign: 'middle',\n color: theme.palette.secondary.light,\n paddingLeft: 30,\n filter:\n 'invert(68%) sepia(13%) saturate(102%) hue-rotate(185deg) brightness(89%) contrast(87%)', // filter for #989A9F\n },\n};\n","/*\n * Copyright 2025 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nimport PropTypes from 'prop-types';\nimport { Button, Typography, Stack, Box } from '@mui/material';\nimport { Link } from 'react-router';\n\nimport { Download } from '@mui/icons-material';\nimport Popup from './common/Popup.jsx';\nimport theme from '../theme/theme.js';\n\nconst TermsOfUsePopup = ({ onClose, isOpen, onProceed, title, onDownload }) => {\n return (\n <Popup title={title} onClose={onClose} isOpen={isOpen} titleStyles={sx.title}>\n <Stack justifyContent=\"center\" pt=\"8px\">\n <Typography alignSelf=\"center\">\n By clicking PROCEED you agree to the{' '}\n <Link target=\"_blank\" to=\"/terms-and-conditions\" role=\"link\" style={sx.link}>\n terms of use\n </Link>\n </Typography>\n <Box sx={sx.box}>\n <Button onClick={onProceed} variant=\"outlined\" sx={[sx.button, sx.proceed]} autoFocus>\n Proceed\n </Button>\n <Button onClick={onDownload} variant=\"outlined\" sx={sx.button} endIcon={<Download />}>\n Download PDF\n </Button>\n </Box>\n </Stack>\n </Popup>\n );\n};\n\nconst sx = {\n button: {\n width: 'fit-content',\n alignSelf: 'center',\n px: 4,\n py: 1,\n mt: '40px',\n mr: 2,\n '&:last-child': {\n mr: 0,\n },\n color: theme.palette.primary.main,\n borderColor: theme.palette.primary.main,\n '&:hover': {\n borderColor: theme.palette.primary.main,\n },\n },\n box: {\n display: 'flex',\n justifyContent: 'center',\n },\n link: { color: theme.palette.primary.main },\n title: { textAlign: 'center' },\n proceed: {\n color: theme.palette.text.primary,\n borderColor: theme.palette.secondary.light,\n '&:hover': {\n borderColor: theme.palette.secondary.light,\n },\n },\n};\n\n// eslint-disable-next-line better-mutation/no-mutation\nTermsOfUsePopup.propTypes = {\n onClose: PropTypes.func,\n onProceed: PropTypes.func,\n isOpen: PropTypes.bool,\n title: PropTypes.string,\n onDownload: PropTypes.func,\n};\n\nexport default TermsOfUsePopup;\n","/**\n * Copyright 2023 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { pdf } from '@react-pdf/renderer';\n\nimport { dataResources } from '../utils/remoteDataProvider.js';\nimport { parseJwt } from '../utils/index.jsx';\nimport { TERMS_AND_CONDITIONS_VERSION } from '../pages/TermsAndConditions.jsx';\nimport TermsAndConditionsPdf from '../pages/TermsAndConditionsPdf.jsx';\nimport TermsOfUsePopup from './TermsOfUsePopup.jsx';\nimport Loading from './Loading.jsx';\nimport { useAuth } from '../utils/auth/AuthContext.js';\nimport { useConfig } from '../utils/ConfigContext.js';\n\nconst logoutErrors = ['Unauthorized', 'missing_refresh_token', 'invalid_grant'];\n\nconst ConsentProvider = ({ children }) => {\n const [agreedVersion, setAgreedVersion] = useState(null);\n const [isShouldAgreeWithNewVersion, setIsShouldAgreeWithNewVersion] = useState(false);\n const [isNewUser, setIsNewUser] = useState(false);\n const [isNewUserHasScope, setIsNewUserHasScope] = useState(false);\n const [isLoading, setIsLoading] = useState(false);\n const { logout, getAccessToken } = useAuth();\n const config = useConfig();\n\n useEffect(() => {\n const checkIfUserScope = (token) => {\n const tokenDecoded = parseJwt(token);\n return tokenDecoded.scope.includes('read:organizations');\n };\n const handleNewUser = (token) => {\n const newUserScope = checkIfUserScope(token);\n setIsNewUser(true);\n setAgreedVersion('');\n setIsShouldAgreeWithNewVersion(newUserScope);\n setIsNewUserHasScope(newUserScope);\n setIsLoading(false);\n };\n const handleExistingUser = (data) => {\n const sortedConsents = [...data].sort(\n (consent1, consent2) => new Date(consent2.version) - new Date(consent1.version),\n );\n const lastAgreedVersion = sortedConsents[0].version;\n setAgreedVersion(lastAgreedVersion);\n\n if (lastAgreedVersion < TERMS_AND_CONDITIONS_VERSION) {\n setIsShouldAgreeWithNewVersion(true);\n }\n };\n\n const handleConsentError = (e) => {\n if (e.error && logoutErrors.includes(e.error)) {\n logout({\n source: 'consent-error',\n details: { error: e.error },\n logoutParams: { returnTo: window.location.origin },\n });\n }\n };\n\n (async () => {\n try {\n const token = await getAccessToken();\n setIsLoading(true);\n const response = await fetch(`${config.registrarApi}/${dataResources.CONSENTS}`, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n Authorization: `Bearer ${token}`,\n },\n });\n const data = await response.json();\n if (data.error) {\n handleConsentError(data);\n } else if (!data || data.length === 0) {\n handleNewUser(token);\n } else {\n handleExistingUser(data);\n }\n\n setIsLoading(false);\n } catch (e) {\n handleConsentError(e);\n setIsLoading(false);\n setIsShouldAgreeWithNewVersion(false); // BE response 404, when `!consents.length`\n }\n })();\n }, [getAccessToken, logout, config.registrarApi, config]);\n\n const onAgreeWithNewVersion = async () => {\n try {\n const token = await getAccessToken();\n await fetch(`${config.registrarApi}/${dataResources.CONSENTS}`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n Authorization: `Bearer ${token}`,\n },\n body: JSON.stringify({\n version: TERMS_AND_CONDITIONS_VERSION,\n }),\n });\n setAgreedVersion(TERMS_AND_CONDITIONS_VERSION);\n setIsShouldAgreeWithNewVersion(false);\n } catch (e) {\n console.error('set consent', e);\n }\n };\n\n const skipTerms = useMemo(() => {\n const newUserWithScope = isNewUser ? isNewUserHasScope : true;\n return (\n !isLoading && isShouldAgreeWithNewVersion !== true && (agreedVersion || !newUserWithScope)\n );\n }, [isNewUser, isNewUserHasScope, isLoading, isShouldAgreeWithNewVersion, agreedVersion]);\n\n const downloadPdf = useCallback(async () => {\n const blob = await pdf(<TermsAndConditionsPdf />).toBlob();\n const link = document.createElement('a');\n link.setAttribute('href', URL.createObjectURL(blob));\n link.setAttribute('download', 'Terms and Conditions');\n document.body.append(link);\n\n link.click();\n link.remove();\n }, []);\n return (\n <>\n {skipTerms && children}\n {isLoading && <Loading sx={{ pt: '60px' }} />}\n <TermsOfUsePopup\n isOpen={isShouldAgreeWithNewVersion}\n onClose={() => {\n logout({ source: 'terms-popup-close' });\n }}\n onProceed={onAgreeWithNewVersion}\n title={isNewUser ? 'Terms of use' : 'The terms of use were updated'}\n onDownload={downloadPdf}\n />\n </>\n );\n};\n\nexport default ConsentProvider;\n\n// eslint-disable-next-line better-mutation/no-mutation\nConsentProvider.propTypes = {\n children: PropTypes.node,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAM,kBAAkB;CACtB,MAAM,YAAA,GAAA,YAAA,cAAwB;CAC9B,MAAM,CAAC,OAAO,kCAAA,yBAAyB;AAEvC,EAAA,GAAA,MAAA,iBAAgB;AACd,MAAI,CAAC,IACH;AAEF,WAAS,QAAQ,iBAAiB,IAAI;IACrC,CAAC,KAAK,SAAS,CAAC;AAEnB,QAAO,iBAAA,GAAA,kBAAA,KAAC,gBAAA,SAAD,EAAS,IAAI,EAAE,IAAI,QAAQ,EAAI,CAAA;;;;;;;;;;;;;;;;;;;ACVxC,IAAM,eAAe;AACnB,QACE,iBAAA,GAAA,kBAAA,MAAC,UAAD;EAAQ,OAAO,OAAO;YAAtB,CACE,iBAAA,GAAA,kBAAA,MAAC,mBAAA,SAAD;GAAM,IAAI,OAAO;GAAM,WAAU;GAAM,cAAW;aAAlD;IACE,iBAAA,GAAA,kBAAA,KAAC,6BAAA,SAAD;KAAgB,UAAA;eACd,iBAAA,GAAA,kBAAA,KAAC,2BAAA,SAAD;MAAc,WAAW,EAAE,SAAS,EAAE,IAAI,OAAO,UAAU,EAAE;MAAE,SAAQ;MAAe,CAAA;KACvE,CAAA;IACjB,iBAAA,GAAA,kBAAA,KAAC,6BAAA,SAAD;KACE,eAAe,OAAO,KAAK,GAAG,OAAO,SAAS,OAAO,wBAAwB,SAAS;eAEtF,iBAAA,GAAA,kBAAA,KAAC,2BAAA,SAAD;MAAc,WAAW,EAAE,SAAS,EAAE,I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A,aAA0B,YAAY;EAC1C,MAAM,OAAO,OAAA,GAAA,oBAAA,KAAU,iBAAA,GAAA,kBAAA,KAAC,8BAAA,uBAAD,EAAyB,CAAA,CAAC,CAAC,QAAQ;EAC1D,MAAM,OAAO,SAAS,cAAc,IAAI;AACxC,OAAK,aAAa,QAAQ,IAAI,gBAAgB,KAAK,CAAC;AACpD,OAAK,aAAa,YAAY,uBAAuB;AACrD,WAAS,KAAK,OAAO,KAAK;AAE1B,OAAK,OAAO;AACZ,OAAK,QAAQ;IACZ,EAAE,CAAC;AACN,QACE,iBAAA,GAAA,kBAAA,MAAA,kBAAA,UAAA,EAAA,UAAA;EACG,aAAa;EACb,aAAa,iBAAA,GAAA,kBAAA,KAAC,gBAAA,SAAD,EAAS,IAAI,EAAE,IAAI,QAAQ,EAAI,CAAA;EAC7C,iBAAA,GAAA,kBAAA,KAAC,iBAAD;GACE,QAAQ;GACR,eAAe;AACb,WAAO,EAAE,QAAQ,qBAAqB,CAAC;;GAEzC,WAAW;GACX,OAAO,YAAY,iBAAiB;GACpC,YAAY;GACZ,CAAA;EACD,EAAA,CAAA;;AAOP,gBAAgB,YAAY,EAC1B,UAAU,WAAA,QAAU,MACrB"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { y as parseJwt } from "./utils.
|
|
1
|
+
import { y as parseJwt } from "./utils.BDiFYUJC.js";
|
|
2
2
|
import { t as Loading } from "./Loading.D7UqoOup.js";
|
|
3
3
|
import { t as useSelectedOrganization } from "./selectedOrganizationState.5NpnMWEo.js";
|
|
4
|
-
import { n as useAuth } from "./AuthContext.
|
|
4
|
+
import { n as useAuth } from "./AuthContext.xLW3Bdji.js";
|
|
5
5
|
import { t as dataResources } from "./remoteDataProvider.CPyVNIhT.js";
|
|
6
6
|
import { n as theme_default, t as FOOTER_HEIGHT } from "./theme.CLyWwe1w.js";
|
|
7
|
-
import { t as TermsAndConditionsPdf } from "./TermsAndConditionsPdf.
|
|
7
|
+
import { t as TermsAndConditionsPdf } from "./TermsAndConditionsPdf.zKtMNvGE.js";
|
|
8
8
|
import { t as Popup } from "./Popup.yNnsGZxG.js";
|
|
9
9
|
import { n as useConfig } from "./ConfigContext.DFzRZQc_.js";
|
|
10
10
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
11
11
|
import { useRedirect } from "react-admin";
|
|
12
|
+
import { Link } from "react-router";
|
|
12
13
|
import PropTypes from "prop-types";
|
|
13
14
|
import { Box, Button as Button$1, Stack, Typography } from "@mui/material";
|
|
14
|
-
import { Link as Link$1 } from "react-router";
|
|
15
15
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
16
16
|
import List$2 from "@mui/material/List";
|
|
17
17
|
import ListItemButton$1 from "@mui/material/ListItemButton";
|
|
@@ -163,7 +163,7 @@ var TermsOfUsePopup = ({ onClose, isOpen, onProceed, title, onDownload }) => {
|
|
|
163
163
|
children: [
|
|
164
164
|
"By clicking PROCEED you agree to the",
|
|
165
165
|
" ",
|
|
166
|
-
/* @__PURE__ */ jsx(Link
|
|
166
|
+
/* @__PURE__ */ jsx(Link, {
|
|
167
167
|
target: "_blank",
|
|
168
168
|
to: "/terms-and-conditions",
|
|
169
169
|
role: "link",
|
|
@@ -270,7 +270,11 @@ var ConsentProvider = ({ children }) => {
|
|
|
270
270
|
if (lastAgreedVersion < "8") setIsShouldAgreeWithNewVersion(true);
|
|
271
271
|
};
|
|
272
272
|
const handleConsentError = (e) => {
|
|
273
|
-
if (e.error && logoutErrors.includes(e.error)) logout({
|
|
273
|
+
if (e.error && logoutErrors.includes(e.error)) logout({
|
|
274
|
+
source: "consent-error",
|
|
275
|
+
details: { error: e.error },
|
|
276
|
+
logoutParams: { returnTo: window.location.origin }
|
|
277
|
+
});
|
|
274
278
|
};
|
|
275
279
|
(async () => {
|
|
276
280
|
try {
|
|
@@ -342,7 +346,7 @@ var ConsentProvider = ({ children }) => {
|
|
|
342
346
|
/* @__PURE__ */ jsx(TermsOfUsePopup, {
|
|
343
347
|
isOpen: isShouldAgreeWithNewVersion,
|
|
344
348
|
onClose: () => {
|
|
345
|
-
logout();
|
|
349
|
+
logout({ source: "terms-popup-close" });
|
|
346
350
|
},
|
|
347
351
|
onProceed: onAgreeWithNewVersion,
|
|
348
352
|
title: isNewUser ? "Terms of use" : "The terms of use were updated",
|
|
@@ -354,4 +358,4 @@ ConsentProvider.propTypes = { children: PropTypes.node };
|
|
|
354
358
|
//#endregion
|
|
355
359
|
export { Dashboard as i, TermsOfUsePopup as n, Footer as r, ConsentProvider as t };
|
|
356
360
|
|
|
357
|
-
//# sourceMappingURL=ConsentProvider.
|
|
361
|
+
//# sourceMappingURL=ConsentProvider.Dq52xEkc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConsentProvider.DS28WRmZ.js","names":[],"sources":["../../src/components/Dashboard.jsx","../../src/components/Footer.jsx","../../src/components/TermsOfUsePopup.jsx","../../src/components/ConsentProvider.jsx"],"sourcesContent":["/**\n * Copyright 2023 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect } from 'react';\nimport { useRedirect } from 'react-admin';\nimport useSelectedOrganization from '../state/selectedOrganizationState.js';\nimport Loading from './Loading.jsx';\n\nconst Dashboard = () => {\n const redirect = useRedirect();\n const [did] = useSelectedOrganization();\n\n useEffect(() => {\n if (!did) {\n return;\n }\n redirect('show', 'organizations', did);\n }, [did, redirect]);\n\n return <Loading sx={{ pt: '60px' }} />;\n};\n\nexport default Dashboard;\n","/**\n * Copyright 2023 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport List from '@mui/material/List';\nimport ListItemButton from '@mui/material/ListItemButton';\nimport ListItemText from '@mui/material/ListItemText';\n\nimport theme, { FOOTER_HEIGHT } from '../theme/theme.js';\n\nconst Footer = () => {\n return (\n <footer style={styles.footer}>\n <List sx={styles.list} component=\"nav\" aria-label=\"footer navigation\">\n <ListItemButton disabled>\n <ListItemText slotProps={{ primary: { sx: styles.listText } }} primary=\"CONTACT US\" />\n </ListItemButton>\n <ListItemButton\n onClick={() => window.open(`${window.location.origin}/terms-and-conditions`, '_blank')}\n >\n <ListItemText slotProps={{ primary: { sx: styles.listText } }} primary=\"TERMS OF USE\" />\n </ListItemButton>\n <ListItemButton\n onClick={() => window.open(`${window.location.origin}/privacy-policy`, '_blank')}\n >\n <ListItemText slotProps={{ primary: { sx: styles.listText } }} primary=\"PRIVACY POLICY\" />\n </ListItemButton>\n </List>\n <div style={styles.text}>\n All rights reserved {new Date().getFullYear()}\n <img\n src=\"/assets/images/logo.svg\"\n alt=\"Velocity\"\n width={98}\n height={20}\n style={styles.icon}\n />\n </div>\n </footer>\n );\n};\n\nexport default Footer;\n\nconst styles = {\n footer: {\n position: 'absolute',\n right: 0,\n bottom: 0,\n left: 0,\n zIndex: 100,\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'center',\n height: FOOTER_HEIGHT,\n paddingRight: 10,\n backgroundColor: theme.palette.background.default,\n borderTop: `1px solid ${theme.palette.divider.main}`,\n },\n list: {\n display: 'flex',\n color: theme.palette.secondary.light,\n },\n listText: {\n fontWeight: 600,\n fontSize: '12px',\n lineHeight: '16px',\n letterSpacing: '0.5px',\n fontFamily: theme.typography.fontFamily,\n },\n text: {\n fontWeight: 300,\n fontSize: '14px',\n lineHeight: '16px',\n letterSpacing: '0.1px',\n color: theme.palette.secondary.light,\n fontFamily: theme.typography.fontFamily,\n },\n icon: {\n verticalAlign: 'middle',\n color: theme.palette.secondary.light,\n paddingLeft: 30,\n filter:\n 'invert(68%) sepia(13%) saturate(102%) hue-rotate(185deg) brightness(89%) contrast(87%)', // filter for #989A9F\n },\n};\n","/*\n * Copyright 2025 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nimport PropTypes from 'prop-types';\nimport { Button, Typography, Stack, Box } from '@mui/material';\nimport { Link } from 'react-router';\n\nimport { Download } from '@mui/icons-material';\nimport Popup from './common/Popup.jsx';\nimport theme from '../theme/theme.js';\n\nconst TermsOfUsePopup = ({ onClose, isOpen, onProceed, title, onDownload }) => {\n return (\n <Popup title={title} onClose={onClose} isOpen={isOpen} titleStyles={sx.title}>\n <Stack justifyContent=\"center\" pt=\"8px\">\n <Typography alignSelf=\"center\">\n By clicking PROCEED you agree to the{' '}\n <Link target=\"_blank\" to=\"/terms-and-conditions\" role=\"link\" style={sx.link}>\n terms of use\n </Link>\n </Typography>\n <Box sx={sx.box}>\n <Button onClick={onProceed} variant=\"outlined\" sx={[sx.button, sx.proceed]} autoFocus>\n Proceed\n </Button>\n <Button onClick={onDownload} variant=\"outlined\" sx={sx.button} endIcon={<Download />}>\n Download PDF\n </Button>\n </Box>\n </Stack>\n </Popup>\n );\n};\n\nconst sx = {\n button: {\n width: 'fit-content',\n alignSelf: 'center',\n px: 4,\n py: 1,\n mt: '40px',\n mr: 2,\n '&:last-child': {\n mr: 0,\n },\n color: theme.palette.primary.main,\n borderColor: theme.palette.primary.main,\n '&:hover': {\n borderColor: theme.palette.primary.main,\n },\n },\n box: {\n display: 'flex',\n justifyContent: 'center',\n },\n link: { color: theme.palette.primary.main },\n title: { textAlign: 'center' },\n proceed: {\n color: theme.palette.text.primary,\n borderColor: theme.palette.secondary.light,\n '&:hover': {\n borderColor: theme.palette.secondary.light,\n },\n },\n};\n\n// eslint-disable-next-line better-mutation/no-mutation\nTermsOfUsePopup.propTypes = {\n onClose: PropTypes.func,\n onProceed: PropTypes.func,\n isOpen: PropTypes.bool,\n title: PropTypes.string,\n onDownload: PropTypes.func,\n};\n\nexport default TermsOfUsePopup;\n","/**\n * Copyright 2023 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { pdf } from '@react-pdf/renderer';\n\nimport { dataResources } from '../utils/remoteDataProvider.js';\nimport { parseJwt } from '../utils/index.jsx';\nimport { TERMS_AND_CONDITIONS_VERSION } from '../pages/TermsAndConditions.jsx';\nimport TermsAndConditionsPdf from '../pages/TermsAndConditionsPdf.jsx';\nimport TermsOfUsePopup from './TermsOfUsePopup.jsx';\nimport Loading from './Loading.jsx';\nimport { useAuth } from '../utils/auth/AuthContext.js';\nimport { useConfig } from '../utils/ConfigContext.js';\n\nconst logoutErrors = ['Unauthorized', 'missing_refresh_token', 'invalid_grant'];\n\nconst ConsentProvider = ({ children }) => {\n const [agreedVersion, setAgreedVersion] = useState(null);\n const [isShouldAgreeWithNewVersion, setIsShouldAgreeWithNewVersion] = useState(false);\n const [isNewUser, setIsNewUser] = useState(false);\n const [isNewUserHasScope, setIsNewUserHasScope] = useState(false);\n const [isLoading, setIsLoading] = useState(false);\n const { logout, getAccessToken } = useAuth();\n const config = useConfig();\n\n useEffect(() => {\n const checkIfUserScope = (token) => {\n const tokenDecoded = parseJwt(token);\n return tokenDecoded.scope.includes('read:organizations');\n };\n const handleNewUser = (token) => {\n const newUserScope = checkIfUserScope(token);\n setIsNewUser(true);\n setAgreedVersion('');\n setIsShouldAgreeWithNewVersion(newUserScope);\n setIsNewUserHasScope(newUserScope);\n setIsLoading(false);\n };\n const handleExistingUser = (data) => {\n const sortedConsents = [...data].sort(\n (consent1, consent2) => new Date(consent2.version) - new Date(consent1.version),\n );\n const lastAgreedVersion = sortedConsents[0].version;\n setAgreedVersion(lastAgreedVersion);\n\n if (lastAgreedVersion < TERMS_AND_CONDITIONS_VERSION) {\n setIsShouldAgreeWithNewVersion(true);\n }\n };\n\n const handleConsentError = (e) => {\n if (e.error && logoutErrors.includes(e.error)) {\n logout({ logoutParams: { returnTo: window.location.origin } });\n }\n };\n\n (async () => {\n try {\n const token = await getAccessToken();\n setIsLoading(true);\n const response = await fetch(`${config.registrarApi}/${dataResources.CONSENTS}`, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n Authorization: `Bearer ${token}`,\n },\n });\n const data = await response.json();\n if (data.error) {\n handleConsentError(data);\n } else if (!data || data.length === 0) {\n handleNewUser(token);\n } else {\n handleExistingUser(data);\n }\n\n setIsLoading(false);\n } catch (e) {\n handleConsentError(e);\n setIsLoading(false);\n setIsShouldAgreeWithNewVersion(false); // BE response 404, when `!consents.length`\n }\n })();\n }, [getAccessToken, logout, config.registrarApi, config]);\n\n const onAgreeWithNewVersion = async () => {\n try {\n const token = await getAccessToken();\n await fetch(`${config.registrarApi}/${dataResources.CONSENTS}`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n Authorization: `Bearer ${token}`,\n },\n body: JSON.stringify({\n version: TERMS_AND_CONDITIONS_VERSION,\n }),\n });\n setAgreedVersion(TERMS_AND_CONDITIONS_VERSION);\n setIsShouldAgreeWithNewVersion(false);\n } catch (e) {\n console.error('set consent', e);\n }\n };\n\n const skipTerms = useMemo(() => {\n const newUserWithScope = isNewUser ? isNewUserHasScope : true;\n return (\n !isLoading && isShouldAgreeWithNewVersion !== true && (agreedVersion || !newUserWithScope)\n );\n }, [isNewUser, isNewUserHasScope, isLoading, isShouldAgreeWithNewVersion, agreedVersion]);\n\n const downloadPdf = useCallback(async () => {\n const blob = await pdf(<TermsAndConditionsPdf />).toBlob();\n const link = document.createElement('a');\n link.setAttribute('href', URL.createObjectURL(blob));\n link.setAttribute('download', 'Terms and Conditions');\n document.body.append(link);\n\n link.click();\n link.remove();\n }, []);\n return (\n <>\n {skipTerms && children}\n {isLoading && <Loading sx={{ pt: '60px' }} />}\n <TermsOfUsePopup\n isOpen={isShouldAgreeWithNewVersion}\n onClose={() => {\n logout();\n }}\n onProceed={onAgreeWithNewVersion}\n title={isNewUser ? 'Terms of use' : 'The terms of use were updated'}\n onDownload={downloadPdf}\n />\n </>\n );\n};\n\nexport default ConsentProvider;\n\n// eslint-disable-next-line better-mutation/no-mutation\nConsentProvider.propTypes = {\n children: PropTypes.node,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAM,kBAAkB;CACtB,MAAM,WAAW,aAAa;CAC9B,MAAM,CAAC,OAAO,yBAAyB;AAEvC,iBAAgB;AACd,MAAI,CAAC,IACH;AAEF,WAAS,QAAQ,iBAAiB,IAAI;IACrC,CAAC,KAAK,SAAS,CAAC;AAEnB,QAAO,oBAAC,SAAD,EAAS,IAAI,EAAE,IAAI,QAAQ,EAAI,CAAA;;;;;;;;;;;;;;;;;;;ACVxC,IAAM,eAAe;AACnB,QACE,qBAAC,UAAD;EAAQ,OAAO,OAAO;YAAtB,CACE,qBAAC,QAAD;GAAM,IAAI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Z,EAAE,CAAC;AACN,QACE,qBAAA,YAAA,EAAA,UAAA;EACG,aAAa;EACb,aAAa,oBAAC,SAAD,EAAS,IAAI,EAAE,IAAI,QAAQ,EAAI,CAAA;EAC7C,oBAAC,iBAAD;GACE,QAAQ;GACR,eAAe;AACb,YAAQ;;GAEV,WAAW;GACX,OAAO,YAAY,iBAAiB;GACpC,YAAY;GACZ,CAAA;EACD,EAAA,CAAA;;AAOP,gBAAgB,YAAY,EAC1B,UAAU,UAAU,MACrB"}
|
|
1
|
+
{"version":3,"file":"ConsentProvider.Dq52xEkc.js","names":[],"sources":["../../src/components/Dashboard.jsx","../../src/components/Footer.jsx","../../src/components/TermsOfUsePopup.jsx","../../src/components/ConsentProvider.jsx"],"sourcesContent":["/**\n * Copyright 2023 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect } from 'react';\nimport { useRedirect } from 'react-admin';\nimport useSelectedOrganization from '../state/selectedOrganizationState.js';\nimport Loading from './Loading.jsx';\n\nconst Dashboard = () => {\n const redirect = useRedirect();\n const [did] = useSelectedOrganization();\n\n useEffect(() => {\n if (!did) {\n return;\n }\n redirect('show', 'organizations', did);\n }, [did, redirect]);\n\n return <Loading sx={{ pt: '60px' }} />;\n};\n\nexport default Dashboard;\n","/**\n * Copyright 2023 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport List from '@mui/material/List';\nimport ListItemButton from '@mui/material/ListItemButton';\nimport ListItemText from '@mui/material/ListItemText';\n\nimport theme, { FOOTER_HEIGHT } from '../theme/theme.js';\n\nconst Footer = () => {\n return (\n <footer style={styles.footer}>\n <List sx={styles.list} component=\"nav\" aria-label=\"footer navigation\">\n <ListItemButton disabled>\n <ListItemText slotProps={{ primary: { sx: styles.listText } }} primary=\"CONTACT US\" />\n </ListItemButton>\n <ListItemButton\n onClick={() => window.open(`${window.location.origin}/terms-and-conditions`, '_blank')}\n >\n <ListItemText slotProps={{ primary: { sx: styles.listText } }} primary=\"TERMS OF USE\" />\n </ListItemButton>\n <ListItemButton\n onClick={() => window.open(`${window.location.origin}/privacy-policy`, '_blank')}\n >\n <ListItemText slotProps={{ primary: { sx: styles.listText } }} primary=\"PRIVACY POLICY\" />\n </ListItemButton>\n </List>\n <div style={styles.text}>\n All rights reserved {new Date().getFullYear()}\n <img\n src=\"/assets/images/logo.svg\"\n alt=\"Velocity\"\n width={98}\n height={20}\n style={styles.icon}\n />\n </div>\n </footer>\n );\n};\n\nexport default Footer;\n\nconst styles = {\n footer: {\n position: 'absolute',\n right: 0,\n bottom: 0,\n left: 0,\n zIndex: 100,\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'center',\n height: FOOTER_HEIGHT,\n paddingRight: 10,\n backgroundColor: theme.palette.background.default,\n borderTop: `1px solid ${theme.palette.divider.main}`,\n },\n list: {\n display: 'flex',\n color: theme.palette.secondary.light,\n },\n listText: {\n fontWeight: 600,\n fontSize: '12px',\n lineHeight: '16px',\n letterSpacing: '0.5px',\n fontFamily: theme.typography.fontFamily,\n },\n text: {\n fontWeight: 300,\n fontSize: '14px',\n lineHeight: '16px',\n letterSpacing: '0.1px',\n color: theme.palette.secondary.light,\n fontFamily: theme.typography.fontFamily,\n },\n icon: {\n verticalAlign: 'middle',\n color: theme.palette.secondary.light,\n paddingLeft: 30,\n filter:\n 'invert(68%) sepia(13%) saturate(102%) hue-rotate(185deg) brightness(89%) contrast(87%)', // filter for #989A9F\n },\n};\n","/*\n * Copyright 2025 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nimport PropTypes from 'prop-types';\nimport { Button, Typography, Stack, Box } from '@mui/material';\nimport { Link } from 'react-router';\n\nimport { Download } from '@mui/icons-material';\nimport Popup from './common/Popup.jsx';\nimport theme from '../theme/theme.js';\n\nconst TermsOfUsePopup = ({ onClose, isOpen, onProceed, title, onDownload }) => {\n return (\n <Popup title={title} onClose={onClose} isOpen={isOpen} titleStyles={sx.title}>\n <Stack justifyContent=\"center\" pt=\"8px\">\n <Typography alignSelf=\"center\">\n By clicking PROCEED you agree to the{' '}\n <Link target=\"_blank\" to=\"/terms-and-conditions\" role=\"link\" style={sx.link}>\n terms of use\n </Link>\n </Typography>\n <Box sx={sx.box}>\n <Button onClick={onProceed} variant=\"outlined\" sx={[sx.button, sx.proceed]} autoFocus>\n Proceed\n </Button>\n <Button onClick={onDownload} variant=\"outlined\" sx={sx.button} endIcon={<Download />}>\n Download PDF\n </Button>\n </Box>\n </Stack>\n </Popup>\n );\n};\n\nconst sx = {\n button: {\n width: 'fit-content',\n alignSelf: 'center',\n px: 4,\n py: 1,\n mt: '40px',\n mr: 2,\n '&:last-child': {\n mr: 0,\n },\n color: theme.palette.primary.main,\n borderColor: theme.palette.primary.main,\n '&:hover': {\n borderColor: theme.palette.primary.main,\n },\n },\n box: {\n display: 'flex',\n justifyContent: 'center',\n },\n link: { color: theme.palette.primary.main },\n title: { textAlign: 'center' },\n proceed: {\n color: theme.palette.text.primary,\n borderColor: theme.palette.secondary.light,\n '&:hover': {\n borderColor: theme.palette.secondary.light,\n },\n },\n};\n\n// eslint-disable-next-line better-mutation/no-mutation\nTermsOfUsePopup.propTypes = {\n onClose: PropTypes.func,\n onProceed: PropTypes.func,\n isOpen: PropTypes.bool,\n title: PropTypes.string,\n onDownload: PropTypes.func,\n};\n\nexport default TermsOfUsePopup;\n","/**\n * Copyright 2023 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { pdf } from '@react-pdf/renderer';\n\nimport { dataResources } from '../utils/remoteDataProvider.js';\nimport { parseJwt } from '../utils/index.jsx';\nimport { TERMS_AND_CONDITIONS_VERSION } from '../pages/TermsAndConditions.jsx';\nimport TermsAndConditionsPdf from '../pages/TermsAndConditionsPdf.jsx';\nimport TermsOfUsePopup from './TermsOfUsePopup.jsx';\nimport Loading from './Loading.jsx';\nimport { useAuth } from '../utils/auth/AuthContext.js';\nimport { useConfig } from '../utils/ConfigContext.js';\n\nconst logoutErrors = ['Unauthorized', 'missing_refresh_token', 'invalid_grant'];\n\nconst ConsentProvider = ({ children }) => {\n const [agreedVersion, setAgreedVersion] = useState(null);\n const [isShouldAgreeWithNewVersion, setIsShouldAgreeWithNewVersion] = useState(false);\n const [isNewUser, setIsNewUser] = useState(false);\n const [isNewUserHasScope, setIsNewUserHasScope] = useState(false);\n const [isLoading, setIsLoading] = useState(false);\n const { logout, getAccessToken } = useAuth();\n const config = useConfig();\n\n useEffect(() => {\n const checkIfUserScope = (token) => {\n const tokenDecoded = parseJwt(token);\n return tokenDecoded.scope.includes('read:organizations');\n };\n const handleNewUser = (token) => {\n const newUserScope = checkIfUserScope(token);\n setIsNewUser(true);\n setAgreedVersion('');\n setIsShouldAgreeWithNewVersion(newUserScope);\n setIsNewUserHasScope(newUserScope);\n setIsLoading(false);\n };\n const handleExistingUser = (data) => {\n const sortedConsents = [...data].sort(\n (consent1, consent2) => new Date(consent2.version) - new Date(consent1.version),\n );\n const lastAgreedVersion = sortedConsents[0].version;\n setAgreedVersion(lastAgreedVersion);\n\n if (lastAgreedVersion < TERMS_AND_CONDITIONS_VERSION) {\n setIsShouldAgreeWithNewVersion(true);\n }\n };\n\n const handleConsentError = (e) => {\n if (e.error && logoutErrors.includes(e.error)) {\n logout({\n source: 'consent-error',\n details: { error: e.error },\n logoutParams: { returnTo: window.location.origin },\n });\n }\n };\n\n (async () => {\n try {\n const token = await getAccessToken();\n setIsLoading(true);\n const response = await fetch(`${config.registrarApi}/${dataResources.CONSENTS}`, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n Authorization: `Bearer ${token}`,\n },\n });\n const data = await response.json();\n if (data.error) {\n handleConsentError(data);\n } else if (!data || data.length === 0) {\n handleNewUser(token);\n } else {\n handleExistingUser(data);\n }\n\n setIsLoading(false);\n } catch (e) {\n handleConsentError(e);\n setIsLoading(false);\n setIsShouldAgreeWithNewVersion(false); // BE response 404, when `!consents.length`\n }\n })();\n }, [getAccessToken, logout, config.registrarApi, config]);\n\n const onAgreeWithNewVersion = async () => {\n try {\n const token = await getAccessToken();\n await fetch(`${config.registrarApi}/${dataResources.CONSENTS}`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n Authorization: `Bearer ${token}`,\n },\n body: JSON.stringify({\n version: TERMS_AND_CONDITIONS_VERSION,\n }),\n });\n setAgreedVersion(TERMS_AND_CONDITIONS_VERSION);\n setIsShouldAgreeWithNewVersion(false);\n } catch (e) {\n console.error('set consent', e);\n }\n };\n\n const skipTerms = useMemo(() => {\n const newUserWithScope = isNewUser ? isNewUserHasScope : true;\n return (\n !isLoading && isShouldAgreeWithNewVersion !== true && (agreedVersion || !newUserWithScope)\n );\n }, [isNewUser, isNewUserHasScope, isLoading, isShouldAgreeWithNewVersion, agreedVersion]);\n\n const downloadPdf = useCallback(async () => {\n const blob = await pdf(<TermsAndConditionsPdf />).toBlob();\n const link = document.createElement('a');\n link.setAttribute('href', URL.createObjectURL(blob));\n link.setAttribute('download', 'Terms and Conditions');\n document.body.append(link);\n\n link.click();\n link.remove();\n }, []);\n return (\n <>\n {skipTerms && children}\n {isLoading && <Loading sx={{ pt: '60px' }} />}\n <TermsOfUsePopup\n isOpen={isShouldAgreeWithNewVersion}\n onClose={() => {\n logout({ source: 'terms-popup-close' });\n }}\n onProceed={onAgreeWithNewVersion}\n title={isNewUser ? 'Terms of use' : 'The terms of use were updated'}\n onDownload={downloadPdf}\n />\n </>\n );\n};\n\nexport default ConsentProvider;\n\n// eslint-disable-next-line better-mutation/no-mutation\nConsentProvider.propTypes = {\n children: PropTypes.node,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAM,kBAAkB;CACtB,MAAM,WAAW,aAAa;CAC9B,MAAM,CAAC,OAAO,yBAAyB;AAEvC,iBAAgB;AACd,MAAI,CAAC,IACH;AAEF,WAAS,QAAQ,iBAAiB,IAAI;IACrC,CAAC,KAAK,SAAS,CAAC;AAEnB,QAAO,oBAAC,SAAD,EAAS,IAAI,EAAE,IAAI,QAAQ,EAAI,CAAA;;;;;;;;;;;;;;;;;;;ACVxC,IAAM,eAAe;AACnB,QACE,qBAAC,UAAD;EAAQ,OAAO,OAAO;YAAtB,CACE,qBAAC,QAAD;GAAM,IAAI,OAAO;GAAM,WAAU;GAAM,cAAW;aAAlD;IACE,oBAAC,kBAAD;KAAgB,UAAA;eACd,oBAAC,cAAD;MA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UAAA;EACG,aAAa;EACb,aAAa,oBAAC,SAAD,EAAS,IAAI,EAAE,IAAI,QAAQ,EAAI,CAAA;EAC7C,oBAAC,iBAAD;GACE,QAAQ;GACR,eAAe;AACb,WAAO,EAAE,QAAQ,qBAAqB,CAAC;;GAEzC,WAAW;GACX,OAAO,YAAY,iBAAiB;GACpC,YAAY;GACZ,CAAA;EACD,EAAA,CAAA;;AAOP,gBAAgB,YAAY,EAC1B,UAAU,UAAU,MACrB"}
|
package/dist/chunks/{CreateOrganizationUtils.IHpfMpyX.js → CreateOrganizationUtils.BhCGAWVR.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require("./Loading.C6QWcMb4.js");
|
|
2
|
-
const require_utils = require("./utils.
|
|
2
|
+
const require_utils = require("./utils.D7BeVF1I.js");
|
|
3
3
|
let react_admin = require("react-admin");
|
|
4
4
|
//#region src/components/organizations/CreateOrganizationUtils.js
|
|
5
5
|
/**
|
|
@@ -62,4 +62,4 @@ Object.defineProperty(exports, "validateWebsiteStrict", {
|
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
//# sourceMappingURL=CreateOrganizationUtils.
|
|
65
|
+
//# sourceMappingURL=CreateOrganizationUtils.BhCGAWVR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateOrganizationUtils.
|
|
1
|
+
{"version":3,"file":"CreateOrganizationUtils.BhCGAWVR.js","names":["validUrlRegexp","secureUrlRegexp","webSiteRegexp","webSiteHttpsRegexp","webSiteCleanPathRegexp"],"sources":["../../src/components/organizations/CreateOrganizationUtils.js"],"sourcesContent":["/**\n * Copyright 2023 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { email, maxLength, required, regex } from 'react-admin';\nimport {\n validUrlRegexp,\n secureUrlRegexp,\n webSiteRegexp,\n webSiteHttpsRegexp,\n webSiteCleanPathRegexp,\n} from '../../utils/index.jsx';\n\nconst urlValidation = (value) => {\n if (!(value && validUrlRegexp.test(value.trim()))) {\n return 'Please type in a valid URL';\n }\n if (!(value && secureUrlRegexp.test(value.trim()))) {\n return `Invalid service endpoint url '${value}'. https is required`;\n }\n return undefined;\n};\n\nexport const validateWebsite = [\n regex(webSiteRegexp, 'Please type in a valid URL'),\n regex(webSiteHttpsRegexp, 'Https is required'),\n maxLength(1024),\n];\n\nexport const validateWebsiteStrict = [\n ...validateWebsite,\n regex(webSiteCleanPathRegexp, 'Website must not contain a path after domain'),\n];\nexport const validateName = [required(), maxLength(100)];\nexport const validateServiceEndpoint = [urlValidation, maxLength(1024)];\nexport const validateEmail = [email()];\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAyBA,IAAM,iBAAiB,UAAU;AAC/B,KAAI,EAAE,SAASA,cAAAA,eAAe,KAAK,MAAM,MAAM,CAAC,EAC9C,QAAO;AAET,KAAI,EAAE,SAASC,cAAAA,gBAAgB,KAAK,MAAM,MAAM,CAAC,EAC/C,QAAO,iCAAiC,MAAM;;AAKlD,IAAa,kBAAkB;wBACvBC,cAAAA,eAAe,6BAA6B;wBAC5CC,cAAAA,oBAAoB,oBAAoB;4BACpC,KAAK;CAChB;AAED,IAAa,wBAAwB,CACnC,GAAG,kBAAA,GAAA,YAAA,OACGC,cAAAA,wBAAwB,+CAA+C,CAC9E;AACD,IAAa,eAAe,EAAA,GAAA,YAAA,WAAW,GAAA,GAAA,YAAA,WAAY,IAAI,CAAC;AACxD,IAAa,0BAA0B,CAAC,gBAAA,GAAA,YAAA,WAAyB,KAAK,CAAC;AACvE,IAAa,gBAAgB,EAAA,GAAA,YAAA,QAAQ,CAAC"}
|
package/dist/chunks/{CreateOrganizationUtils.BAL1YBx4.js → CreateOrganizationUtils.z-XS18wQ.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as webSiteCleanPathRegexp, S as validUrlRegexp, T as webSiteRegexp, b as secureUrlRegexp, w as webSiteHttpsRegexp } from "./utils.
|
|
1
|
+
import { C as webSiteCleanPathRegexp, S as validUrlRegexp, T as webSiteRegexp, b as secureUrlRegexp, w as webSiteHttpsRegexp } from "./utils.BDiFYUJC.js";
|
|
2
2
|
import { email, maxLength, regex, required } from "react-admin";
|
|
3
3
|
//#region src/components/organizations/CreateOrganizationUtils.js
|
|
4
4
|
/**
|
|
@@ -32,4 +32,4 @@ var validateEmail = [email()];
|
|
|
32
32
|
//#endregion
|
|
33
33
|
export { validateWebsiteStrict as a, validateWebsite as i, validateName as n, validateServiceEndpoint as r, validateEmail as t };
|
|
34
34
|
|
|
35
|
-
//# sourceMappingURL=CreateOrganizationUtils.
|
|
35
|
+
//# sourceMappingURL=CreateOrganizationUtils.z-XS18wQ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateOrganizationUtils.
|
|
1
|
+
{"version":3,"file":"CreateOrganizationUtils.z-XS18wQ.js","names":[],"sources":["../../src/components/organizations/CreateOrganizationUtils.js"],"sourcesContent":["/**\n * Copyright 2023 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { email, maxLength, required, regex } from 'react-admin';\nimport {\n validUrlRegexp,\n secureUrlRegexp,\n webSiteRegexp,\n webSiteHttpsRegexp,\n webSiteCleanPathRegexp,\n} from '../../utils/index.jsx';\n\nconst urlValidation = (value) => {\n if (!(value && validUrlRegexp.test(value.trim()))) {\n return 'Please type in a valid URL';\n }\n if (!(value && secureUrlRegexp.test(value.trim()))) {\n return `Invalid service endpoint url '${value}'. https is required`;\n }\n return undefined;\n};\n\nexport const validateWebsite = [\n regex(webSiteRegexp, 'Please type in a valid URL'),\n regex(webSiteHttpsRegexp, 'Https is required'),\n maxLength(1024),\n];\n\nexport const validateWebsiteStrict = [\n ...validateWebsite,\n regex(webSiteCleanPathRegexp, 'Website must not contain a path after domain'),\n];\nexport const validateName = [required(), maxLength(100)];\nexport const validateServiceEndpoint = [urlValidation, maxLength(1024)];\nexport const validateEmail = [email()];\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyBA,IAAM,iBAAiB,UAAU;AAC/B,KAAI,EAAE,SAAS,eAAe,KAAK,MAAM,MAAM,CAAC,EAC9C,QAAO;AAET,KAAI,EAAE,SAAS,gBAAgB,KAAK,MAAM,MAAM,CAAC,EAC/C,QAAO,iCAAiC,MAAM;;AAKlD,IAAa,kBAAkB;CAC7B,MAAM,eAAe,6BAA6B;CAClD,MAAM,oBAAoB,oBAAoB;CAC9C,UAAU,KAAK;CAChB;AAED,IAAa,wBAAwB,CACnC,GAAG,iBACH,MAAM,wBAAwB,+CAA+C,CAC9E;AACD,IAAa,eAAe,CAAC,UAAU,EAAE,UAAU,IAAI,CAAC;AACxD,IAAa,0BAA0B,CAAC,eAAe,UAAU,KAAK,CAAC;AACvE,IAAa,gBAAgB,CAAC,OAAO,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { x as useIsHideSidebar } from "./utils.
|
|
1
|
+
import { x as useIsHideSidebar } from "./utils.BDiFYUJC.js";
|
|
2
2
|
import { t as Loading } from "./Loading.D7UqoOup.js";
|
|
3
3
|
import { t as OrganizationAvatar } from "./OrganizationAvatar.DS6kYxbZ.js";
|
|
4
4
|
import { t as useSelectedOrganization } from "./selectedOrganizationState.5NpnMWEo.js";
|
|
5
5
|
import { t as useCountryCodes } from "./countryCodes.BmivMxyD.js";
|
|
6
|
-
import { n as useAuth } from "./AuthContext.
|
|
6
|
+
import { n as useAuth } from "./AuthContext.xLW3Bdji.js";
|
|
7
7
|
import { t as dataResources } from "./remoteDataProvider.CPyVNIhT.js";
|
|
8
8
|
import React, { useEffect, useState } from "react";
|
|
9
9
|
import { useGetList, useGetOne, useLogout, useRedirect } from "react-admin";
|
|
10
|
+
import { Link } from "react-router";
|
|
10
11
|
import { AppBar, Box, Button as Button$1, List as List$1, ListItem, ListItemButton, Popover, Stack, Toolbar, Typography } from "@mui/material";
|
|
11
|
-
import { Link as Link$1 } from "react-router";
|
|
12
12
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
13
13
|
import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown";
|
|
14
14
|
import AddIcon from "@mui/icons-material/Add";
|
|
@@ -33,7 +33,6 @@ var AppBarOrganization = () => {
|
|
|
33
33
|
const isHidden = useIsHideSidebar();
|
|
34
34
|
const redirect = useRedirect();
|
|
35
35
|
const [did, setDid] = useSelectedOrganization();
|
|
36
|
-
const auth = useAuth();
|
|
37
36
|
const logout = useLogout();
|
|
38
37
|
const { data: allOrganizations, isLoading } = useGetList("organizations", void 0, {
|
|
39
38
|
onSuccess: ({ data }) => {
|
|
@@ -60,7 +59,7 @@ var AppBarOrganization = () => {
|
|
|
60
59
|
};
|
|
61
60
|
const handleLogoutClick = () => {
|
|
62
61
|
setAnchorEl(null);
|
|
63
|
-
logout(
|
|
62
|
+
logout({ source: "app-bar-organization" }, "/", false);
|
|
64
63
|
};
|
|
65
64
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(Stack, {
|
|
66
65
|
sx: sx.root,
|
|
@@ -282,7 +281,7 @@ var CustomAppBar = (props) => {
|
|
|
282
281
|
...props,
|
|
283
282
|
elevation: 0,
|
|
284
283
|
children: /* @__PURE__ */ jsxs(Toolbar, { children: [
|
|
285
|
-
/* @__PURE__ */ jsx(Link
|
|
284
|
+
/* @__PURE__ */ jsx(Link, {
|
|
286
285
|
to: isLogoDisabled ? void 0 : "/",
|
|
287
286
|
style: {
|
|
288
287
|
display: "flex",
|
|
@@ -304,4 +303,4 @@ var CustomAppBar = (props) => {
|
|
|
304
303
|
//#endregion
|
|
305
304
|
export { AppBarOrganization as n, CustomAppBar as t };
|
|
306
305
|
|
|
307
|
-
//# sourceMappingURL=CustomAppBar.
|
|
306
|
+
//# sourceMappingURL=CustomAppBar.BXQSOkgw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomAppBar.BXQSOkgw.js","names":[],"sources":["../../src/components/AppBar/AppBarOrganization.jsx","../../src/components/AppBar/hooks/useCheckUserHasGroup.js","../../src/components/AppBar/CustomAppBar.jsx"],"sourcesContent":["/**\n * Copyright 2023 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { useLogout, useRedirect, useGetList } from 'react-admin';\nimport {\n Box,\n Button,\n List,\n ListItem,\n ListItemButton,\n Popover,\n Stack,\n Typography,\n} from '@mui/material';\nimport ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';\nimport AddIcon from '@mui/icons-material/Add';\nimport OrganizationAvatar from '../common/OrganizationAvatar.jsx';\nimport useSelectedOrganization from '../../state/selectedOrganizationState.js';\nimport { useIsHideSidebar } from '../../utils/index.jsx';\nimport useCountryCodes from '../../utils/countryCodes.js';\nimport Loading from '../Loading.jsx';\n\n// eslint-disable-next-line complexity\nconst AppBarOrganization = () => {\n const { getCountryNameByCode } = useCountryCodes();\n const isHidden = useIsHideSidebar();\n const redirect = useRedirect();\n const [did, setDid] = useSelectedOrganization();\n const logout = useLogout();\n\n const { data: allOrganizations, isLoading } = useGetList('organizations', undefined, {\n onSuccess: ({ data }) => {\n if (!data) {\n return;\n }\n\n if (data.find((item) => item.id === did)) {\n return;\n }\n\n setDid(data[0].id);\n },\n onError: () => redirect('/'),\n });\n\n const [anchorEl, setAnchorEl] = React.useState(null);\n\n const organization = React.useMemo(\n () => (allOrganizations || []).find((item) => item.id === did),\n [did, allOrganizations],\n );\n\n if (isLoading) {\n return (\n <Box>\n <Loading />\n </Box>\n );\n }\n\n if (!did || !allOrganizations || isHidden || !organization) {\n return null;\n }\n\n const isOpen = Boolean(anchorEl);\n const id = isOpen ? 'user-menu' : undefined;\n\n const handleSelectOrganization = (value) => {\n setDid(value);\n setAnchorEl(null);\n redirect('show', 'organizations', value);\n };\n\n const handleAddNewClick = () => {\n setAnchorEl(null);\n redirect('create', 'organizations');\n };\n\n const handleLogoutClick = () => {\n setAnchorEl(null);\n logout({ source: 'app-bar-organization' }, '/', false);\n };\n\n return (\n <>\n <Stack\n sx={sx.root}\n role=\"button\"\n aria-describedby={id}\n onClick={(e) => setAnchorEl(e.currentTarget)}\n data-testid=\"app-bar-org\"\n >\n <OrganizationAvatar\n size={36}\n name={organization.profile.name}\n logo={organization.profile.logo}\n />\n <Box>\n <Typography variant=\"pl\" component=\"div\" fontWeight={600}>\n {organization.profile.name}\n </Typography>\n <Typography variant=\"ps\" mt={0.25}>\n {getCountryNameByCode(organization.profile.location.countryCode)}\n </Typography>\n </Box>\n <ArrowDropDownIcon />\n </Stack>\n <Popover\n id={id}\n open={isOpen}\n anchorEl={anchorEl}\n onClose={() => setAnchorEl(null)}\n componentsProps={{\n backdrop: {\n invisible: true,\n },\n }}\n anchorOrigin={{\n vertical: 'bottom',\n horizontal: 'right',\n }}\n transformOrigin={{\n vertical: 'top',\n horizontal: 'right',\n }}\n >\n <Stack sx={sx.popup} alignItems=\"center\">\n <OrganizationAvatar\n size={56}\n name={organization.profile.name}\n logo={organization.profile.logo}\n />\n <Typography mt={2} variant=\"h5\">\n {organization.profile.name}\n </Typography>\n <Typography mt={2} variant=\"pm\" fontWeight=\"600\" sx={sx.did}>\n {did}\n </Typography>\n <Typography variant=\"ps\" mt={1} mb={3}>\n {getCountryNameByCode(organization.profile.location.countryCode)}\n </Typography>\n <List sx={sx.list}>\n {allOrganizations\n .filter((item) => item.id !== did)\n .map((item) => (\n <ListItem key={item.id} sx={sx.listItem} disablePadding>\n <ListItemButton\n sx={sx.listItemButton}\n onClick={() => handleSelectOrganization(item.id)}\n >\n <OrganizationAvatar\n size={26}\n name={item.profile.name}\n logo={item.profile.logo}\n />\n <Typography variant=\"pm\" fontWeight={600}>\n {item.profile.name}\n </Typography>\n </ListItemButton>\n </ListItem>\n ))}\n <ListItem key=\"'add-new'\" sx={sx.listItem} disablePadding>\n <ListItemButton sx={sx.listItemButton} onClick={handleAddNewClick}>\n <Box sx={sx.plusIcon}>\n <AddIcon />\n </Box>\n <Typography variant=\"pm\" fontWeight={600} fontSize={12}>\n ADD ORGANIZATION\n </Typography>\n </ListItemButton>\n </ListItem>\n </List>\n <Button\n sx={sx.logout}\n onClick={handleLogoutClick}\n variant=\"outlined\"\n color=\"secondary\"\n size=\"small\"\n >\n LOG OUT\n </Button>\n\n <Button sx={sx.changePassword} variant=\"text\" color=\"secondary\" size=\"small\">\n Change password\n </Button>\n </Stack>\n </Popover>\n </>\n );\n};\n\nexport default AppBarOrganization;\n\nconst sx = {\n root: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 1.5,\n cursor: 'pointer',\n py: 1.25,\n },\n popup: {\n minWidth: 368,\n py: 4,\n },\n list: {\n alignSelf: 'stretch',\n },\n listItem: {\n borderTop: (theme) => `1px solid ${theme.palette.divider.main}`,\n },\n listItemButton: {\n gap: 2.5,\n px: 3.25,\n py: 1.5,\n },\n plusIcon: {\n padding: 0.625,\n display: 'flex',\n },\n logout: {\n mt: 1,\n minWidth: 176,\n },\n changePassword: {\n mt: 2,\n },\n did: {\n wordBreak: 'break-word',\n px: '10px',\n },\n};\n","import { useEffect, useState } from 'react';\nimport { useGetOne, useRedirect } from 'react-admin';\nimport { useAuth } from '@/utils/auth/AuthContext.js';\nimport { dataResources } from '@/utils/remoteDataProvider.js';\nimport useSelectedOrganization from '@/state/selectedOrganizationState.js';\n\nexport const useCheckUserHasGroup = () => {\n const { user, getAccessTokenWithPopup } = useAuth();\n const redirect = useRedirect();\n const [, setDid] = useSelectedOrganization();\n const {\n data: userData,\n isLoading: isUserDataLoading,\n isError,\n } = useGetOne(dataResources.USERS, {\n id: user.sub,\n });\n const [isLoading, setIsLoading] = useState(false);\n const [hasOrganisations, setHasOrganisations] = useState(false);\n\n useEffect(() => {\n const checkUserGroup = async () => {\n setIsLoading(true);\n try {\n const userHasGroup = !!userData?.groupId;\n if (userHasGroup) {\n setHasOrganisations(true);\n return;\n }\n\n setDid('');\n if (!/organizations\\/create/.test(window.location.pathname)) {\n redirect('create', 'organizations', undefined, undefined, { userHasGroup });\n }\n } catch (e) {\n if (e.error === 'consent_required') {\n await getAccessTokenWithPopup();\n }\n throw e;\n } finally {\n setIsLoading(false);\n }\n };\n if (!isUserDataLoading && (userData || isError)) {\n checkUserGroup();\n }\n }, [\n getAccessTokenWithPopup,\n redirect,\n setDid,\n setIsLoading,\n userData?.groupId,\n isUserDataLoading,\n userData,\n isError,\n ]);\n\n return {\n isLoading,\n hasOrganisations,\n };\n};\n","/**\n * Copyright 2023 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Link } from 'react-router';\nimport { AppBar, Box, Toolbar } from '@mui/material';\nimport AppBarOrganization from './AppBarOrganization.jsx';\nimport { useCheckUserHasGroup } from './hooks/useCheckUserHasGroup.js';\n\nconst CustomAppBar = (props) => {\n const { hasOrganisations, isLoading } = useCheckUserHasGroup();\n const isLogoDisabled = isLoading || !hasOrganisations;\n\n return (\n <AppBar {...props} elevation={0}>\n <Toolbar>\n <Link\n to={isLogoDisabled ? undefined : '/'}\n style={{ display: 'flex', ...(isLogoDisabled ? { pointerEvents: 'none' } : {}) }}\n aria-disabled={isLogoDisabled}\n disabled={isLogoDisabled}\n role=\"link\"\n >\n <img src=\"/assets/images/logo.svg\" alt=\"Velocity\" />\n </Link>\n <Box flex={1} />\n {hasOrganisations && <AppBarOrganization />}\n </Toolbar>\n </AppBar>\n );\n};\n\nexport default CustomAppBar;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,IAAM,2BAA2B;CAC/B,MAAM,EAAE,yBAAyB,iBAAiB;CAClD,MAAM,WAAW,kBAAkB;CACnC,MAAM,WAAW,aAAa;CAC9B,MAAM,CAAC,KAAK,UAAU,yBAAyB;CAC/C,MAAM,SAAS,WAAW;CAE1B,MAAM,EAAE,MAAM,kBAAkB,cAAc,WAAW,iBAAiB,KAAA,GAAW;EACnF,YAAY,EAAE,WAAW;AACvB,OAAI,CAAC,KACH;AAGF,OAAI,KAAK,MAAM,SAAS,KAAK,OAAO,IAAI,CACtC;AAGF,UAAO,KAAK,GAAG,GAAG;;EAEpB,eAAe,SAAS,IAAI;EAC7B,CAAC;CAEF,MAAM,CAAC,UAAU,eAAe,MAAM,SAAS,KAAK;CAEpD,MAAM,eAAe,MAAM,eAClB,oBAAoB,EAAE,EAAE,MAAM,SAAS,KAAK,OAAO,IAAI,EAC9D,CAAC,KAAK,iBAAiB,CACxB;AAED,KAAI,UACF,QACE,oBAAC,KAAD,EAAA,UACE,oBAAC,SAAD,EAAW,CAAA,EACP,CAAA;AAIV,KAAI,C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;;;;;;;;;;;;;;ACvCH,IAAM,gBAAgB,UAAU;CAC9B,MAAM,EAAE,kBAAkB,cAAc,sBAAsB;CAC9D,MAAM,iBAAiB,aAAa,CAAC;AAErC,QACE,oBAAC,QAAD;EAAQ,GAAI;EAAO,WAAW;YAC5B,qBAAC,SAAD,EAAA,UAAA;GACE,oBAAC,MAAD;IACE,IAAI,iBAAiB,KAAA,IAAY;IACjC,OAAO;KAAE,SAAS;KAAQ,GAAI,iBAAiB,EAAE,eAAe,QAAQ,GAAG,EAAE;KAAG;IAChF,iBAAe;IACf,UAAU;IACV,MAAK;cAEL,oBAAC,OAAD;KAAK,KAAI;KAA0B,KAAI;KAAa,CAAA;IAC/C,CAAA;GACP,oBAAC,KAAD,EAAK,MAAM,GAAK,CAAA;GACf,oBAAoB,oBAAC,oBAAD,EAAsB,CAAA;GACnC,EAAA,CAAA;EACH,CAAA"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
const require_Loading = require("./Loading.C6QWcMb4.js");
|
|
2
|
-
const require_utils = require("./utils.
|
|
2
|
+
const require_utils = require("./utils.D7BeVF1I.js");
|
|
3
3
|
const require_OrganizationAvatar = require("./OrganizationAvatar.CoqOpFDY.js");
|
|
4
4
|
const require_selectedOrganizationState = require("./selectedOrganizationState.1hFVZLSS.js");
|
|
5
5
|
const require_countryCodes = require("./countryCodes.BEAogtmL.js");
|
|
6
|
-
const require_AuthContext = require("./AuthContext.
|
|
6
|
+
const require_AuthContext = require("./AuthContext.7b-sPPn_.js");
|
|
7
7
|
const require_remoteDataProvider = require("./remoteDataProvider.BOdk5HJ0.js");
|
|
8
8
|
let react = require("react");
|
|
9
9
|
react = require_Loading.__toESM(react, 1);
|
|
10
10
|
let react_admin = require("react-admin");
|
|
11
|
-
let _mui_material = require("@mui/material");
|
|
12
11
|
let react_router = require("react-router");
|
|
12
|
+
let _mui_material = require("@mui/material");
|
|
13
13
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
14
14
|
let _mui_icons_material_ArrowDropDown = require("@mui/icons-material/ArrowDropDown");
|
|
15
15
|
_mui_icons_material_ArrowDropDown = require_Loading.__toESM(_mui_icons_material_ArrowDropDown, 1);
|
|
@@ -36,7 +36,6 @@ var AppBarOrganization = () => {
|
|
|
36
36
|
const isHidden = require_utils.useIsHideSidebar();
|
|
37
37
|
const redirect = (0, react_admin.useRedirect)();
|
|
38
38
|
const [did, setDid] = require_selectedOrganizationState.useSelectedOrganization();
|
|
39
|
-
const auth = require_AuthContext.useAuth();
|
|
40
39
|
const logout = (0, react_admin.useLogout)();
|
|
41
40
|
const { data: allOrganizations, isLoading } = (0, react_admin.useGetList)("organizations", void 0, {
|
|
42
41
|
onSuccess: ({ data }) => {
|
|
@@ -63,7 +62,7 @@ var AppBarOrganization = () => {
|
|
|
63
62
|
};
|
|
64
63
|
const handleLogoutClick = () => {
|
|
65
64
|
setAnchorEl(null);
|
|
66
|
-
logout(
|
|
65
|
+
logout({ source: "app-bar-organization" }, "/", false);
|
|
67
66
|
};
|
|
68
67
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_mui_material.Stack, {
|
|
69
68
|
sx: sx.root,
|
|
@@ -318,4 +317,4 @@ Object.defineProperty(exports, "CustomAppBar", {
|
|
|
318
317
|
}
|
|
319
318
|
});
|
|
320
319
|
|
|
321
|
-
//# sourceMappingURL=CustomAppBar.
|
|
320
|
+
//# sourceMappingURL=CustomAppBar.DFiez_ky.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomAppBar.DFiez_ky.js","names":["useAuth","useSelectedOrganization","dataResources"],"sources":["../../src/components/AppBar/AppBarOrganization.jsx","../../src/components/AppBar/hooks/useCheckUserHasGroup.js","../../src/components/AppBar/CustomAppBar.jsx"],"sourcesContent":["/**\n * Copyright 2023 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { useLogout, useRedirect, useGetList } from 'react-admin';\nimport {\n Box,\n Button,\n List,\n ListItem,\n ListItemButton,\n Popover,\n Stack,\n Typography,\n} from '@mui/material';\nimport ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';\nimport AddIcon from '@mui/icons-material/Add';\nimport OrganizationAvatar from '../common/OrganizationAvatar.jsx';\nimport useSelectedOrganization from '../../state/selectedOrganizationState.js';\nimport { useIsHideSidebar } from '../../utils/index.jsx';\nimport useCountryCodes from '../../utils/countryCodes.js';\nimport Loading from '../Loading.jsx';\n\n// eslint-disable-next-line complexity\nconst AppBarOrganization = () => {\n const { getCountryNameByCode } = useCountryCodes();\n const isHidden = useIsHideSidebar();\n const redirect = useRedirect();\n const [did, setDid] = useSelectedOrganization();\n const logout = useLogout();\n\n const { data: allOrganizations, isLoading } = useGetList('organizations', undefined, {\n onSuccess: ({ data }) => {\n if (!data) {\n return;\n }\n\n if (data.find((item) => item.id === did)) {\n return;\n }\n\n setDid(data[0].id);\n },\n onError: () => redirect('/'),\n });\n\n const [anchorEl, setAnchorEl] = React.useState(null);\n\n const organization = React.useMemo(\n () => (allOrganizations || []).find((item) => item.id === did),\n [did, allOrganizations],\n );\n\n if (isLoading) {\n return (\n <Box>\n <Loading />\n </Box>\n );\n }\n\n if (!did || !allOrganizations || isHidden || !organization) {\n return null;\n }\n\n const isOpen = Boolean(anchorEl);\n const id = isOpen ? 'user-menu' : undefined;\n\n const handleSelectOrganization = (value) => {\n setDid(value);\n setAnchorEl(null);\n redirect('show', 'organizations', value);\n };\n\n const handleAddNewClick = () => {\n setAnchorEl(null);\n redirect('create', 'organizations');\n };\n\n const handleLogoutClick = () => {\n setAnchorEl(null);\n logout({ source: 'app-bar-organization' }, '/', false);\n };\n\n return (\n <>\n <Stack\n sx={sx.root}\n role=\"button\"\n aria-describedby={id}\n onClick={(e) => setAnchorEl(e.currentTarget)}\n data-testid=\"app-bar-org\"\n >\n <OrganizationAvatar\n size={36}\n name={organization.profile.name}\n logo={organization.profile.logo}\n />\n <Box>\n <Typography variant=\"pl\" component=\"div\" fontWeight={600}>\n {organization.profile.name}\n </Typography>\n <Typography variant=\"ps\" mt={0.25}>\n {getCountryNameByCode(organization.profile.location.countryCode)}\n </Typography>\n </Box>\n <ArrowDropDownIcon />\n </Stack>\n <Popover\n id={id}\n open={isOpen}\n anchorEl={anchorEl}\n onClose={() => setAnchorEl(null)}\n componentsProps={{\n backdrop: {\n invisible: true,\n },\n }}\n anchorOrigin={{\n vertical: 'bottom',\n horizontal: 'right',\n }}\n transformOrigin={{\n vertical: 'top',\n horizontal: 'right',\n }}\n >\n <Stack sx={sx.popup} alignItems=\"center\">\n <OrganizationAvatar\n size={56}\n name={organization.profile.name}\n logo={organization.profile.logo}\n />\n <Typography mt={2} variant=\"h5\">\n {organization.profile.name}\n </Typography>\n <Typography mt={2} variant=\"pm\" fontWeight=\"600\" sx={sx.did}>\n {did}\n </Typography>\n <Typography variant=\"ps\" mt={1} mb={3}>\n {getCountryNameByCode(organization.profile.location.countryCode)}\n </Typography>\n <List sx={sx.list}>\n {allOrganizations\n .filter((item) => item.id !== did)\n .map((item) => (\n <ListItem key={item.id} sx={sx.listItem} disablePadding>\n <ListItemButton\n sx={sx.listItemButton}\n onClick={() => handleSelectOrganization(item.id)}\n >\n <OrganizationAvatar\n size={26}\n name={item.profile.name}\n logo={item.profile.logo}\n />\n <Typography variant=\"pm\" fontWeight={600}>\n {item.profile.name}\n </Typography>\n </ListItemButton>\n </ListItem>\n ))}\n <ListItem key=\"'add-new'\" sx={sx.listItem} disablePadding>\n <ListItemButton sx={sx.listItemButton} onClick={handleAddNewClick}>\n <Box sx={sx.plusIcon}>\n <AddIcon />\n </Box>\n <Typography variant=\"pm\" fontWeight={600} fontSize={12}>\n ADD ORGANIZATION\n </Typography>\n </ListItemButton>\n </ListItem>\n </List>\n <Button\n sx={sx.logout}\n onClick={handleLogoutClick}\n variant=\"outlined\"\n color=\"secondary\"\n size=\"small\"\n >\n LOG OUT\n </Button>\n\n <Button sx={sx.changePassword} variant=\"text\" color=\"secondary\" size=\"small\">\n Change password\n </Button>\n </Stack>\n </Popover>\n </>\n );\n};\n\nexport default AppBarOrganization;\n\nconst sx = {\n root: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 1.5,\n cursor: 'pointer',\n py: 1.25,\n },\n popup: {\n minWidth: 368,\n py: 4,\n },\n list: {\n alignSelf: 'stretch',\n },\n listItem: {\n borderTop: (theme) => `1px solid ${theme.palette.divider.main}`,\n },\n listItemButton: {\n gap: 2.5,\n px: 3.25,\n py: 1.5,\n },\n plusIcon: {\n padding: 0.625,\n display: 'flex',\n },\n logout: {\n mt: 1,\n minWidth: 176,\n },\n changePassword: {\n mt: 2,\n },\n did: {\n wordBreak: 'break-word',\n px: '10px',\n },\n};\n","import { useEffect, useState } from 'react';\nimport { useGetOne, useRedirect } from 'react-admin';\nimport { useAuth } from '@/utils/auth/AuthContext.js';\nimport { dataResources } from '@/utils/remoteDataProvider.js';\nimport useSelectedOrganization from '@/state/selectedOrganizationState.js';\n\nexport const useCheckUserHasGroup = () => {\n const { user, getAccessTokenWithPopup } = useAuth();\n const redirect = useRedirect();\n const [, setDid] = useSelectedOrganization();\n const {\n data: userData,\n isLoading: isUserDataLoading,\n isError,\n } = useGetOne(dataResources.USERS, {\n id: user.sub,\n });\n const [isLoading, setIsLoading] = useState(false);\n const [hasOrganisations, setHasOrganisations] = useState(false);\n\n useEffect(() => {\n const checkUserGroup = async () => {\n setIsLoading(true);\n try {\n const userHasGroup = !!userData?.groupId;\n if (userHasGroup) {\n setHasOrganisations(true);\n return;\n }\n\n setDid('');\n if (!/organizations\\/create/.test(window.location.pathname)) {\n redirect('create', 'organizations', undefined, undefined, { userHasGroup });\n }\n } catch (e) {\n if (e.error === 'consent_required') {\n await getAccessTokenWithPopup();\n }\n throw e;\n } finally {\n setIsLoading(false);\n }\n };\n if (!isUserDataLoading && (userData || isError)) {\n checkUserGroup();\n }\n }, [\n getAccessTokenWithPopup,\n redirect,\n setDid,\n setIsLoading,\n userData?.groupId,\n isUserDataLoading,\n userData,\n isError,\n ]);\n\n return {\n isLoading,\n hasOrganisations,\n };\n};\n","/**\n * Copyright 2023 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Link } from 'react-router';\nimport { AppBar, Box, Toolbar } from '@mui/material';\nimport AppBarOrganization from './AppBarOrganization.jsx';\nimport { useCheckUserHasGroup } from './hooks/useCheckUserHasGroup.js';\n\nconst CustomAppBar = (props) => {\n const { hasOrganisations, isLoading } = useCheckUserHasGroup();\n const isLogoDisabled = isLoading || !hasOrganisations;\n\n return (\n <AppBar {...props} elevation={0}>\n <Toolbar>\n <Link\n to={isLogoDisabled ? undefined : '/'}\n style={{ display: 'flex', ...(isLogoDisabled ? { pointerEvents: 'none' } : {}) }}\n aria-disabled={isLogoDisabled}\n disabled={isLogoDisabled}\n role=\"link\"\n >\n <img src=\"/assets/images/logo.svg\" alt=\"Velocity\" />\n </Link>\n <Box flex={1} />\n {hasOrganisations && <AppBarOrganization />}\n </Toolbar>\n </AppBar>\n );\n};\n\nexport default CustomAppBar;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,IAAM,2BAA2B;CAC/B,MAAM,EA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