@undp/carbon-library 1.0.274-CARBON-347.0 → 1.0.274-CARBON-347.1

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.
@@ -3,6 +3,7 @@ import { ReactNode } from 'react';
3
3
  export type Methods = 'get' | 'post' | 'delete' | 'put' | 'patch';
4
4
  export type ConnectionContextProviderProps = {
5
5
  serverURL: string;
6
+ statServerUrl?: string;
6
7
  t: any;
7
8
  children: ReactNode;
8
9
  };
@@ -24,4 +25,5 @@ export type ConnectionProps = {
24
25
  updateToken: (token?: string) => void;
25
26
  token?: string;
26
27
  removeToken: (tkn?: string) => void;
28
+ statServerUrl?: string;
27
29
  };
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export default function DashboardI18nDecorator(Story: any, context: any): React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export default function InvestmentCreationI18nDecorator(Story: any, context: any): React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export default function ProgrammeCreateI18nDecorator(Story: any, context: any): React.JSX.Element;
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import type { StoryObj } from "@storybook/react";
3
+ import "antd/dist/antd.css";
4
+ import ConnectionContextDecorator from './Decorators/ConnectionContextDecorator';
5
+ declare const meta: {
6
+ title: string;
7
+ component: (props: any) => import("react").JSX.Element;
8
+ decorators: (typeof ConnectionContextDecorator)[];
9
+ };
10
+ export default meta;
11
+ type Story = StoryObj<typeof meta>;
12
+ export declare const Primary: Story;
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import type { StoryObj } from "@storybook/react";
3
+ import "antd/dist/antd.css";
4
+ import ConnectionContextDecorator from './Decorators/ConnectionContextDecorator';
5
+ declare const meta: {
6
+ title: string;
7
+ component: (props: any) => import("react").JSX.Element;
8
+ decorators: (typeof ConnectionContextDecorator)[];
9
+ };
10
+ export default meta;
11
+ type Story = StoryObj<typeof meta>;
12
+ export declare const Primary: Story;
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import type { StoryObj } from "@storybook/react";
3
+ import "antd/dist/antd.css";
4
+ import ConnectionContextDecorator from './Decorators/ConnectionContextDecorator';
5
+ declare const meta: {
6
+ title: string;
7
+ component: (props: any) => import("react").JSX.Element;
8
+ decorators: (typeof ConnectionContextDecorator)[];
9
+ };
10
+ export default meta;
11
+ type Story = StoryObj<typeof meta>;
12
+ export declare const Primary: Story;
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import type { StoryObj } from "@storybook/react";
3
+ import "antd/dist/antd.css";
4
+ import ConnectionContextDecorator from './Decorators/ConnectionContextDecorator';
5
+ declare const meta: {
6
+ title: string;
7
+ component: (props: any) => import("react").JSX.Element;
8
+ decorators: (typeof ConnectionContextDecorator)[];
9
+ };
10
+ export default meta;
11
+ type Story = StoryObj<typeof meta>;
12
+ export declare const Primary: Story;
package/dist/esm/index.js CHANGED
@@ -495,7 +495,7 @@ function e$1(e){this.message=e;}e$1.prototype=new Error,e$1.prototype.name="Inva
495
495
  var ConnectionContext = createContext({});
496
496
  var ConnectionContextProvider = function (props) {
497
497
  var _a = useState(), token = _a[0], setToken = _a[1];
498
- var serverURL = props.serverURL, t = props.t, children = props.children;
498
+ var serverURL = props.serverURL, t = props.t, children = props.children, statServerUrl = props.statServerUrl;
499
499
  useEffect(function () {
500
500
  var timer = setInterval(function () { return __awaiter(void 0, void 0, void 0, function () {
501
501
  var newToken;
@@ -526,10 +526,16 @@ var ConnectionContextProvider = function (props) {
526
526
  headers = { authorization: "Bearer ".concat(token.toString()) };
527
527
  }
528
528
  else {
529
- localStorage.getItem('token');
530
- headers = {
531
- authorization: "Bearer ".concat(localStorage.getItem('token')),
532
- };
529
+ if (localStorage.getItem('token')) {
530
+ headers = {
531
+ authorization: "Bearer ".concat(localStorage.getItem('token')),
532
+ };
533
+ }
534
+ else {
535
+ headers = {
536
+ authorization: "Bearer ".concat(process.env.STORYBOOK_ACCESS_TOKEN),
537
+ };
538
+ }
533
539
  }
534
540
  axios(__assign({ method: method, url: url, data: data, headers: headers }, config))
535
541
  .then(function (response) {
@@ -650,7 +656,7 @@ var ConnectionContextProvider = function (props) {
650
656
  removeToken(token);
651
657
  }, [token]);
652
658
  return (React.createElement(ConnectionContext.Provider, { value: {
653
- connection: { post: post, put: put, get: get, patch: patch, delete: del, updateToken: updateToken, token: token, removeToken: removeToken },
659
+ connection: { post: post, put: put, get: get, patch: patch, delete: del, updateToken: updateToken, token: token, removeToken: removeToken, statServerUrl: statServerUrl },
654
660
  } }, children));
655
661
  };
656
662
  var useConnection = function () {
@@ -670,23 +676,23 @@ var UserInformationContextProvider = function (_a) {
670
676
  var token = useConnection().token;
671
677
  var _b = useState(false), isTokenExpired = _b[0], setIsTokenExpired = _b[1];
672
678
  var initialUserProps = {
673
- id: localStorage.getItem('userId') ? localStorage.getItem('userId') : '',
674
- userRole: localStorage.getItem('userRole') ? localStorage.getItem('userRole') : '',
679
+ id: localStorage.getItem('userId') ? localStorage.getItem('userId') : process.env.STORYBOOK_USER_ID ? process.env.STORYBOOK_USER_ID : '',
680
+ userRole: localStorage.getItem('userRole') ? localStorage.getItem('userRole') : process.env.STORYBOOK_USER_ROLE ? process.env.STORYBOOK_USER_ROLE : '',
675
681
  companyRole: localStorage.getItem('companyRole')
676
682
  ? localStorage.getItem('companyRole')
677
- : '',
683
+ : process.env.STORYBOOK_COMPANY_ROLE ? process.env.STORYBOOK_COMPANY_ROLE : '',
678
684
  companyId: localStorage.getItem('companyId')
679
685
  ? parseInt(localStorage.getItem('companyId'))
680
- : -1,
686
+ : process.env.STORYBOOK_COMPANY_ID ? parseInt(process.env.STORYBOOK_COMPANY_ID) : -1,
681
687
  companyLogo: localStorage.getItem('companyLogo')
682
688
  ? localStorage.getItem('companyLogo')
683
- : '',
689
+ : process.env.STORYBOOK_COMPANY_LOGO ? process.env.STORYBOOK_COMPANY_LOGO : '',
684
690
  companyName: localStorage.getItem('companyName')
685
691
  ? localStorage.getItem('companyName')
686
- : '',
692
+ : process.env.STORYBOOK_COMPANY_NAME ? process.env.STORYBOOK_COMPANY_NAME : '',
687
693
  companyState: localStorage.getItem('companyState')
688
694
  ? parseInt(localStorage.getItem('companyState'))
689
- : 0,
695
+ : process.env.STORYBOOK_COMPANY_STATE ? parseInt(process.env.STORYBOOK_COMPANY_STATE) : 0,
690
696
  };
691
697
  var _c = useState(initialUserProps), userInfoState = _c[0], setUserInfoState = _c[1];
692
698
  var setUserInfo = function (value) {
@@ -23931,7 +23937,7 @@ var MapStatsComponent = function (props) {
23931
23937
  var RangePicker$1 = DatePicker.RangePicker;
23932
23938
  var MrvDashboardComponent = function (props) {
23933
23939
  var Link = props.Link, Chart = props.Chart, t = props.t, ButtonGroup = props.ButtonGroup, _a = props.isMultipleDashboardsVisible, isMultipleDashboardsVisible = _a === void 0 ? false : _a;
23934
- var _b = useConnection(); _b.get; var post = _b.post; _b.delete;
23940
+ var _b = useConnection(); _b.get; var post = _b.post; _b.delete; var statServerUrl = _b.statServerUrl;
23935
23941
  var _c = useState({}), data = _c[0], setData = _c[1];
23936
23942
  var _e = useState(false), loading = _e[0], setLoading = _e[1];
23937
23943
  var userInfoState = useUserContext().userInfoState;
@@ -24414,7 +24420,7 @@ var MrvDashboardComponent = function (props) {
24414
24420
  _e.label = 1;
24415
24421
  case 1:
24416
24422
  _e.trys.push([1, 3, 4, 5]);
24417
- return [4 /*yield*/, post("stats/programme/agg", genPayload(), undefined, process.env.REACT_APP_STAT_URL)];
24423
+ return [4 /*yield*/, post("stats/programme/agg", genPayload(), undefined, statServerUrl)];
24418
24424
  case 2:
24419
24425
  response = _e.sent();
24420
24426
  console.log("Response", response);
@@ -25664,7 +25670,7 @@ var RegistryBarChartsStatComponent = function (props) {
25664
25670
  var RangePicker = DatePicker.RangePicker;
25665
25671
  var RegistryDashboardComponent = function (props) {
25666
25672
  var Chart = props.Chart, t = props.t, ButtonGroup = props.ButtonGroup, Link = props.Link, _a = props.isMultipleDashboardsVisible, isMultipleDashboardsVisible = _a === void 0 ? false : _a;
25667
- var _b = useConnection(); _b.get; var post = _b.post; _b.delete;
25673
+ var _b = useConnection(); _b.get; var post = _b.post; _b.delete; var statServerUrl = _b.statServerUrl;
25668
25674
  var userInfoState = useUserContext().userInfoState;
25669
25675
  var _c = useState(false), loadingWithoutTimeRange = _c[0], setLoadingWithoutTimeRange = _c[1];
25670
25676
  var _e = useState(false), loading = _e[0], setLoading = _e[1];
@@ -26111,7 +26117,7 @@ var RegistryDashboardComponent = function (props) {
26111
26117
  _253.label = 1;
26112
26118
  case 1:
26113
26119
  _253.trys.push([1, 3, 4, 5]);
26114
- return [4 /*yield*/, post("stats/programme/agg", getAllChartsParams(), undefined, process.env.REACT_APP_STAT_URL)];
26120
+ return [4 /*yield*/, post("stats/programme/agg", getAllChartsParams(), undefined, statServerUrl)];
26115
26121
  case 2:
26116
26122
  response = _253.sent();
26117
26123
  totalCreditsCertifiedStats = void 0;
@@ -26388,7 +26394,7 @@ var RegistryDashboardComponent = function (props) {
26388
26394
  _77.label = 1;
26389
26395
  case 1:
26390
26396
  _77.trys.push([1, 3, 4, 5]);
26391
- return [4 /*yield*/, post("stats/programme/agg", getAllProgrammeAnalyticsStatsParamsWithoutTimeRange(), undefined, process.env.REACT_APP_STAT_URL)];
26397
+ return [4 /*yield*/, post("stats/programme/agg", getAllProgrammeAnalyticsStatsParamsWithoutTimeRange(), undefined, statServerUrl)];
26392
26398
  case 2:
26393
26399
  response = _77.sent();
26394
26400
  programmeByStatusAggregationResponse = (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.stats) === null || _b === void 0 ? void 0 : _b.AGG_PROGRAMME_BY_STATUS) === null || _c === void 0 ? void 0 : _c.data;
@@ -26481,7 +26487,7 @@ var RegistryDashboardComponent = function (props) {
26481
26487
  _188.label = 1;
26482
26488
  case 1:
26483
26489
  _188.trys.push([1, 3, 4, 5]);
26484
- return [4 /*yield*/, post("stats/programme/agg", getAllProgrammeAnalyticsStatsParams(), undefined, process.env.REACT_APP_STAT_URL)];
26490
+ return [4 /*yield*/, post("stats/programme/agg", getAllProgrammeAnalyticsStatsParams(), undefined, statServerUrl)];
26485
26491
  case 2:
26486
26492
  response = _188.sent();
26487
26493
  programmeByStatusAuthAggregationResponse = void 0;