@influenzanet/case-web-app-core 2.7.5-staging.6 → 2.7.5-staging.7

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.
@@ -1,10 +1,10 @@
1
- import React from 'react';
2
- import { FooterConfig } from './types/footerConfig';
3
- import { AppConfig } from './types/appConfig';
4
- import { HeaderConfig } from './types/headerConfig';
5
- import { NavbarConfig } from './types/navbarConfig';
6
- import { PagesConfig } from './types/pagesConfig';
7
- import { CustomSurveyResponseComponent } from '@influenzanet/case-web-ui/build/components/survey/SurveySingleItemView/ResponseComponent/ResponseComponent';
1
+ import React from "react";
2
+ import { FooterConfig } from "./types/footerConfig";
3
+ import { AppConfig } from "./types/appConfig";
4
+ import { HeaderConfig } from "./types/headerConfig";
5
+ import { NavbarConfig } from "./types/navbarConfig";
6
+ import { PagesConfig } from "./types/pagesConfig";
7
+ import { CustomSurveyResponseComponent } from "@influenzanet/case-web-ui/build/components/survey/SurveySingleItemView/ResponseComponent/ResponseComponent";
8
8
  export interface Extension {
9
9
  name: string;
10
10
  component: React.FunctionComponent<any>;
package/build/index.d.ts CHANGED
@@ -6,6 +6,11 @@ import * as userAPI from "./api/userAPI";
6
6
  import { useAuthTokenCheck } from "./hooks/useAuthTokenCheck";
7
7
  import PreventAccidentalNavigationPrompt from "./components/misc/PreventAccidentalNavigationPrompt";
8
8
  import InternalNavigator from "./components/misc/InternalNavigator";
9
+ import { AppConfig } from "./types/appConfig";
10
+ import { HeaderConfig } from './types/headerConfig';
11
+ import { FooterConfig } from './types/footerConfig';
12
+ import { NavbarConfig } from './types/navbarConfig';
13
+ import { PageConfig } from './types/pagesConfig';
9
14
  declare const coreReduxActions: {
10
15
  appActions: import("@reduxjs/toolkit").CaseReducerActions<{
11
16
  reset: (state: import("immer/dist/internal").WritableDraft<import("./store/appSlice").AppState>) => import("immer/dist/internal").WritableDraft<import("./store/appSlice").AppState>;
@@ -80,4 +85,4 @@ declare const coreReduxActions: {
80
85
  declare const coreReduxThunks: {
81
86
  enterStudyThunk: import("@reduxjs/toolkit").AsyncThunk<import("./store/actions/studiesActions").EnterStudyPayload, import("./store/thunks/studiesThunks").EnterStudyRequest, {}>;
82
87
  };
83
- export { AppCore, initI18n, store, reducersManager, localStorageManager, studyAPI, userAPI, coreReduxActions, coreReduxThunks, useAuthTokenCheck, PreventAccidentalNavigationPrompt, InternalNavigator, };
88
+ export { AppCore, initI18n, store, reducersManager, localStorageManager, studyAPI, userAPI, coreReduxActions, coreReduxThunks, useAuthTokenCheck, PreventAccidentalNavigationPrompt, InternalNavigator, type AppConfig, type HeaderConfig, type FooterConfig, type NavbarConfig, type PageConfig };
package/build/index.es.js CHANGED
@@ -21978,11 +21978,11 @@ var enterStudyThunk = createAsyncThunk("studies/enterStudy", function (_a, _b) {
21978
21978
  })];
21979
21979
  case 1:
21980
21980
  _c.sent();
21981
+ payload = { profileId: profileId, studyKey: studyKey };
21982
+ dispatch(enterStudy(payload));
21981
21983
  return [4 /*yield*/, dispatch(initializeActiveSurveysThunk())];
21982
21984
  case 2:
21983
21985
  _c.sent();
21984
- payload = { profileId: profileId, studyKey: studyKey };
21985
- dispatch(enterStudy(payload));
21986
21986
  return [2 /*return*/, payload];
21987
21987
  }
21988
21988
  });
@@ -22053,7 +22053,6 @@ var EditProfile = function (props) {
22053
22053
  return [4 /*yield*/, getUserReq()];
22054
22054
  case 4:
22055
22055
  user = (_a.sent()).data;
22056
- dispatch(userActions.setUser(user));
22057
22056
  // if the profile creation is successful, enter the default studies
22058
22057
  if (defaultStudies.length > 0) {
22059
22058
  defaultStudies.forEach(function (studyKey) {
@@ -22063,6 +22062,7 @@ var EditProfile = function (props) {
22063
22062
  }));
22064
22063
  });
22065
22064
  }
22065
+ dispatch(userActions.setUser(user));
22066
22066
  setLoading(false);
22067
22067
  close();
22068
22068
  return [3 /*break*/, 6];
@@ -33313,7 +33313,7 @@ var DefaultStudiesManager = function () {
33313
33313
  var currentUserId = useSelector(function (state) { return state.user.currentUser.id; });
33314
33314
  useEffect(function () {
33315
33315
  var initialize = function () { return __awaiter(void 0, void 0, void 0, function () {
33316
- var defaultStudies_1, _a, profilesStudiesMap_1, _b;
33316
+ var defaultStudies_1, _a, profilesStudiesMap_1, _b, enterStudyReqs_1;
33317
33317
  return __generator$1(this, function (_d) {
33318
33318
  switch (_d.label) {
33319
33319
  case 0:
@@ -33322,7 +33322,7 @@ var DefaultStudiesManager = function () {
33322
33322
  }
33323
33323
  _d.label = 1;
33324
33324
  case 1:
33325
- _d.trys.push([1, 5, , 6]);
33325
+ _d.trys.push([1, 7, , 8]);
33326
33326
  _a = unwrapResult;
33327
33327
  return [4 /*yield*/, dispatch(initializeDefaultStudiesThunk())];
33328
33328
  case 2:
@@ -33331,13 +33331,7 @@ var DefaultStudiesManager = function () {
33331
33331
  return [4 /*yield*/, dispatch(initializeUserStudiesThunk())];
33332
33332
  case 3:
33333
33333
  profilesStudiesMap_1 = _b.apply(void 0, [_d.sent()]);
33334
- /**
33335
- * Backward compatibility with the functionality once present
33336
- * in the SurveyList component
33337
- *
33338
- * We check whether all the default studies are assigned
33339
- * to all profiles and if not, we try entering the study
33340
- */
33334
+ enterStudyReqs_1 = [];
33341
33335
  Object.keys(profilesStudiesMap_1).forEach(function (profileId) {
33342
33336
  var profileStudies = profilesStudiesMap_1[profileId];
33343
33337
  if (!profileStudies) {
@@ -33346,18 +33340,32 @@ var DefaultStudiesManager = function () {
33346
33340
  var missingDefaultStudies = defaultStudies_1.filter(function (study) { return !profileStudies.includes(study); });
33347
33341
  if (missingDefaultStudies.length > 0) {
33348
33342
  missingDefaultStudies.forEach(function (studyKey) {
33349
- dispatch(enterStudyThunk({ profileId: profileId, studyKey: studyKey }));
33343
+ enterStudyReqs_1.push({ profileId: profileId, studyKey: studyKey });
33350
33344
  });
33351
33345
  }
33352
33346
  });
33353
- return [4 /*yield*/, dispatch(initializeActiveSurveysThunk())];
33347
+ if (!(enterStudyReqs_1.length > 0)) return [3 /*break*/, 6];
33348
+ return [4 /*yield*/, Promise.all(enterStudyReqs_1.map(function (req) { return __awaiter(void 0, void 0, void 0, function () {
33349
+ return __generator$1(this, function (_a) {
33350
+ switch (_a.label) {
33351
+ case 0: return [4 /*yield*/, dispatch(enterStudyThunk(req))];
33352
+ case 1:
33353
+ _a.sent();
33354
+ return [2 /*return*/];
33355
+ }
33356
+ });
33357
+ }); }))];
33354
33358
  case 4:
33355
33359
  _d.sent();
33356
- return [3 /*break*/, 6];
33360
+ return [4 /*yield*/, dispatch(initializeActiveSurveysThunk())];
33357
33361
  case 5:
33358
33362
  _d.sent();
33359
- return [3 /*break*/, 6];
33360
- case 6: return [2 /*return*/];
33363
+ _d.label = 6;
33364
+ case 6: return [3 /*break*/, 8];
33365
+ case 7:
33366
+ _d.sent();
33367
+ return [3 /*break*/, 8];
33368
+ case 8: return [2 /*return*/];
33361
33369
  }
33362
33370
  });
33363
33371
  }); };
@@ -33372,19 +33380,23 @@ var AppCore = function (props) {
33372
33380
  var i18n = useTranslation().i18n;
33373
33381
  var accessToken = useSelector(function (state) { var _a; return (_a = state.app.auth) === null || _a === void 0 ? void 0 : _a.accessToken; });
33374
33382
  /*
33375
- * In order to solve the issue https://github.com/coneno/case-web-app-core/issues/5, now Dialogs also need to know the application level default routes,
33376
- * but removing the defaultRoutes field from the PagesConfig interface and make it available at a higher level would be a breaking change for all the existing frontends.
33377
- *
33378
- * From now on, all components under AppCore that need to be aware of the application level default routes, can use a prop directly initialized with the const below.
33379
- *
33380
- * See how it is handled in the Pages and GlobalDialog components
33381
- */
33382
- var defaultRoutes = ((_a = props.pagesConfig) === null || _a === void 0 ? void 0 : _a.defaultRoutes) ? props.pagesConfig.defaultRoutes : BasicRoutes;
33383
+ * In order to solve the issue https://github.com/coneno/case-web-app-core/issues/5, now Dialogs also need to know the application level default routes,
33384
+ * but removing the defaultRoutes field from the PagesConfig interface and make it available at a higher level would be a breaking change for all the existing frontends.
33385
+ *
33386
+ * From now on, all components under AppCore that need to be aware of the application level default routes, can use a prop directly initialized with the const below.
33387
+ *
33388
+ * See how it is handled in the Pages and GlobalDialog components
33389
+ */
33390
+ var defaultRoutes = ((_a = props.pagesConfig) === null || _a === void 0 ? void 0 : _a.defaultRoutes)
33391
+ ? props.pagesConfig.defaultRoutes
33392
+ : BasicRoutes;
33383
33393
  if (accessToken) {
33384
33394
  setDefaultAccessTokenHeader(accessToken);
33385
33395
  }
33386
33396
  useEffect(function () {
33387
- var language = loadLastSelectedLanguage(process.env.REACT_APP_DEFAULT_LANGUAGE ? process.env.REACT_APP_DEFAULT_LANGUAGE : 'en');
33397
+ var language = loadLastSelectedLanguage(process.env.REACT_APP_DEFAULT_LANGUAGE
33398
+ ? process.env.REACT_APP_DEFAULT_LANGUAGE
33399
+ : "en");
33388
33400
  i18n.changeLanguage(language);
33389
33401
  }, [i18n]);
33390
33402
  useEffect(function () {
@@ -33392,7 +33404,7 @@ var AppCore = function (props) {
33392
33404
  }, [i18n.language]);
33393
33405
  useEffect(function () {
33394
33406
  var _a, _b;
33395
- dispatch(appConfig.updateInstanceID(((_a = props.appConfig) === null || _a === void 0 ? void 0 : _a.instanceId) ? (_b = props.appConfig) === null || _b === void 0 ? void 0 : _b.instanceId : 'default'));
33407
+ dispatch(appConfig.updateInstanceID(((_a = props.appConfig) === null || _a === void 0 ? void 0 : _a.instanceId) ? (_b = props.appConfig) === null || _b === void 0 ? void 0 : _b.instanceId : "default"));
33396
33408
  }, [dispatch, (_b = props.appConfig) === null || _b === void 0 ? void 0 : _b.instanceId]);
33397
33409
  useEffect(function () {
33398
33410
  if (props.appConfig) {
@@ -33404,7 +33416,9 @@ var AppCore = function (props) {
33404
33416
  console.log("Changing language to: ".concat(code));
33405
33417
  i18n.changeLanguage(code);
33406
33418
  };
33407
- return (jsxs(q, { children: [jsx(LocalStorage, {}, void 0), jsxs(BrowserRouter, __assign({ basename: process.env.NODE_ENV === 'production' ? process.env.PUBLIC_URL : undefined }, { children: [jsx(ScrollToTop, {}, void 0), jsx(DefaultStudiesManager, {}, void 0), props.customHeader ? props.customHeader : null, !props.hideDefaultHeader ? jsx(HeaderRenderer, { config: props.headerConfig, onChangeLanguage: handleLanguageChange, onOpenExternalPage: handleOpenExternalPage }, void 0) : null, jsx(Navbar, { loading: props.navbarConfig === undefined, content: props.navbarConfig, onOpenExternalPage: handleOpenExternalPage }, void 0), jsx(Pages, { config: props.pagesConfig, onOpenExternalPage: handleOpenExternalPage, extensions: props.extensions, customResponseComponents: props.customSurveyResponseComponents, dateLocales: props.dateLocales, defaultRoutes: defaultRoutes }, void 0), !props.hideDefaultFooter ? jsx(FooterRenderer, { footerConfig: props.footerConfig, onChangeLanguage: handleLanguageChange, onOpenExternalPage: handleOpenExternalPage }, void 0) : null, props.customFooter ? props.customFooter : null, jsx(GlobalDialogs, { defaultRoutes: defaultRoutes, onChangeLanguage: handleLanguageChange }, void 0)] }), void 0)] }, void 0));
33419
+ return (jsxs(q, { children: [jsx(LocalStorage, {}, void 0), jsx(DefaultStudiesManager, {}, void 0), jsxs(BrowserRouter, __assign({ basename: process.env.NODE_ENV === "production"
33420
+ ? process.env.PUBLIC_URL
33421
+ : undefined }, { children: [jsx(ScrollToTop, {}, void 0), props.customHeader ? props.customHeader : null, !props.hideDefaultHeader ? (jsx(HeaderRenderer, { config: props.headerConfig, onChangeLanguage: handleLanguageChange, onOpenExternalPage: handleOpenExternalPage }, void 0)) : null, jsx(Navbar, { loading: props.navbarConfig === undefined, content: props.navbarConfig, onOpenExternalPage: handleOpenExternalPage }, void 0), jsx(Pages, { config: props.pagesConfig, onOpenExternalPage: handleOpenExternalPage, extensions: props.extensions, customResponseComponents: props.customSurveyResponseComponents, dateLocales: props.dateLocales, defaultRoutes: defaultRoutes }, void 0), !props.hideDefaultFooter ? (jsx(FooterRenderer, { footerConfig: props.footerConfig, onChangeLanguage: handleLanguageChange, onOpenExternalPage: handleOpenExternalPage }, void 0)) : null, props.customFooter ? props.customFooter : null, jsx(GlobalDialogs, { defaultRoutes: defaultRoutes, onChangeLanguage: handleLanguageChange }, void 0)] }), void 0)] }, void 0));
33408
33422
  };
33409
33423
 
33410
33424
  var InternalNavigator = function (props) {