@entur-partner/app-shell 6.1.5 → 6.1.6-alpha.0
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/dist/AppShell.d.ts +6 -6
- package/dist/ConsentManagerProvider.d.ts +2 -2
- package/dist/EnvironmentBanner.d.ts +2 -2
- package/dist/LanguageProvider.d.ts +1 -1
- package/dist/MenuProvider.d.ts +2 -2
- package/dist/MicroFrontendLink.d.ts +1 -1
- package/dist/OrganisationProvider.d.ts +1 -1
- package/dist/OrganisationSelector.d.ts +3 -3
- package/dist/PostHogProviderWrapper.d.ts +1 -1
- package/dist/app-shell.cjs.development.js +220 -214
- package/dist/app-shell.cjs.development.js.map +1 -1
- package/dist/app-shell.cjs.production.min.js +1 -1
- package/dist/app-shell.cjs.production.min.js.map +1 -1
- package/dist/app-shell.esm.js +222 -216
- package/dist/app-shell.esm.js.map +1 -1
- package/dist/index.d.ts +12 -12
- package/dist/types/ConsentTypes.d.ts +1 -1
- package/dist/types/UserTypes.d.ts +2 -2
- package/dist/util/convertUCServicesToConsents.d.ts +1 -1
- package/package.json +53 -54
package/dist/AppShell.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { User } from
|
|
4
|
-
import {
|
|
5
|
-
import { DecorateUserFn } from
|
|
1
|
+
import { type Auth0ContextInterface, type GetTokenSilentlyOptions } from "@auth0/auth0-react";
|
|
2
|
+
import { Environment } from "@entur-partner/common";
|
|
3
|
+
import type { User } from "@entur-partner/micro-frontend";
|
|
4
|
+
import React, { type ReactNode } from "react";
|
|
5
|
+
import type { DecorateUserFn } from "./types/UserTypes";
|
|
6
6
|
export interface AppShellValues {
|
|
7
|
-
logout: Auth0ContextInterface[
|
|
7
|
+
logout: Auth0ContextInterface["logout"];
|
|
8
8
|
user: User;
|
|
9
9
|
getToken(options?: GetTokenSilentlyOptions): Promise<string>;
|
|
10
10
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { type Environment } from "@entur-partner/common";
|
|
2
|
+
import React from "react";
|
|
3
3
|
type EnvironmentBannerProps = {
|
|
4
4
|
environment: Exclude<Environment, Environment.Production>;
|
|
5
5
|
};
|
package/dist/MenuProvider.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import type { MenuItem, NavigationFunction } from "@entur-partner/micro-frontend";
|
|
2
|
+
import React, { type FC, type ReactNode } from "react";
|
|
3
3
|
interface MenuContextType {
|
|
4
4
|
getItemsForPath: (path: string) => MenuItem[];
|
|
5
5
|
addItems: (items: MenuItem[], path: string) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { GetTokenSilentlyOptions } from "@auth0/auth0-spa-js";
|
|
2
|
+
import { type FC } from "react";
|
|
3
3
|
export type GetOrganisationsFn = (token: string) => Promise<OrganisationV3[]>;
|
|
4
4
|
export interface OrganisationV3 {
|
|
5
5
|
organisationId: number;
|
|
@@ -10,6 +10,6 @@ export interface OrganisationSelectorProps {
|
|
|
10
10
|
getOrganisations: GetOrganisationsFn | string;
|
|
11
11
|
selectedOrganisationId: number;
|
|
12
12
|
onChange: (organisationId: number) => void;
|
|
13
|
-
[key: string]:
|
|
13
|
+
[key: string]: object | string | number | boolean;
|
|
14
14
|
}
|
|
15
15
|
export declare const OrganisationSelector: FC<OrganisationSelectorProps>;
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var auth0React = require('@auth0/auth0-react');
|
|
6
6
|
var alert = require('@entur/alert');
|
|
7
|
-
var typography = require('@entur/typography');
|
|
8
7
|
var loader = require('@entur/loader');
|
|
9
8
|
var tokens = require('@entur/tokens');
|
|
10
|
-
var
|
|
9
|
+
var typography = require('@entur/typography');
|
|
11
10
|
var common = require('@entur-partner/common');
|
|
12
11
|
var util = require('@entur-partner/util');
|
|
12
|
+
var React = require('react');
|
|
13
13
|
var postHog = require('posthog-js');
|
|
14
14
|
var react = require('posthog-js/react');
|
|
15
15
|
|
|
@@ -447,13 +447,13 @@ var EnvironmentBanner = function EnvironmentBanner(_ref) {
|
|
|
447
447
|
return React__default["default"].createElement("div", {
|
|
448
448
|
className: "epp-environment-banner",
|
|
449
449
|
style: {
|
|
450
|
-
position:
|
|
450
|
+
position: "fixed",
|
|
451
451
|
zIndex: 9999,
|
|
452
452
|
top: 0,
|
|
453
453
|
left: 0,
|
|
454
454
|
right: 0,
|
|
455
|
-
width:
|
|
456
|
-
height:
|
|
455
|
+
width: "100vw",
|
|
456
|
+
height: "16px",
|
|
457
457
|
backgroundColor: common.getColorForEnvironment(environment)
|
|
458
458
|
}
|
|
459
459
|
});
|
|
@@ -506,7 +506,7 @@ var Authenticate = function Authenticate(_ref) {
|
|
|
506
506
|
case 10:
|
|
507
507
|
_context.prev = 10;
|
|
508
508
|
_context.t0 = _context["catch"](0);
|
|
509
|
-
console.error(
|
|
509
|
+
console.error("Error fetching user data:", _context.t0);
|
|
510
510
|
case 13:
|
|
511
511
|
case "end":
|
|
512
512
|
return _context.stop();
|
|
@@ -542,10 +542,10 @@ var Authenticate = function Authenticate(_ref) {
|
|
|
542
542
|
variant: "error",
|
|
543
543
|
title: "Authentication failed",
|
|
544
544
|
style: {
|
|
545
|
-
maxWidth:
|
|
546
|
-
margin:
|
|
545
|
+
maxWidth: "600px",
|
|
546
|
+
margin: "0 auto"
|
|
547
547
|
}
|
|
548
|
-
}, React__default["default"].createElement(typography.Paragraph, null, "Something went wrong while trying to authenticate you. If the problem persists you should contact",
|
|
548
|
+
}, React__default["default"].createElement(typography.Paragraph, null, "Something went wrong while trying to authenticate you. If the problem persists you should contact", " ", React__default["default"].createElement(typography.Link, {
|
|
549
549
|
href: "mailto:support@entur.org"
|
|
550
550
|
}, "support@entur.org"), " to get it resolved."), React__default["default"].createElement(typography.Paragraph, null, "Authentication failed with: ", React__default["default"].createElement(typography.CodeText, null, error == null ? void 0 : error.toString())));
|
|
551
551
|
}
|
|
@@ -581,38 +581,164 @@ var AppShell = function AppShell(_ref3) {
|
|
|
581
581
|
}));
|
|
582
582
|
};
|
|
583
583
|
|
|
584
|
-
var
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
584
|
+
var ORGANISATION_STORAGE_KEY = "EP::activeOrgId";
|
|
585
|
+
var organisationStorage = {
|
|
586
|
+
get: function get() {
|
|
587
|
+
return localStorage.getItem(ORGANISATION_STORAGE_KEY);
|
|
588
|
+
},
|
|
589
|
+
set: function set(value) {
|
|
590
|
+
return localStorage.setItem(ORGANISATION_STORAGE_KEY, value);
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
var LANGUAGE_STORAGE_KEY = "EP::locale";
|
|
594
|
+
var languageStorage = {
|
|
595
|
+
get: function get() {
|
|
596
|
+
return localStorage.getItem(LANGUAGE_STORAGE_KEY);
|
|
597
|
+
},
|
|
598
|
+
set: function set(value) {
|
|
599
|
+
return localStorage.setItem(LANGUAGE_STORAGE_KEY, value);
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
var UC_UI_STORAGE_KEY = "ucData";
|
|
603
|
+
var ucUiStorage = {
|
|
604
|
+
get: function get() {
|
|
605
|
+
return localStorage.getItem(UC_UI_STORAGE_KEY);
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
var SERVICE_NAMES = {
|
|
610
|
+
Usercentrics: "Usercentrics Consent Management Platform",
|
|
611
|
+
PostHog: "PostHog.com",
|
|
612
|
+
Sentry: "Sentry"
|
|
613
|
+
};
|
|
614
|
+
|
|
615
|
+
var DEFAULT_CONSENT_GIVEN = {
|
|
616
|
+
Usercentrics: {
|
|
617
|
+
consentGiven: false
|
|
618
|
+
},
|
|
619
|
+
PostHog: {
|
|
620
|
+
consentGiven: false
|
|
621
|
+
},
|
|
622
|
+
Sentry: {
|
|
623
|
+
consentGiven: false
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
var convertUCServicesToConsents = function convertUCServicesToConsents(services) {
|
|
627
|
+
return services.map(function (service) {
|
|
628
|
+
var _Object$entries$find, _ref3;
|
|
629
|
+
var serviceName = (_Object$entries$find = Object.entries(SERVICE_NAMES).find(function (keyValue) {
|
|
630
|
+
return keyValue[1] === service.name;
|
|
631
|
+
})) == null ? void 0 : _Object$entries$find[0];
|
|
632
|
+
// Ensure the service name exists in SERVICE_NAMES
|
|
633
|
+
util.assertIsDefined(serviceName, "Service name " + service.name + " not found in SERVICE_NAMES");
|
|
634
|
+
if (typeof service.consent === "boolean") {
|
|
635
|
+
var _ref;
|
|
636
|
+
var consentGiven = service.consent;
|
|
637
|
+
return _ref = {}, _ref[serviceName] = {
|
|
638
|
+
consentGiven: consentGiven
|
|
639
|
+
}, _ref;
|
|
640
|
+
} else if (typeof service.consent === "object" && "given" in service.consent) {
|
|
641
|
+
var _ref2;
|
|
642
|
+
var _consentGiven = service.consent.given;
|
|
643
|
+
return _ref2 = {}, _ref2[serviceName] = {
|
|
644
|
+
consentGiven: _consentGiven
|
|
645
|
+
}, _ref2;
|
|
646
|
+
}
|
|
647
|
+
return _ref3 = {}, _ref3[serviceName] = {
|
|
648
|
+
consentGiven: false
|
|
649
|
+
}, _ref3;
|
|
650
|
+
}).reduce(
|
|
651
|
+
// biome-ignore lint/performance/noAccumulatingSpread: Ignore it for now. No changes in code.
|
|
652
|
+
function (acc, curr) {
|
|
653
|
+
return _extends({}, acc, curr);
|
|
654
|
+
}, DEFAULT_CONSENT_GIVEN);
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
var ConsentContext = /*#__PURE__*/React.createContext(DEFAULT_CONSENT_GIVEN);
|
|
658
|
+
var useConsentManager = function useConsentManager() {
|
|
659
|
+
var context = React.useContext(ConsentContext);
|
|
660
|
+
return context;
|
|
661
|
+
};
|
|
662
|
+
var ConsentManagerProvider = function ConsentManagerProvider(_ref) {
|
|
663
|
+
var children = _ref.children;
|
|
664
|
+
var _useState = React.useState(DEFAULT_CONSENT_GIVEN),
|
|
665
|
+
consentManager = _useState[0],
|
|
666
|
+
setConsentManager = _useState[1];
|
|
667
|
+
// Initialize consent manager from local storage once
|
|
668
|
+
React.useEffect(function () {
|
|
669
|
+
if (typeof window === "undefined") return;
|
|
670
|
+
var ucData = ucUiStorage.get();
|
|
671
|
+
if (ucData) {
|
|
672
|
+
var data = JSON.parse(ucData);
|
|
673
|
+
var services = convertUCServicesToConsents(Object.values(data.consent.services));
|
|
674
|
+
setConsentManager(services);
|
|
675
|
+
}
|
|
676
|
+
}, []);
|
|
677
|
+
// Listen for Usercentrics consent events and update consent manager state
|
|
678
|
+
React.useEffect(function () {
|
|
679
|
+
var handleConsentEvent = /*#__PURE__*/function () {
|
|
680
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
|
|
681
|
+
var customEvent, services, updatedConsentManager;
|
|
682
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
683
|
+
while (1) switch (_context.prev = _context.next) {
|
|
684
|
+
case 0:
|
|
685
|
+
if (!(typeof window === "undefined")) {
|
|
686
|
+
_context.next = 2;
|
|
687
|
+
break;
|
|
688
|
+
}
|
|
689
|
+
return _context.abrupt("return");
|
|
690
|
+
case 2:
|
|
691
|
+
customEvent = event;
|
|
692
|
+
services = Object.values(customEvent.detail.services);
|
|
693
|
+
updatedConsentManager = convertUCServicesToConsents(services);
|
|
694
|
+
setConsentManager(updatedConsentManager);
|
|
695
|
+
case 6:
|
|
696
|
+
case "end":
|
|
697
|
+
return _context.stop();
|
|
698
|
+
}
|
|
699
|
+
}, _callee);
|
|
700
|
+
}));
|
|
701
|
+
return function handleConsentEvent(_x) {
|
|
702
|
+
return _ref2.apply(this, arguments);
|
|
703
|
+
};
|
|
704
|
+
}();
|
|
705
|
+
window.addEventListener("UC_CONSENT", handleConsentEvent);
|
|
706
|
+
return function () {
|
|
707
|
+
return window.removeEventListener("UC_CONSENT", handleConsentEvent);
|
|
708
|
+
};
|
|
709
|
+
}, []);
|
|
710
|
+
return React__default["default"].createElement(ConsentContext.Provider, {
|
|
711
|
+
value: consentManager
|
|
712
|
+
}, children);
|
|
713
|
+
};
|
|
714
|
+
|
|
715
|
+
var LanguageContext = /*#__PURE__*/React__default["default"].createContext(undefined);
|
|
716
|
+
var useLanguageState = function useLanguageState(language) {
|
|
717
|
+
var _useState = React.useState(language),
|
|
718
|
+
activeLanguage = _useState[0],
|
|
719
|
+
setLanguage = _useState[1];
|
|
720
|
+
React.useEffect(function () {
|
|
721
|
+
languageStorage.set(activeLanguage);
|
|
722
|
+
}, [activeLanguage]);
|
|
723
|
+
return [activeLanguage, setLanguage];
|
|
724
|
+
};
|
|
725
|
+
var useLanguage = function useLanguage() {
|
|
726
|
+
var context = React.useContext(LanguageContext);
|
|
727
|
+
util.assertIsDefined(context);
|
|
728
|
+
return context;
|
|
729
|
+
};
|
|
730
|
+
var LanguageProvider = function LanguageProvider(_ref) {
|
|
731
|
+
var children = _ref.children,
|
|
732
|
+
language = _ref.language;
|
|
733
|
+
var _useLanguageState = useLanguageState(language),
|
|
734
|
+
activeLanguage = _useLanguageState[0],
|
|
735
|
+
setLanguage = _useLanguageState[1];
|
|
736
|
+
return React__default["default"].createElement(LanguageContext.Provider, {
|
|
737
|
+
value: {
|
|
738
|
+
language: activeLanguage,
|
|
739
|
+
setLanguage: setLanguage
|
|
740
|
+
}
|
|
741
|
+
}, children);
|
|
616
742
|
};
|
|
617
743
|
|
|
618
744
|
var MenuContext = /*#__PURE__*/React__default["default"].createContext({
|
|
@@ -650,7 +776,7 @@ var MenuProvider = function MenuProvider(_ref) {
|
|
|
650
776
|
var _extends2;
|
|
651
777
|
return _extends({}, prevState, (_extends2 = {}, _extends2[path] = newItems, _extends2));
|
|
652
778
|
});
|
|
653
|
-
}, [
|
|
779
|
+
}, []);
|
|
654
780
|
var getMFNavigate = function getMFNavigate(path) {
|
|
655
781
|
return navFuncs[path];
|
|
656
782
|
};
|
|
@@ -673,29 +799,42 @@ var MenuProvider = function MenuProvider(_ref) {
|
|
|
673
799
|
}, children);
|
|
674
800
|
};
|
|
675
801
|
|
|
676
|
-
var
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
802
|
+
var _excluded$1 = ["navigate", "children", "onClick", "target"];
|
|
803
|
+
function isModifiedEvent(event) {
|
|
804
|
+
return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
|
|
805
|
+
}
|
|
806
|
+
var MicroFrontendLink = function MicroFrontendLink(_ref) {
|
|
807
|
+
var navigate = _ref.navigate,
|
|
808
|
+
children = _ref.children,
|
|
809
|
+
_onClick = _ref.onClick,
|
|
810
|
+
target = _ref.target,
|
|
811
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
812
|
+
return (
|
|
813
|
+
// biome-ignore lint/a11y/noStaticElementInteractions: Ignore lint rule for now. No changes in code.
|
|
814
|
+
React__default["default"].createElement("a", _extends({
|
|
815
|
+
// biome-ignore lint/a11y/useValidAnchor: Ignore lint rule for now. No changes in code.
|
|
816
|
+
onClick: function onClick(event) {
|
|
817
|
+
try {
|
|
818
|
+
if (_onClick) _onClick(event);
|
|
819
|
+
} catch (ex) {
|
|
820
|
+
event.preventDefault();
|
|
821
|
+
throw ex;
|
|
822
|
+
}
|
|
823
|
+
if (!event.defaultPrevented &&
|
|
824
|
+
// onClick prevented default
|
|
825
|
+
event.button === 0 && (
|
|
826
|
+
// ignore everything but right clicks
|
|
827
|
+
!target || target === "_self") &&
|
|
828
|
+
// let browser handle "target=_blank" etc.
|
|
829
|
+
!isModifiedEvent(event) // ignore clicks with modifier keys
|
|
830
|
+
) {
|
|
831
|
+
event.preventDefault();
|
|
832
|
+
navigate();
|
|
833
|
+
}
|
|
834
|
+
},
|
|
835
|
+
target: target
|
|
836
|
+
}, rest), children)
|
|
837
|
+
);
|
|
699
838
|
};
|
|
700
839
|
|
|
701
840
|
var OrganisationContext = /*#__PURE__*/React__default["default"].createContext(undefined);
|
|
@@ -732,35 +871,6 @@ var OrganisationProvider = function OrganisationProvider(_ref) {
|
|
|
732
871
|
}, children);
|
|
733
872
|
};
|
|
734
873
|
|
|
735
|
-
var LanguageContext = /*#__PURE__*/React__default["default"].createContext(undefined);
|
|
736
|
-
var useLanguageState = function useLanguageState(language) {
|
|
737
|
-
var _useState = React.useState(language),
|
|
738
|
-
activeLanguage = _useState[0],
|
|
739
|
-
setLanguage = _useState[1];
|
|
740
|
-
React.useEffect(function () {
|
|
741
|
-
languageStorage.set(activeLanguage);
|
|
742
|
-
}, [activeLanguage]);
|
|
743
|
-
return [activeLanguage, setLanguage];
|
|
744
|
-
};
|
|
745
|
-
var useLanguage = function useLanguage() {
|
|
746
|
-
var context = React.useContext(LanguageContext);
|
|
747
|
-
util.assertIsDefined(context);
|
|
748
|
-
return context;
|
|
749
|
-
};
|
|
750
|
-
var LanguageProvider = function LanguageProvider(_ref) {
|
|
751
|
-
var children = _ref.children,
|
|
752
|
-
language = _ref.language;
|
|
753
|
-
var _useLanguageState = useLanguageState(language),
|
|
754
|
-
activeLanguage = _useLanguageState[0],
|
|
755
|
-
setLanguage = _useLanguageState[1];
|
|
756
|
-
return React__default["default"].createElement(LanguageContext.Provider, {
|
|
757
|
-
value: {
|
|
758
|
-
language: activeLanguage,
|
|
759
|
-
setLanguage: setLanguage
|
|
760
|
-
}
|
|
761
|
-
}, children);
|
|
762
|
-
};
|
|
763
|
-
|
|
764
874
|
var OrganisationsError = /*#__PURE__*/function (_Error) {
|
|
765
875
|
function OrganisationsError() {
|
|
766
876
|
var _this;
|
|
@@ -768,7 +878,7 @@ var OrganisationsError = /*#__PURE__*/function (_Error) {
|
|
|
768
878
|
args[_key] = arguments[_key];
|
|
769
879
|
}
|
|
770
880
|
_this = _Error.call.apply(_Error, [this].concat(args)) || this;
|
|
771
|
-
_this.message =
|
|
881
|
+
_this.message = "Failed fetching organisations";
|
|
772
882
|
return _this;
|
|
773
883
|
}
|
|
774
884
|
_inheritsLoose(OrganisationsError, _Error);
|
|
@@ -787,7 +897,7 @@ var OrganisationSelector = function OrganisationSelector(_ref) {
|
|
|
787
897
|
setOrganisations = _useState[1];
|
|
788
898
|
var _useLanguage = useLanguage(),
|
|
789
899
|
language = _useLanguage.language;
|
|
790
|
-
var _useState2 = React.useState(
|
|
900
|
+
var _useState2 = React.useState("LOADING"),
|
|
791
901
|
status = _useState2[0],
|
|
792
902
|
setStatus = _useState2[1];
|
|
793
903
|
React.useEffect(function () {
|
|
@@ -801,7 +911,7 @@ var OrganisationSelector = function OrganisationSelector(_ref) {
|
|
|
801
911
|
return getToken();
|
|
802
912
|
case 2:
|
|
803
913
|
token = _context.sent;
|
|
804
|
-
if (!(typeof getOrganisations ===
|
|
914
|
+
if (!(typeof getOrganisations === "string")) {
|
|
805
915
|
_context.next = 9;
|
|
806
916
|
break;
|
|
807
917
|
}
|
|
@@ -809,7 +919,7 @@ var OrganisationSelector = function OrganisationSelector(_ref) {
|
|
|
809
919
|
return fetch(getOrganisations, {
|
|
810
920
|
headers: {
|
|
811
921
|
Authorization: "Bearer " + token,
|
|
812
|
-
Accept:
|
|
922
|
+
Accept: "application/json"
|
|
813
923
|
}
|
|
814
924
|
}).then(function (response) {
|
|
815
925
|
return response.json();
|
|
@@ -825,7 +935,7 @@ var OrganisationSelector = function OrganisationSelector(_ref) {
|
|
|
825
935
|
organisations = _context.sent;
|
|
826
936
|
case 12:
|
|
827
937
|
setOrganisations(organisations);
|
|
828
|
-
setStatus(
|
|
938
|
+
setStatus("SUCCESS");
|
|
829
939
|
case 14:
|
|
830
940
|
case "end":
|
|
831
941
|
return _context.stop();
|
|
@@ -840,136 +950,32 @@ var OrganisationSelector = function OrganisationSelector(_ref) {
|
|
|
840
950
|
{
|
|
841
951
|
console.error(error);
|
|
842
952
|
}
|
|
843
|
-
setStatus(
|
|
953
|
+
setStatus("ERROR");
|
|
844
954
|
});
|
|
845
955
|
}, [getOrganisations, getToken]);
|
|
846
956
|
switch (status) {
|
|
847
|
-
case
|
|
957
|
+
case "LOADING":
|
|
848
958
|
return React__default["default"].createElement("div", {
|
|
849
959
|
className: "eds-contrast"
|
|
850
960
|
}, React__default["default"].createElement(loader.SkeletonRectangle, {
|
|
851
961
|
style: {
|
|
852
|
-
height:
|
|
962
|
+
height: "2.4rem"
|
|
853
963
|
}
|
|
854
964
|
}));
|
|
855
|
-
case
|
|
965
|
+
case "SUCCESS":
|
|
856
966
|
return React__default["default"].createElement(common.OrganisationDropDown, _extends({
|
|
857
|
-
label: language ===
|
|
967
|
+
label: language === "nb" || language === "nb-NO" ? "Organisasjon" : "Organisation",
|
|
858
968
|
selectedOrganisationId: selectedOrganisationId,
|
|
859
969
|
organisations: organisations,
|
|
860
970
|
onChange: onChange
|
|
861
971
|
}, rest));
|
|
862
|
-
case
|
|
972
|
+
case "ERROR":
|
|
863
973
|
throw new OrganisationsError();
|
|
864
974
|
default:
|
|
865
975
|
return null;
|
|
866
976
|
}
|
|
867
977
|
};
|
|
868
978
|
|
|
869
|
-
var SERVICE_NAMES = {
|
|
870
|
-
Usercentrics: 'Usercentrics Consent Management Platform',
|
|
871
|
-
PostHog: 'PostHog.com',
|
|
872
|
-
Sentry: 'Sentry'
|
|
873
|
-
};
|
|
874
|
-
|
|
875
|
-
var DEFAULT_CONSENT_GIVEN = {
|
|
876
|
-
Usercentrics: {
|
|
877
|
-
consentGiven: false
|
|
878
|
-
},
|
|
879
|
-
PostHog: {
|
|
880
|
-
consentGiven: false
|
|
881
|
-
},
|
|
882
|
-
Sentry: {
|
|
883
|
-
consentGiven: false
|
|
884
|
-
}
|
|
885
|
-
};
|
|
886
|
-
var convertUCServicesToConsents = function convertUCServicesToConsents(services) {
|
|
887
|
-
return services.map(function (service) {
|
|
888
|
-
var _Object$entries$find, _ref3;
|
|
889
|
-
var serviceName = (_Object$entries$find = Object.entries(SERVICE_NAMES).find(function (keyValue) {
|
|
890
|
-
return keyValue[1] === service.name;
|
|
891
|
-
})) == null ? void 0 : _Object$entries$find[0];
|
|
892
|
-
// Ensure the service name exists in SERVICE_NAMES
|
|
893
|
-
util.assertIsDefined(serviceName, "Service name " + service.name + " not found in SERVICE_NAMES");
|
|
894
|
-
if (typeof service.consent == 'boolean') {
|
|
895
|
-
var _ref;
|
|
896
|
-
var consentGiven = service.consent;
|
|
897
|
-
return _ref = {}, _ref[serviceName] = {
|
|
898
|
-
consentGiven: consentGiven
|
|
899
|
-
}, _ref;
|
|
900
|
-
} else if (typeof service.consent === 'object' && 'given' in service.consent) {
|
|
901
|
-
var _ref2;
|
|
902
|
-
var _consentGiven = service.consent.given;
|
|
903
|
-
return _ref2 = {}, _ref2[serviceName] = {
|
|
904
|
-
consentGiven: _consentGiven
|
|
905
|
-
}, _ref2;
|
|
906
|
-
}
|
|
907
|
-
return _ref3 = {}, _ref3[serviceName] = {
|
|
908
|
-
consentGiven: false
|
|
909
|
-
}, _ref3;
|
|
910
|
-
}).reduce(function (acc, curr) {
|
|
911
|
-
return _extends({}, acc, curr);
|
|
912
|
-
}, DEFAULT_CONSENT_GIVEN);
|
|
913
|
-
};
|
|
914
|
-
|
|
915
|
-
var ConsentContext = /*#__PURE__*/React.createContext(DEFAULT_CONSENT_GIVEN);
|
|
916
|
-
var useConsentManager = function useConsentManager() {
|
|
917
|
-
var context = React.useContext(ConsentContext);
|
|
918
|
-
return context;
|
|
919
|
-
};
|
|
920
|
-
var ConsentManagerProvider = function ConsentManagerProvider(_ref) {
|
|
921
|
-
var children = _ref.children;
|
|
922
|
-
var _useState = React.useState(DEFAULT_CONSENT_GIVEN),
|
|
923
|
-
consentManager = _useState[0],
|
|
924
|
-
setConsentManager = _useState[1];
|
|
925
|
-
// Initialize consent manager from local storage once
|
|
926
|
-
React.useEffect(function () {
|
|
927
|
-
if (typeof window === 'undefined') return;
|
|
928
|
-
var ucData = ucUiStorage.get();
|
|
929
|
-
if (ucData) {
|
|
930
|
-
var data = JSON.parse(ucData);
|
|
931
|
-
var services = convertUCServicesToConsents(Object.values(data.consent.services));
|
|
932
|
-
setConsentManager(services);
|
|
933
|
-
}
|
|
934
|
-
}, []);
|
|
935
|
-
// Listen for Usercentrics consent events and update consent manager state
|
|
936
|
-
React.useEffect(function () {
|
|
937
|
-
var handleConsentEvent = /*#__PURE__*/function () {
|
|
938
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
|
|
939
|
-
var customEvent, services, updatedConsentManager;
|
|
940
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
941
|
-
while (1) switch (_context.prev = _context.next) {
|
|
942
|
-
case 0:
|
|
943
|
-
if (!(typeof window === 'undefined')) {
|
|
944
|
-
_context.next = 2;
|
|
945
|
-
break;
|
|
946
|
-
}
|
|
947
|
-
return _context.abrupt("return");
|
|
948
|
-
case 2:
|
|
949
|
-
customEvent = event;
|
|
950
|
-
services = Object.values(customEvent.detail.services);
|
|
951
|
-
updatedConsentManager = convertUCServicesToConsents(services);
|
|
952
|
-
setConsentManager(updatedConsentManager);
|
|
953
|
-
case 6:
|
|
954
|
-
case "end":
|
|
955
|
-
return _context.stop();
|
|
956
|
-
}
|
|
957
|
-
}, _callee);
|
|
958
|
-
}));
|
|
959
|
-
return function handleConsentEvent(_x) {
|
|
960
|
-
return _ref2.apply(this, arguments);
|
|
961
|
-
};
|
|
962
|
-
}();
|
|
963
|
-
window.addEventListener('UC_CONSENT', handleConsentEvent);
|
|
964
|
-
return function () {
|
|
965
|
-
return window.removeEventListener('UC_CONSENT', handleConsentEvent);
|
|
966
|
-
};
|
|
967
|
-
}, []);
|
|
968
|
-
return React__default["default"].createElement(ConsentContext.Provider, {
|
|
969
|
-
value: consentManager
|
|
970
|
-
}, children);
|
|
971
|
-
};
|
|
972
|
-
|
|
973
979
|
var PostHogProviderWrapper = function PostHogProviderWrapper(_ref) {
|
|
974
980
|
var _ref$debug = _ref.debug,
|
|
975
981
|
debug = _ref$debug === void 0 ? false : _ref$debug,
|
|
@@ -993,16 +999,16 @@ var PostHogProviderWrapper = function PostHogProviderWrapper(_ref) {
|
|
|
993
999
|
// If no API key is provided or PostHog is forced to be disabled, do not initialize PostHog
|
|
994
1000
|
if (!postHogApiKey || forceDisablePostHog) {
|
|
995
1001
|
if (!forceDisablePostHog) {
|
|
996
|
-
console.warn(
|
|
1002
|
+
console.warn("AppShellStandalone Warning: PostHog API key is not provided. PostHog will not be initialized.");
|
|
997
1003
|
} else {
|
|
998
|
-
console.warn(
|
|
1004
|
+
console.warn("AppShellStandalone Warning: PostHog tracking is disabled by force. PostHog will not be initialized.");
|
|
999
1005
|
}
|
|
1000
1006
|
return React__default["default"].createElement(React__default["default"].Fragment, null, children);
|
|
1001
1007
|
}
|
|
1002
1008
|
postHog__default["default"].init(postHogApiKey, {
|
|
1003
1009
|
debug: debug,
|
|
1004
|
-
api_host: isStandalone ?
|
|
1005
|
-
ui_host:
|
|
1010
|
+
api_host: isStandalone ? "https://eu.posthog.com" : "/ingest",
|
|
1011
|
+
ui_host: "https://eu.posthog.com",
|
|
1006
1012
|
opt_out_capturing_by_default: true,
|
|
1007
1013
|
autocapture: isStandalone
|
|
1008
1014
|
}, project);
|