@griddo/ax 1.65.27 → 1.66.2

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.
Files changed (57) hide show
  1. package/package.json +2 -2
  2. package/src/GlobalStore.tsx +4 -3
  3. package/src/api/structuredData.tsx +15 -1
  4. package/src/components/Browser/index.tsx +13 -16
  5. package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/Field/index.tsx +12 -0
  6. package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/TemplateManager/index.tsx +11 -0
  7. package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/index.tsx +13 -0
  8. package/src/components/ConfigPanel/Form/index.tsx +3 -1
  9. package/src/components/ConfigPanel/index.tsx +19 -5
  10. package/src/components/ConfigPanel/style.tsx +5 -0
  11. package/src/components/FieldContainer/index.tsx +4 -0
  12. package/src/components/Fields/ComponentArray/MixableComponentArray/PasteModuleButton/index.tsx +49 -0
  13. package/src/components/Fields/ComponentArray/MixableComponentArray/index.tsx +51 -11
  14. package/src/components/Fields/ComponentArray/MixableComponentArray/style.tsx +14 -1
  15. package/src/components/Fields/ComponentContainer/index.tsx +24 -5
  16. package/src/components/Fields/ImageField/index.tsx +18 -5
  17. package/src/components/Image/index.tsx +25 -0
  18. package/src/components/Notification/index.tsx +3 -1
  19. package/src/components/index.tsx +2 -0
  20. package/src/containers/Navigation/Defaults/actions.tsx +27 -9
  21. package/src/containers/PageEditor/actions.tsx +104 -5
  22. package/src/containers/PageEditor/constants.tsx +2 -0
  23. package/src/containers/PageEditor/interfaces.tsx +12 -0
  24. package/src/containers/PageEditor/reducer.tsx +8 -0
  25. package/src/containers/PageEditor/utils.tsx +2 -2
  26. package/src/helpers/index.tsx +6 -0
  27. package/src/helpers/schemas.tsx +36 -7
  28. package/src/modules/App/Routing/index.tsx +1 -1
  29. package/src/modules/Content/OptionTable/index.tsx +44 -43
  30. package/src/modules/Content/OptionTable/store.tsx +1 -1
  31. package/src/modules/Content/OptionTable/style.tsx +27 -12
  32. package/src/modules/Content/PageItem/index.tsx +14 -4
  33. package/src/modules/Content/atoms.tsx +19 -2
  34. package/src/modules/Content/index.tsx +37 -14
  35. package/src/modules/Content/utils.tsx +27 -12
  36. package/src/modules/GlobalEditor/Editor/index.tsx +12 -1
  37. package/src/modules/GlobalEditor/index.tsx +20 -2
  38. package/src/modules/Navigation/Defaults/DefaultsEditor/index.tsx +13 -0
  39. package/src/modules/Navigation/Defaults/atoms.tsx +28 -0
  40. package/src/modules/Navigation/Defaults/index.tsx +30 -4
  41. package/src/modules/Navigation/Defaults/style.tsx +32 -1
  42. package/src/modules/PageEditor/Editor/index.tsx +16 -1
  43. package/src/modules/PageEditor/index.tsx +14 -1
  44. package/src/modules/PublicPreview/index.tsx +15 -18
  45. package/src/modules/Settings/Globals/NavigationModules/SideModal/SideModalOption/index.tsx +35 -0
  46. package/src/modules/Settings/Globals/NavigationModules/SideModal/SideModalOption/style.tsx +22 -0
  47. package/src/modules/Settings/Globals/NavigationModules/SideModal/index.tsx +111 -0
  48. package/src/modules/Settings/Globals/NavigationModules/SideModal/style.tsx +64 -0
  49. package/src/modules/Settings/Globals/NavigationModules/index.tsx +89 -0
  50. package/src/modules/Settings/Globals/NavigationModules/style.tsx +36 -0
  51. package/src/modules/Settings/Globals/index.tsx +38 -1
  52. package/src/modules/Sites/SitesList/SiteItem/index.tsx +7 -5
  53. package/src/modules/StructuredData/StructuredDataList/OptionTable/index.tsx +14 -3
  54. package/src/modules/StructuredData/StructuredDataList/OptionTable/style.tsx +11 -2
  55. package/src/modules/StructuredData/StructuredDataList/atoms.tsx +19 -2
  56. package/src/modules/StructuredData/StructuredDataList/index.tsx +4 -13
  57. package/src/types/index.tsx +11 -0
@@ -0,0 +1,25 @@
1
+ import React from "react";
2
+ import { GriddoImage } from "@griddo/core";
3
+
4
+ const Image = (props: IProps) => {
5
+ const DEFAULTS = {
6
+ quality: 75,
7
+ crop: "cover",
8
+ loading: "lazy",
9
+ formats: ["webp"],
10
+ };
11
+
12
+ return <GriddoImage {...DEFAULTS} {...props} />;
13
+ };
14
+
15
+ interface IProps {
16
+ width: number;
17
+ height?: number;
18
+ url: string;
19
+ quality?: number;
20
+ crop?: string;
21
+ loading?: string;
22
+ formats?: string[];
23
+ }
24
+
25
+ export default Image;
@@ -4,7 +4,7 @@ import { Icon } from "@ax/components";
4
4
  import * as S from "./style";
5
5
 
6
6
  const Notification = (props: IProps) => {
7
- const { text, type, btnText, resetError, onClick, closeButton = true, actionsBelow } = props;
7
+ const { text, type, btnText, resetError, onClick, closeButton = true, actionsBelow, onClose } = props;
8
8
 
9
9
  const [isOpen, setIsOpen] = useState(true);
10
10
 
@@ -40,6 +40,7 @@ const Notification = (props: IProps) => {
40
40
 
41
41
  const handleClose = () => {
42
42
  resetError && resetError();
43
+ onClose && onClose();
43
44
  setIsOpen(false);
44
45
  };
45
46
 
@@ -78,6 +79,7 @@ interface IProps {
78
79
  onClick?: () => void;
79
80
  closeButton?: boolean;
80
81
  actionsBelow?: boolean;
82
+ onClose?: () => void;
81
83
  }
82
84
 
83
85
  export default Notification;
@@ -64,6 +64,7 @@ import Gallery from "./Gallery";
64
64
  import GuardModal from "./GuardModal";
65
65
  import Icon from "./Icon";
66
66
  import IconAction from "./IconAction";
67
+ import Image from "./Image";
67
68
  import InformativeMenu from "./InformativeMenu";
68
69
  import LanguageMenu from "./LanguageMenu";
69
70
  import Loader from "./Loader";
@@ -155,6 +156,7 @@ export {
155
156
  GuardModal,
156
157
  Icon,
157
158
  IconAction,
159
+ Image,
158
160
  InformativeMenu,
159
161
  LanguageMenu,
160
162
  Loader,
@@ -2,7 +2,15 @@ import { Dispatch } from "redux";
2
2
 
3
3
  import { navigation } from "@ax/api";
4
4
  import { IBreadcrumbItem, ISchema } from "@ax/types";
5
- import { getDefaultSchema, getSchema, handleRequest, removeEditorIds, deepClone, getNullValue } from "@ax/helpers";
5
+ import {
6
+ getDefaultSchema,
7
+ getSchema,
8
+ handleRequest,
9
+ removeEditorIds,
10
+ deepClone,
11
+ getNullValue,
12
+ getDefaultNavigationModules,
13
+ } from "@ax/helpers";
6
14
  import {
7
15
  findByEditorID,
8
16
  generateEditorIDs,
@@ -49,7 +57,7 @@ import {
49
57
  ISetSelectedParent,
50
58
  } from "./interfaces";
51
59
 
52
- const { setIsLoading, setIsSaving } = appActions;
60
+ const { setIsLoading } = appActions;
53
61
 
54
62
  function setEditorContent(editorContent: any): ISetEditorContent {
55
63
  return { type: SET_EDITOR_CONTENT, payload: { editorContent } };
@@ -366,9 +374,16 @@ function getSiteDefaults(): (dispatch: Dispatch, getState: any) => Promise<void>
366
374
  }
367
375
 
368
376
  function generateNewDefault(dispatch: Dispatch, getState: any) {
369
- const { selectedDefault } = getStateValues(getState);
377
+ const {
378
+ selectedDefault,
379
+ currentSiteInfo: { navigationModules },
380
+ } = getStateValues(getState);
381
+
370
382
  const isHeader = selectedDefault === "Headers";
371
- const component = isHeader ? "Header" : "Footer";
383
+ const { defaultHeader, defaultFooter } = getDefaultNavigationModules();
384
+ const headerComponent = navigationModules?.header || defaultHeader.component;
385
+ const footerComponent = navigationModules?.footer || defaultFooter.component;
386
+ const component = isHeader ? headerComponent : footerComponent;
372
387
  const defaultSchema = getDefaultSchema(component);
373
388
 
374
389
  const rootEditorID = 0;
@@ -382,7 +397,7 @@ function generateNewDefault(dispatch: Dispatch, getState: any) {
382
397
  function getValues(): (dispatch: Dispatch, getState: any) => Promise<void> {
383
398
  return async (dispatch, getState) => {
384
399
  try {
385
- const { selectedDefault, header, footer, isNewTranslation } = getStateValues(getState);
400
+ const { selectedDefault, header, footer, isNewTranslation, currentSiteInfo } = getStateValues(getState);
386
401
 
387
402
  const isHeader = selectedDefault === "Headers";
388
403
  const currentNavigation = isHeader ? header : footer;
@@ -397,7 +412,10 @@ function getValues(): (dispatch: Dispatch, getState: any) => Promise<void> {
397
412
  const responseActions = {
398
413
  handleSuccess: async (response: any) => {
399
414
  const rootEditorID = 0;
400
-
415
+ const navigationModuleComponent = currentSiteInfo.navigationModules?.[type];
416
+ if (navigationModuleComponent) {
417
+ response.component = navigationModuleComponent;
418
+ }
401
419
  dispatch(setSelectedEditorID(rootEditorID));
402
420
  generateContent(response, dispatch, getState);
403
421
  },
@@ -475,11 +493,11 @@ function addComponent(type: any, key: string): (dispatch: Dispatch, getState: an
475
493
  generateContent(updatedContent, dispatch, getState);
476
494
 
477
495
  if (type.editorID) {
478
- setSelectedContent(type.editorID)(dispatch, getState);
496
+ localStorage.setItem("selectedID", `${type.editorID}`);
479
497
  } else {
480
498
  const { editorContent } = getStateValues(getState);
481
499
  const lastElementEditorID = getLastComponentEditorID(editorContent, component.editorID, key);
482
- setSelectedContent(lastElementEditorID)(dispatch, getState);
500
+ localStorage.setItem("selectedID", `${lastElementEditorID}`);
483
501
  }
484
502
  };
485
503
  }
@@ -546,7 +564,7 @@ function duplicateModule(editorID: number, key?: string): (dispatch: Dispatch, g
546
564
  const module = Array.isArray(generatedParent) ? generatedGrandParent : generatedParent;
547
565
  const duplicatedEditorID = module[parentKey][duplicatedItemIndex].editorID;
548
566
 
549
- setSelectedContent(duplicatedEditorID)(dispatch, getState);
567
+ localStorage.setItem("selectedID", `${duplicatedEditorID}`);
550
568
  };
551
569
  }
552
570
 
@@ -29,7 +29,7 @@ import {
29
29
  } from "@ax/forms";
30
30
  import { appActions } from "@ax/containers/App";
31
31
  import { navigationActions } from "@ax/containers/Navigation";
32
- import { pages } from "@ax/api";
32
+ import { pages, structuredData } from "@ax/api";
33
33
  import { getPageData, getPageNavigation, getStateValues } from "./utils";
34
34
  import {
35
35
  SET_BREADCRUMB,
@@ -50,9 +50,20 @@ import {
50
50
  SET_VALIDATED,
51
51
  SET_SITE_PAGE_ID,
52
52
  SET_USER_EDITING,
53
+ SET_LAST_ELEMENT_ADDED_ID,
54
+ SET_COPY_MODULE,
53
55
  } from "./constants";
54
56
 
55
- import { IPage, ISavePageParams, IBreadcrumbItem, ISchema, IErrorItem, IUserEditing } from "@ax/types";
57
+ import {
58
+ IPage,
59
+ ISavePageParams,
60
+ IBreadcrumbItem,
61
+ ISchema,
62
+ IErrorItem,
63
+ IUserEditing,
64
+ IStructuredDataContent,
65
+ INotification,
66
+ } from "@ax/types";
56
67
  import {
57
68
  ISetBreadcrumb,
58
69
  ISetSchema,
@@ -74,6 +85,8 @@ import {
74
85
  ISetSitePageID,
75
86
  ISetUserEditing,
76
87
  pageStatus,
88
+ ISetLastElementAddedId,
89
+ ISetCopyModule,
77
90
  } from "./interfaces";
78
91
 
79
92
  const { setIsLoading, setIsSaving } = appActions;
@@ -154,6 +167,14 @@ function setUserEditing(userEditing: IUserEditing | null): ISetUserEditing {
154
167
  return { type: SET_USER_EDITING, payload: { userEditing } };
155
168
  }
156
169
 
170
+ function setLastElementAddedId(lastElementAddedId: null | number): ISetLastElementAddedId {
171
+ return { type: SET_LAST_ELEMENT_ADDED_ID, payload: { lastElementAddedId } };
172
+ }
173
+
174
+ function setCopyModule(moduleCopy: Record<string, unknown> | null): ISetCopyModule {
175
+ return { type: SET_COPY_MODULE, payload: { moduleCopy } };
176
+ }
177
+
157
178
  function setTranslatedParent(): (dispatch: Dispatch, getState: any) => void {
158
179
  return async (dispatch, getState) => {
159
180
  try {
@@ -582,7 +603,8 @@ function addComponent(type: any, key: string): (dispatch: Dispatch, getState: an
582
603
  } else {
583
604
  const { sections: generatedSections } = getStateValues(getState);
584
605
  const lastElementEditorID = getLastComponentEditorID(generatedSections, component.editorID, key);
585
- setSelectedContent(lastElementEditorID)(dispatch, getState);
606
+ dispatch(setLastElementAddedId(lastElementEditorID));
607
+ localStorage.setItem("selectedID", `${lastElementEditorID}`);
586
608
  }
587
609
  };
588
610
  }
@@ -626,7 +648,8 @@ function addModule(
626
648
  const { sections: generatedSections } = getStateValues(getState);
627
649
  const lastModuleEditorID = getLastModuleEditorID(generatedSections, updatedSectionIndex);
628
650
 
629
- setSelectedContent(lastModuleEditorID)(dispatch, getState);
651
+ dispatch(setLastElementAddedId(lastModuleEditorID));
652
+ localStorage.setItem("selectedID", `${lastModuleEditorID}`);
630
653
  };
631
654
  }
632
655
 
@@ -685,6 +708,8 @@ function deleteModule(editorID: number, key?: string): (dispatch: Dispatch, getS
685
708
  };
686
709
 
687
710
  generatePageContent(updatedPageContent, dispatch, getState);
711
+
712
+ dispatch(setLastElementAddedId(null));
688
713
  };
689
714
  }
690
715
 
@@ -714,7 +739,78 @@ function duplicateModule(editorID: number, key?: string): (dispatch: Dispatch, g
714
739
  const section = Array.isArray(generatedParent) ? generatedGrandParent : generatedParent;
715
740
  const duplicatedEditorID = section[parentKey][duplicatedItemIndex].editorID;
716
741
 
717
- setSelectedContent(duplicatedEditorID)(dispatch, getState);
742
+ localStorage.setItem("selectedID", `${duplicatedEditorID}`);
743
+ };
744
+ }
745
+
746
+ function copyModule(editorID: number): (dispatch: Dispatch, getState: any) => boolean {
747
+ return (dispatch, getState) => {
748
+ const { sections } = getStateValues(getState);
749
+ const { element: originalElement } = findByEditorID(sections, editorID);
750
+ if (originalElement) {
751
+ const { editorID, parentEditorID, ...element } = originalElement;
752
+ const payload = {
753
+ date: new Date(),
754
+ element,
755
+ };
756
+ dispatch(setCopyModule(payload));
757
+ return true;
758
+ } else {
759
+ return false;
760
+ }
761
+ };
762
+ }
763
+
764
+ function pasteModule(editorID: number): (dispatch: Dispatch, getState: any) => Promise<{ error?: INotification }> {
765
+ return async (dispatch, getState) => {
766
+ const {
767
+ pageEditor: { moduleCopy },
768
+ sites: { currentSiteInfo },
769
+ } = getState();
770
+
771
+ const { sections, editorContent } = getStateValues(getState);
772
+
773
+ const updatedSections: any = [...sections];
774
+ const { element: originalElement } = findByEditorID(updatedSections, editorID);
775
+
776
+ const validatedModuleCopy: any = deepClone(moduleCopy.element);
777
+ let error: INotification | undefined;
778
+
779
+ if (moduleCopy.element.hasDistributorData) {
780
+ const { mode, fixed } = moduleCopy.element.data;
781
+ const isManualMode = mode === "manual" && !!fixed?.length;
782
+ if (isManualMode) {
783
+ const response = await structuredData.getDataContentBulk(fixed, currentSiteInfo.id);
784
+ if (isReqOk(response.status)) {
785
+ const validDataIds: number[] = [];
786
+ response.data.forEach((data: IStructuredDataContent) => data.relatedSite && validDataIds.push(data.id));
787
+ const hasInvalidData = validDataIds.length < fixed.length;
788
+ validatedModuleCopy.data.fixed = validDataIds;
789
+ if (hasInvalidData) {
790
+ error = {
791
+ type: "warning",
792
+ text: "Some distributor data were not copied because they are not imported into this site",
793
+ };
794
+ }
795
+ }
796
+ }
797
+ }
798
+
799
+ const itemsArr = originalElement.modules;
800
+ itemsArr.push(validatedModuleCopy);
801
+
802
+ const updatedPageContent = {
803
+ ...editorContent,
804
+ };
805
+
806
+ generatePageContent(updatedPageContent, dispatch, getState);
807
+
808
+ const { sections: generatedSections } = getStateValues(getState);
809
+ const { element: generatedElement } = findByEditorID(generatedSections, editorID);
810
+ const pastedEditorID = generatedElement.modules[itemsArr.length - 1].editorID;
811
+
812
+ localStorage.setItem("selectedID", `${pastedEditorID}`);
813
+ return { error };
718
814
  };
719
815
  }
720
816
 
@@ -875,6 +971,7 @@ function resetPageEditor(): (dispatch: Dispatch) => Promise<void> {
875
971
  dispatch(setValidated(false));
876
972
  dispatch(setSitePageID(null));
877
973
  dispatch(setUserEditing(null));
974
+ dispatch(setLastElementAddedId(null));
878
975
  localStorage.removeItem("selectedID");
879
976
  } catch (e) {
880
977
  console.log("Error", e); //TODO
@@ -1075,4 +1172,6 @@ export {
1075
1172
  sendPagePing,
1076
1173
  discardDraft,
1077
1174
  getTemplatePage,
1175
+ copyModule,
1176
+ pasteModule,
1078
1177
  };
@@ -18,6 +18,8 @@ export const SET_ERRORS = `${NAME}/SET_ERRORS`;
18
18
  export const SET_VALIDATED = `${NAME}/SET_VALIDATED`;
19
19
  export const SET_SITE_PAGE_ID = `${NAME}/SET_SITE_PAGE_ID`;
20
20
  export const SET_USER_EDITING = `${NAME}/SET_USER_EDITING`;
21
+ export const SET_LAST_ELEMENT_ADDED_ID = `${NAME}/SET_LAST_ELEMENT_ADDED_ID`;
22
+ export const SET_COPY_MODULE = `${NAME}/SET_COPY_MODULE`;
21
23
 
22
24
  export const INITIAL_TEMPLATE = "BasicTemplate";
23
25
  export const MULTIMEDIA_COMPONENTS = ["LinkableImage", "Video"];
@@ -17,6 +17,8 @@ import {
17
17
  SET_VALIDATED,
18
18
  SET_SITE_PAGE_ID,
19
19
  SET_USER_EDITING,
20
+ SET_LAST_ELEMENT_ADDED_ID,
21
+ SET_COPY_MODULE,
20
22
  } from "./constants";
21
23
  import { IBreadcrumbItem, ISchema, IPage, IErrorItem, IUserEditing } from "@ax/types";
22
24
 
@@ -110,6 +112,16 @@ export interface ISetUserEditing {
110
112
  payload: { userEditing: IUserEditing | null };
111
113
  }
112
114
 
115
+ export interface ISetLastElementAddedId {
116
+ type: typeof SET_LAST_ELEMENT_ADDED_ID;
117
+ payload: { lastElementAddedId: null | number };
118
+ }
119
+
120
+ export interface ISetCopyModule {
121
+ type: typeof SET_COPY_MODULE;
122
+ payload: { moduleCopy: Record<string, unknown> | null };
123
+ }
124
+
113
125
  export interface IFieldProps {
114
126
  id: number;
115
127
  key: string;
@@ -20,6 +20,8 @@ import {
20
20
  SET_VALIDATED,
21
21
  SET_SITE_PAGE_ID,
22
22
  SET_USER_EDITING,
23
+ SET_LAST_ELEMENT_ADDED_ID,
24
+ SET_COPY_MODULE,
23
25
  } from "./constants";
24
26
 
25
27
  import { PageEditorActionsCreators } from "./interfaces";
@@ -43,6 +45,8 @@ export interface IPageEditorState {
43
45
  validated: boolean;
44
46
  sitePageID: number | null;
45
47
  userEditing: IUserEditing | null;
48
+ lastElementAddedId: null | number;
49
+ moduleCopy: { date: string; element: Record<string, unknown> } | null;
46
50
  }
47
51
 
48
52
  export const initialState = {
@@ -64,6 +68,8 @@ export const initialState = {
64
68
  validated: false,
65
69
  sitePageID: null,
66
70
  userEditing: null,
71
+ lastElementAddedId: null,
72
+ moduleCopy: null,
67
73
  };
68
74
 
69
75
  export function reducer(state = initialState, action: PageEditorActionsCreators): IPageEditorState {
@@ -87,6 +93,8 @@ export function reducer(state = initialState, action: PageEditorActionsCreators)
87
93
  case SET_VALIDATED:
88
94
  case SET_SITE_PAGE_ID:
89
95
  case SET_USER_EDITING:
96
+ case SET_LAST_ELEMENT_ADDED_ID:
97
+ case SET_COPY_MODULE:
90
98
  return { ...state, ...action.payload };
91
99
  default:
92
100
  return state;
@@ -66,8 +66,8 @@ export const getPageNavigation = (
66
66
  return { header: null, footer: null };
67
67
  }
68
68
 
69
- const headers: any = defaultsContent.filter((content: any) => content.component === "Header");
70
- const footers: any = defaultsContent.filter((content: any) => content.component === "Footer");
69
+ const headers: any = defaultsContent.filter((content: any) => content.type === "header");
70
+ const footers: any = defaultsContent.filter((content: any) => content.type === "footer");
71
71
  const header = !headerID
72
72
  ? headers.find((content: any) => content.setAsDefault)
73
73
  : headers.find((content: any) => content.id === headerID);
@@ -51,6 +51,9 @@ import {
51
51
  getDataPackSchema,
52
52
  getSchemaThumbnails,
53
53
  getTemplateThumbnails,
54
+ getNavigationModules,
55
+ getDefaultNavigationModules,
56
+ isMultipleNavigationModules,
54
57
  } from "./schemas";
55
58
 
56
59
  import {
@@ -169,4 +172,7 @@ export {
169
172
  splitAndTrim,
170
173
  getDefaultTheme,
171
174
  copyTextToClipboard,
175
+ getNavigationModules,
176
+ getDefaultNavigationModules,
177
+ isMultipleNavigationModules,
172
178
  };
@@ -3,15 +3,15 @@ import { sortBy } from "@ax/helpers";
3
3
  import { ModuleCategoryInfo } from "@ax/types";
4
4
  import { pageSchemas } from "@ax/schemas";
5
5
 
6
- const allSChemas = { ...schemas.all, ...pageSchemas };
6
+ const allSchemas = { ...schemas.all, ...pageSchemas };
7
7
 
8
- const getSchema = (name: string) => allSChemas[name];
9
- const getDefaultSchema = (name: string) => allSChemas[name].default;
8
+ const getSchema = (name: string) => allSchemas[name];
9
+ const getDefaultSchema = (name: string) => allSchemas[name].default;
10
10
 
11
11
  const getSchemaThumbnails = (name: string, theme?: string) => {
12
- if (!allSChemas[name].thumbnails) return null;
12
+ if (!allSchemas[name].thumbnails) return null;
13
13
 
14
- return theme && allSChemas[name].thumbnails[theme] ? allSChemas[name].thumbnails[theme] : allSChemas[name].thumbnails;
14
+ return theme && allSchemas[name].thumbnails[theme] ? allSchemas[name].thumbnails[theme] : allSchemas[name].thumbnails;
15
15
  };
16
16
 
17
17
  const getTemplate = (name: string) => schemas.templates[name];
@@ -19,7 +19,7 @@ const getTemplate = (name: string) => schemas.templates[name];
19
19
  const getDefaultTemplate = (name: string) => schemas.templates[name].default;
20
20
 
21
21
  const getTemplateThumbnails = (name: string, theme?: string) => {
22
- if (!schemas.templates[name].thumbnails) return null;
22
+ if (!schemas.templates[name]?.thumbnails) return null;
23
23
 
24
24
  return theme && schemas.templates[name].thumbnails[theme]
25
25
  ? schemas.templates[name].thumbnails[theme]
@@ -49,7 +49,7 @@ const getTemplateDisplayName = (template: string) => {
49
49
  };
50
50
 
51
51
  const filterByCategory = (options: any, category: string) =>
52
- options.filter((option: any) => allSChemas[option].category === category);
52
+ options.filter((option: any) => allSchemas[option].category === category);
53
53
 
54
54
  const getModuleCategories = (moduleList: string[]): ModuleCategoryInfo[] => {
55
55
  const categories: string[] = [];
@@ -90,6 +90,32 @@ const getModuleStyles = (module: string): any[] => {
90
90
  return options;
91
91
  };
92
92
 
93
+ const getNavigationModules = (): Record<string, any[]> => {
94
+ const navigationModules: Record<string, any[]> = { header: [], footer: [] };
95
+ Object.keys(schemas.modules).forEach((key: string) => {
96
+ const moduleType = schemas.modules[key].type;
97
+ if (["header", "footer"].includes(moduleType)) {
98
+ navigationModules[moduleType].push(schemas.modules[key]);
99
+ }
100
+ });
101
+ return navigationModules;
102
+ };
103
+
104
+ const getDefaultNavigationModules = (): Record<string, any> => {
105
+ const navigationModules: Record<string, any[]> = getNavigationModules();
106
+ const defaultHeader = navigationModules.header.find((header: any) => header.defaultNavigation);
107
+ const defaultFooter = navigationModules.footer.find((footer: any) => footer.defaultNavigation);
108
+ return {
109
+ defaultHeader: defaultHeader || navigationModules.header[0],
110
+ defaultFooter: defaultFooter || navigationModules.footer[0],
111
+ };
112
+ };
113
+
114
+ const isMultipleNavigationModules = (): boolean => {
115
+ const navigationModules: Record<string, any[]> = getNavigationModules();
116
+ return navigationModules.header.length > 1 || navigationModules.footer.length > 1;
117
+ };
118
+
93
119
  export {
94
120
  getSchema,
95
121
  getDefaultSchema,
@@ -105,4 +131,7 @@ export {
105
131
  getModuleCategories,
106
132
  getModuleStyles,
107
133
  getDataPackSchema,
134
+ getNavigationModules,
135
+ getDefaultNavigationModules,
136
+ isMultipleNavigationModules,
108
137
  };
@@ -5,7 +5,7 @@ import { Switch, Route } from "react-router-dom";
5
5
  import { ErrorGuard } from "@ax/guards";
6
6
  import { IRootState } from "@ax/types";
7
7
  import { appActions } from "@ax/containers/App";
8
- import { publicRoutes, privateRoutes, routes, IRouter, history } from "@ax/routes";
8
+ import { publicRoutes, privateRoutes, routes, IRouter } from "@ax/routes";
9
9
  import { ILogoutAction } from "@ax/containers/App/interfaces";
10
10
  import NavMenu from "./NavMenu";
11
11
  import PrivateRoute from "./PrivateRoute";