@griddo/ax 11.2.12 → 11.3.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.
Files changed (106) hide show
  1. package/package.json +3 -2
  2. package/src/__tests__/components/SideModal/SideModal.test.tsx +15 -11
  3. package/src/api/images.tsx +17 -2
  4. package/src/api/pages.tsx +49 -2
  5. package/src/api/selects.tsx +7 -5
  6. package/src/components/Browser/index.tsx +8 -1
  7. package/src/components/Button/style.tsx +7 -2
  8. package/src/components/ConfigPanel/Form/ConnectedField/NavConnectedField/index.tsx +6 -3
  9. package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/TemplateManager/index.tsx +8 -3
  10. package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/index.tsx +20 -6
  11. package/src/components/ConfigPanel/NavigationForm/Field/index.tsx +1 -1
  12. package/src/components/ErrorCenter/index.tsx +6 -5
  13. package/src/components/Fields/AsyncSelect/index.tsx +3 -1
  14. package/src/components/Fields/ComponentArray/MixableComponentArray/AddItemButton/index.tsx +1 -1
  15. package/src/components/Fields/ComponentArray/MixableComponentArray/index.tsx +18 -15
  16. package/src/components/Fields/ComponentArray/SameComponentArray/index.tsx +6 -7
  17. package/src/components/Fields/ComponentArray/helpers.tsx +19 -11
  18. package/src/components/Fields/ComponentContainer/EmptyContainer/index.tsx +10 -3
  19. package/src/components/Fields/ComponentContainer/index.tsx +15 -3
  20. package/src/components/Fields/FormContainer/FormModal/index.tsx +217 -0
  21. package/src/components/Fields/FormContainer/FormModal/style.tsx +129 -0
  22. package/src/components/Fields/FormContainer/index.tsx +96 -0
  23. package/src/components/Fields/FormContainer/style.tsx +74 -0
  24. package/src/components/Fields/HiddenField/index.tsx +8 -5
  25. package/src/components/Fields/HiddenField/style.tsx +28 -18
  26. package/src/components/Fields/IntegrationsField/index.tsx +8 -2
  27. package/src/components/Fields/LinkField/index.tsx +1 -1
  28. package/src/components/Fields/TextField/index.tsx +3 -3
  29. package/src/components/Fields/UrlField/utils.tsx +2 -2
  30. package/src/components/Fields/index.tsx +2 -0
  31. package/src/components/FieldsBehavior/index.tsx +7 -4
  32. package/src/components/FileGallery/index.tsx +5 -5
  33. package/src/components/FloatingButton/index.tsx +34 -0
  34. package/src/components/FloatingButton/style.tsx +76 -0
  35. package/src/components/FloatingPanel/style.tsx +1 -2
  36. package/src/components/Gallery/index.tsx +1 -1
  37. package/src/components/MainWrapper/AppBar/index.tsx +2 -2
  38. package/src/components/MainWrapper/index.tsx +2 -2
  39. package/src/components/MainWrapper/style.tsx +1 -0
  40. package/src/components/Modal/index.tsx +3 -3
  41. package/src/components/OcassionalToast/index.tsx +25 -0
  42. package/src/components/OcassionalToast/style.tsx +33 -0
  43. package/src/components/SearchField/index.tsx +4 -3
  44. package/src/components/SideModal/SideModalOption/index.tsx +1 -3
  45. package/src/components/SideModal/index.tsx +67 -44
  46. package/src/components/SideModal/style.tsx +67 -23
  47. package/src/components/TableFilters/CategoryFilter/index.tsx +14 -3
  48. package/src/components/TableFilters/CategoryFilter/style.tsx +2 -2
  49. package/src/components/Toast/index.tsx +6 -4
  50. package/src/components/index.tsx +8 -0
  51. package/src/containers/Forms/actions.tsx +92 -51
  52. package/src/containers/Gallery/actions.tsx +2 -5
  53. package/src/containers/Navigation/Defaults/actions.tsx +6 -4
  54. package/src/containers/Navigation/Defaults/utils.tsx +1 -43
  55. package/src/containers/PageEditor/actions.tsx +53 -34
  56. package/src/containers/PageEditor/reducer.tsx +1 -1
  57. package/src/containers/PageEditor/utils.tsx +22 -9
  58. package/src/forms/editor.tsx +20 -1
  59. package/src/forms/elements.tsx +3 -0
  60. package/src/forms/index.tsx +2 -0
  61. package/src/forms/validators.tsx +56 -33
  62. package/src/helpers/containerEvaluations.tsx +1 -1
  63. package/src/helpers/fields.tsx +1 -1
  64. package/src/helpers/images.tsx +71 -1
  65. package/src/helpers/index.tsx +5 -1
  66. package/src/helpers/schemas.tsx +10 -7
  67. package/src/helpers/themes.tsx +2 -2
  68. package/src/hooks/forms.tsx +2 -2
  69. package/src/hooks/modals.tsx +2 -2
  70. package/src/modules/Categories/CategoriesList/CategoryPanel/index.tsx +4 -7
  71. package/src/modules/Categories/CategoriesList/index.tsx +1 -3
  72. package/src/modules/FileDrive/atoms.tsx +2 -2
  73. package/src/modules/FileDrive/index.tsx +9 -9
  74. package/src/modules/Forms/FormCategoriesList/CategoryItem/index.tsx +30 -10
  75. package/src/modules/Forms/FormCategoriesList/CategoryPanel/index.tsx +1 -0
  76. package/src/modules/Forms/FormCategoriesList/index.tsx +45 -21
  77. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/Field/index.tsx +3 -0
  78. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/TemplateManager/index.tsx +9 -6
  79. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/index.tsx +20 -4
  80. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/index.tsx +17 -2
  81. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/index.tsx +7 -1
  82. package/src/modules/Forms/FormEditor/Editor/index.tsx +8 -2
  83. package/src/modules/Forms/FormEditor/PageBrowser/index.tsx +20 -16
  84. package/src/modules/Forms/FormEditor/PageBrowser/style.tsx +9 -0
  85. package/src/modules/Forms/FormEditor/index.tsx +126 -30
  86. package/src/modules/Forms/FormEditor/style.tsx +1 -1
  87. package/src/modules/Forms/FormList/FormItem/index.tsx +114 -36
  88. package/src/modules/Forms/FormList/FormItem/style.tsx +4 -2
  89. package/src/modules/Forms/FormList/TemplateModal/index.tsx +67 -20
  90. package/src/modules/Forms/FormList/TemplateModal/style.tsx +28 -2
  91. package/src/modules/Forms/FormList/index.tsx +114 -34
  92. package/src/modules/Forms/FormList/style.tsx +10 -2
  93. package/src/modules/Forms/FormUseModal/index.tsx +219 -0
  94. package/src/modules/Forms/FormUseModal/style.tsx +81 -0
  95. package/src/modules/Forms/FormUseModal/utils.tsx +39 -0
  96. package/src/modules/Forms/atoms.tsx +38 -3
  97. package/src/modules/PageEditor/index.tsx +2 -2
  98. package/src/modules/Redirects/index.tsx +10 -12
  99. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/ConfigPanel/NavigationField/index.tsx +1 -1
  100. package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +1 -1
  101. package/src/modules/Users/UserCreate/index.tsx +5 -4
  102. package/src/routes/multisite.tsx +18 -0
  103. package/src/routes/site.tsx +5 -0
  104. package/src/schemas/pages/FormPage.tsx +3 -2
  105. package/src/types/forms.tsx +4 -2
  106. package/src/types/index.tsx +20 -3
@@ -44,6 +44,7 @@ import {
44
44
  getPageData,
45
45
  getPageNavigation,
46
46
  getStateValues,
47
+ protectFormKeys,
47
48
  } from "./utils";
48
49
  import {
49
50
  SET_BREADCRUMB,
@@ -85,6 +86,7 @@ import {
85
86
  IComponent,
86
87
  IModule,
87
88
  IRootState,
89
+ IGetSitePagesParams,
88
90
  } from "@ax/types";
89
91
  import {
90
92
  ISetBreadcrumb,
@@ -266,7 +268,7 @@ const setRootEditorID = (dispatch: Dispatch) => {
266
268
  dispatch(setSelectedEditorID(rootEditorID));
267
269
  };
268
270
 
269
- function generateNewPage(dispatch: Dispatch, getState: any, baseSchema: string) {
271
+ function generateNewPage(dispatch: Dispatch, getState: () => IRootState, baseSchema: string) {
270
272
  const {
271
273
  structuredData: {
272
274
  structuredData: { site },
@@ -307,13 +309,13 @@ function generateNewPage(dispatch: Dispatch, getState: any, baseSchema: string)
307
309
  }
308
310
 
309
311
  // API RELATED ACTIONS
310
- function getPageBreadcrumb(pageId: number): (dispatch: Dispatch, getState: any) => Promise<void> {
312
+ function getPageBreadcrumb(pageId: number): (dispatch: Dispatch, getState: () => IRootState) => Promise<void> {
311
313
  return async (dispatch, getState) => {
312
314
  try {
313
315
  const { selectedEditorID } = getState().pageEditor;
314
316
 
315
317
  const response: { status: number; data: any } = await pages.getPageBreadcrumb(pageId);
316
- if (isReqOk(response.status)) {
318
+ if (isReqOk(response.status) && selectedEditorID) {
317
319
  const { breadcrumb, path } = response.data;
318
320
 
319
321
  updateEditorContent(selectedEditorID, "breadcrumb", breadcrumb)(dispatch, getState);
@@ -325,7 +327,7 @@ function getPageBreadcrumb(pageId: number): (dispatch: Dispatch, getState: any)
325
327
  };
326
328
  }
327
329
 
328
- function getPage(pageID?: number, global?: boolean): (dispatch: Dispatch, getState: any) => Promise<void> {
330
+ function getPage(pageID?: number, global?: boolean): (dispatch: Dispatch, getState: () => IRootState) => Promise<void> {
329
331
  return async (dispatch, getState) => {
330
332
  try {
331
333
  dispatch(setIsLoading(true));
@@ -387,7 +389,7 @@ function getPage(pageID?: number, global?: boolean): (dispatch: Dispatch, getSta
387
389
  };
388
390
  }
389
391
 
390
- function getTemplatePage(template: string): (dispatch: Dispatch, getState: any) => Promise<void> {
392
+ function getTemplatePage(template: string): (dispatch: Dispatch, getState: () => IRootState) => Promise<void> {
391
393
  return async (dispatch, getState) => {
392
394
  try {
393
395
  dispatch(setIsLoading(true));
@@ -473,7 +475,8 @@ function savePage(
473
475
  const { pageContent } = generateEditorIDs({ ...mappedData, header, footer });
474
476
 
475
477
  const isGlobalPage = saveResponse.data.component === "GlobalPage";
476
- !isGlobalPage && (await getPageLanguages(pageID, currentSiteInfo.id, saveResponse.data.entity)(dispatch));
478
+ !isGlobalPage &&
479
+ (await getPageLanguages(pageID, currentSiteInfo?.id || null, saveResponse.data.entity)(dispatch));
477
480
 
478
481
  if (publishPage) {
479
482
  await pages.setPageStatus(publishPage.status, [pageID]);
@@ -510,7 +513,7 @@ function savePage(
510
513
  };
511
514
  }
512
515
 
513
- function deletePage(params?: ISavePageParams): (dispatch: Dispatch, getState: any) => Promise<boolean> {
516
+ function deletePage(params?: ISavePageParams): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
514
517
  return async (dispatch, getState) => {
515
518
  try {
516
519
  const page = getPageData(getState, true, params);
@@ -583,7 +586,7 @@ function updatePageStatus(
583
586
  ids: number[],
584
587
  status: string,
585
588
  updatedFromList?: boolean
586
- ): (dispatch: Dispatch, getState: any) => Promise<boolean> {
589
+ ): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
587
590
  return async (dispatch, getState) => {
588
591
  try {
589
592
  dispatch(setIsSaving(true));
@@ -599,7 +602,7 @@ function updatePageStatus(
599
602
 
600
603
  const pagesWithErrors: number[] = [];
601
604
  if (status === pageStatus.UPLOAD_PENDING && updatedFromList && !skipReviewOnPublish && ids.length > 1) {
602
- const getPagesParams = {
605
+ const getPagesParams: IGetSitePagesParams = {
603
606
  siteID: currentSiteInfo ? currentSiteInfo.id : "global",
604
607
  filterPages: ids,
605
608
  deleted: false,
@@ -637,7 +640,11 @@ function updatePageStatus(
637
640
  };
638
641
  }
639
642
 
640
- function getPageLanguages(pageID: number, siteID: number | null, entity?: string): (dispatch: any) => Promise<void> {
643
+ function getPageLanguages(
644
+ pageID: number,
645
+ siteID: number | null,
646
+ entity?: string
647
+ ): (dispatch: Dispatch) => Promise<void> {
641
648
  return async (dispatch) => {
642
649
  try {
643
650
  const response: any = await pages.getPageLanguages(pageID, siteID, entity);
@@ -690,7 +697,10 @@ function addTemplate(template: string): (dispatch: Dispatch) => Promise<void> {
690
697
  };
691
698
  }
692
699
 
693
- function addComponent(type: IComponent | string, key: string): (dispatch: Dispatch, getState: any) => void {
700
+ function addComponent(
701
+ type: IComponent | string,
702
+ key: string
703
+ ): (dispatch: Dispatch, getState: () => IRootState) => void {
694
704
  return (dispatch, getState) => {
695
705
  const { editorContent, sections, editorID } = getStateValues(getState);
696
706
  const component = {
@@ -727,7 +737,7 @@ function addModule(
727
737
  key: string,
728
738
  selectedID: number,
729
739
  isComponentModule?: boolean
730
- ): (dispatch: Dispatch, getState: any) => void {
740
+ ): (dispatch: Dispatch, getState: () => IRootState) => void {
731
741
  return (dispatch, getState) => {
732
742
  const { editorContent, sections, editorID } = getStateValues(getState);
733
743
 
@@ -773,7 +783,11 @@ function addModule(
773
783
  };
774
784
  }
775
785
 
776
- function replaceModule(module: any, parent: any, objKey: string): (dispatch: Dispatch, getState: any) => void {
786
+ function replaceModule(
787
+ module: any,
788
+ parent: any,
789
+ objKey: string
790
+ ): (dispatch: Dispatch, getState: () => IRootState) => void {
777
791
  return async (dispatch, getState) => {
778
792
  const { editorContent } = getStateValues(getState);
779
793
 
@@ -801,7 +815,7 @@ function replaceModule(module: any, parent: any, objKey: string): (dispatch: Dis
801
815
  function replaceElementsInCollection(
802
816
  newValue: string,
803
817
  reference?: string
804
- ): (dispatch: Dispatch, getState: any) => void {
818
+ ): (dispatch: Dispatch, getState: () => IRootState) => void {
805
819
  return async (dispatch, getState) => {
806
820
  const { selectedContent } = getStateValues(getState);
807
821
 
@@ -815,7 +829,7 @@ function replaceElementsInCollection(
815
829
  };
816
830
  }
817
831
 
818
- function deleteModule(editorID: number[], key?: string): (dispatch: Dispatch, getState: any) => void {
832
+ function deleteModule(editorID: number[], key?: string): (dispatch: Dispatch, getState: () => IRootState) => void {
819
833
  return (dispatch, getState) => {
820
834
  const { sections, editorContent, errors } = getStateValues(getState);
821
835
 
@@ -845,7 +859,7 @@ function deleteModule(editorID: number[], key?: string): (dispatch: Dispatch, ge
845
859
  };
846
860
  }
847
861
 
848
- function duplicateModule(editorID: number[], key?: string): (dispatch: Dispatch, getState: any) => number {
862
+ function duplicateModule(editorID: number[], key?: string): (dispatch: Dispatch, getState: () => IRootState) => number {
849
863
  return (dispatch, getState) => {
850
864
  const { sections, editorContent } = getStateValues(getState);
851
865
 
@@ -891,7 +905,7 @@ function duplicateModule(editorID: number[], key?: string): (dispatch: Dispatch,
891
905
  };
892
906
  }
893
907
 
894
- function copyModule(editorID: number[]): (dispatch: Dispatch, getState: any) => boolean | number {
908
+ function copyModule(editorID: number[]): (dispatch: Dispatch, getState: () => IRootState) => boolean | number {
895
909
  return (dispatch, getState) => {
896
910
  const { sections } = getStateValues(getState);
897
911
  const modulesToCopy: Record<string, unknown>[] = [];
@@ -924,7 +938,7 @@ function pasteModule(
924
938
  editorID: number,
925
939
  key: string,
926
940
  modulesToPaste: IModule[]
927
- ): (dispatch: Dispatch, getState: any) => Promise<{ error?: INotification }> {
941
+ ): (dispatch: Dispatch, getState: () => IRootState) => Promise<{ error?: INotification }> {
928
942
  return async (dispatch, getState) => {
929
943
  const {
930
944
  sites: { currentSiteInfo },
@@ -989,7 +1003,7 @@ function pasteModule(
989
1003
  };
990
1004
  }
991
1005
 
992
- function overwriteHeaderConfig(params: IFieldProps): (dispatch: Dispatch, getState: any) => void {
1006
+ function overwriteHeaderConfig(params: IFieldProps): (dispatch: Dispatch, getState: () => IRootState) => void {
993
1007
  return (dispatch, getState) => {
994
1008
  const {
995
1009
  pageEditor: { editorContent: content },
@@ -1032,7 +1046,7 @@ function generatePageContent(editorContent: IPage): (dispatch: Dispatch, getStat
1032
1046
  const { element: selectedContent, parent: selectedParent } = findByEditorID({ pageContent }, selectedEditorID);
1033
1047
  const { component } = selectedContent;
1034
1048
  const schema = getSchema(component);
1035
-
1049
+ if (!schema) return;
1036
1050
  dispatch(setSchema(schema));
1037
1051
  dispatch(setEditorContent(pageContent));
1038
1052
  dispatch(updateBreadcrumb(selectedEditorID));
@@ -1047,7 +1061,7 @@ function updateEditorContent(
1047
1061
  selectedEditorID: number,
1048
1062
  key: string,
1049
1063
  value: any
1050
- ): (dispatch: Dispatch, getState: any) => void {
1064
+ ): (dispatch: Dispatch, getState: () => IRootState) => void {
1051
1065
  return (dispatch, getState) => {
1052
1066
  const {
1053
1067
  pageEditor: { editorContent, selectedContent, lastTimeout },
@@ -1055,6 +1069,10 @@ function updateEditorContent(
1055
1069
 
1056
1070
  const clonedContent = deepClone(editorContent);
1057
1071
 
1072
+ if (selectedContent.component === "FormPage") {
1073
+ protectFormKeys(clonedContent, key);
1074
+ }
1075
+
1058
1076
  const updatedSelectedContent = updateByEditorID(selectedContent, selectedEditorID, key, value);
1059
1077
  let updatedEditorContent = updateByEditorID(clonedContent, selectedEditorID, key, value);
1060
1078
 
@@ -1079,7 +1097,7 @@ function updateEditorContent(
1079
1097
  };
1080
1098
  }
1081
1099
 
1082
- function setSelectedContent(editorID: number): (dispatch: Dispatch, getState: any) => Promise<void> {
1100
+ function setSelectedContent(editorID: number): (dispatch: Dispatch, getState: () => IRootState) => Promise<void> {
1083
1101
  return async (dispatch, getState) => {
1084
1102
  /*
1085
1103
  We set selectedID in localStorage to have it retrieved
@@ -1119,6 +1137,7 @@ function setSelectedContent(editorID: number): (dispatch: Dispatch, getState: an
1119
1137
  isUpdatedComponent && updateComponent(selectedContent, defaultSchema);
1120
1138
 
1121
1139
  const schema = getSchema(component);
1140
+ if (!schema) return;
1122
1141
  const defaultTab = "content";
1123
1142
  dispatch(setTab(tab || defaultTab));
1124
1143
  dispatch(setSchema(schema));
@@ -1179,7 +1198,7 @@ function moveElement(
1179
1198
  content: any,
1180
1199
  newIndex: number,
1181
1200
  key: string
1182
- ): (dispatch: Dispatch, getState: any) => void {
1201
+ ): (dispatch: Dispatch, getState: () => IRootState) => void {
1183
1202
  return async (dispatch, getState) => {
1184
1203
  try {
1185
1204
  const { editorContent, editorID, selectedContent } = getStateValues(getState);
@@ -1202,7 +1221,7 @@ function moveElement(
1202
1221
  };
1203
1222
  }
1204
1223
 
1205
- function getTemplateConfig(template: string): (dispatch: Dispatch, getState: any) => Promise<void> {
1224
+ function getTemplateConfig(template: string): (dispatch: Dispatch, getState: () => IRootState) => Promise<void> {
1206
1225
  return async (dispatch, getState) => {
1207
1226
  try {
1208
1227
  const {
@@ -1223,7 +1242,7 @@ function getTemplateConfig(template: string): (dispatch: Dispatch, getState: any
1223
1242
  };
1224
1243
  }
1225
1244
 
1226
- function validatePage(publish?: boolean): (dispatch: Dispatch, getState: any) => Promise<boolean> {
1245
+ function validatePage(publish?: boolean): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
1227
1246
  return async (dispatch, getState) => {
1228
1247
  try {
1229
1248
  const { editorContent } = getStateValues(getState);
@@ -1243,7 +1262,7 @@ function validatePage(publish?: boolean): (dispatch: Dispatch, getState: any) =>
1243
1262
 
1244
1263
  const responseActions = {
1245
1264
  handleSuccess: (data: any) => {
1246
- const apiErrors = parseValidationErrors(data, content);
1265
+ const apiErrors: IErrorItem[] = parseValidationErrors(data, content);
1247
1266
  errors = [...errors, ...apiErrors];
1248
1267
  },
1249
1268
  handleError: () => console.log("Error en page check"),
@@ -1285,7 +1304,7 @@ function validatePage(publish?: boolean): (dispatch: Dispatch, getState: any) =>
1285
1304
  };
1286
1305
  }
1287
1306
 
1288
- function deleteError(error: IErrorItem): (dispatch: Dispatch, getState: any) => void {
1307
+ function deleteError(error: IErrorItem): (dispatch: Dispatch, getState: () => IRootState) => void {
1289
1308
  return async (dispatch, getState) => {
1290
1309
  try {
1291
1310
  const { errors } = getState().pageEditor;
@@ -1321,7 +1340,7 @@ function getGlobalFromLocalPage(): (dispatch: Dispatch, getState: any) => Promis
1321
1340
  };
1322
1341
  }
1323
1342
 
1324
- function sendPagePing(pageID: number): (dispatch: Dispatch, getState: any) => Promise<boolean> {
1343
+ function sendPagePing(pageID: number): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
1325
1344
  return async (dispatch, getState) => {
1326
1345
  try {
1327
1346
  const {
@@ -1348,7 +1367,7 @@ function sendPagePing(pageID: number): (dispatch: Dispatch, getState: any) => Pr
1348
1367
  };
1349
1368
  }
1350
1369
 
1351
- function discardDraft(): (dispatch: Dispatch, getState: any) => Promise<void> {
1370
+ function discardDraft(): (dispatch: Dispatch, getState: () => IRootState) => Promise<void> {
1352
1371
  return async (dispatch, getState) => {
1353
1372
  try {
1354
1373
  const page = getPageData(getState, true);
@@ -1369,7 +1388,7 @@ function discardDraft(): (dispatch: Dispatch, getState: any) => Promise<void> {
1369
1388
  };
1370
1389
  }
1371
1390
 
1372
- function removeNavigationFromPage(key: string): (dispatch: Dispatch, getState: any) => void {
1391
+ function removeNavigationFromPage(key: string): (dispatch: Dispatch, getState: () => IRootState) => void {
1373
1392
  return (dispatch, getState) => {
1374
1393
  const {
1375
1394
  pageEditor: { editorContent },
@@ -1380,7 +1399,7 @@ function removeNavigationFromPage(key: string): (dispatch: Dispatch, getState: a
1380
1399
  };
1381
1400
  }
1382
1401
 
1383
- function restorePageNavigation(key: string): (dispatch: Dispatch, getState: any) => void {
1402
+ function restorePageNavigation(key: string): (dispatch: Dispatch, getState: () => IRootState) => void {
1384
1403
  return (dispatch, getState) => {
1385
1404
  const {
1386
1405
  pageEditor: { editorContent },
@@ -1406,7 +1425,7 @@ function restorePageNavigation(key: string): (dispatch: Dispatch, getState: any)
1406
1425
  };
1407
1426
  }
1408
1427
 
1409
- function getPageSummary(): (dispatch: Dispatch, getState: any) => Promise<boolean> {
1428
+ function getPageSummary(): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
1410
1429
  return async (dispatch, getState) => {
1411
1430
  try {
1412
1431
  const {
@@ -1433,7 +1452,7 @@ function getPageSummary(): (dispatch: Dispatch, getState: any) => Promise<boolea
1433
1452
  };
1434
1453
  }
1435
1454
 
1436
- function getPageTranslation(langID: number): (dispatch: Dispatch, getState: any) => Promise<boolean> {
1455
+ function getPageTranslation(langID: number): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
1437
1456
  return async (dispatch, getState) => {
1438
1457
  try {
1439
1458
  const {
@@ -1473,7 +1492,7 @@ function setIsTranslated(isTranslated: boolean): (dispatch: Dispatch) => Promise
1473
1492
  function schedulePublication(
1474
1493
  date: string | null,
1475
1494
  isDraft: boolean
1476
- ): (dispatch: Dispatch, getState: any) => Promise<boolean> {
1495
+ ): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
1477
1496
  return async (dispatch, getState) => {
1478
1497
  try {
1479
1498
  const {
@@ -33,7 +33,7 @@ export interface IPageEditorState {
33
33
  template: string;
34
34
  breadcrumb: IBreadcrumbItem[];
35
35
  schema: ISchema | Record<string, unknown>;
36
- selectedContent: IPage | Record<string, unknown>;
36
+ selectedContent: any;
37
37
  tab: string;
38
38
  selectedEditorID: number | undefined;
39
39
  currentPageID: number | null;
@@ -1,5 +1,5 @@
1
1
  import { IIntegration, ISavePageParams } from "@ax/types";
2
- import { cleanContent } from "@ax/forms";
2
+ import { cleanContent, findByComponent } from "@ax/forms";
3
3
 
4
4
  const getPageParams = (getState: any): ISavePageParams => {
5
5
  const {
@@ -77,19 +77,19 @@ const getPageNavigation = (
77
77
  headerID === 0
78
78
  ? headerID
79
79
  : headerID === undefined || headerID === null
80
- ? headerDefault
81
- : headers.find((content: any) =>
82
- content.navigationLanguages.some((navLang: any) => navLang.navigationId === headerID)
83
- ) || headerDefault;
80
+ ? headerDefault
81
+ : headers.find((content: any) =>
82
+ content.navigationLanguages.some((navLang: any) => navLang.navigationId === headerID)
83
+ ) || headerDefault;
84
84
 
85
85
  const footer =
86
86
  footerID === 0
87
87
  ? footerID
88
88
  : footerID === undefined || footerID === null
89
- ? footerDefault
90
- : footers.find((content: any) =>
91
- content.navigationLanguages.some((navLang: any) => navLang.navigationId === footerID)
92
- ) || footerDefault;
89
+ ? footerDefault
90
+ : footers.find((content: any) =>
91
+ content.navigationLanguages.some((navLang: any) => navLang.navigationId === footerID)
92
+ ) || footerDefault;
93
93
 
94
94
  return { header, footer };
95
95
  };
@@ -123,6 +123,18 @@ const getDefaultPageNavigation = (defaultsContent: any, type: string) => {
123
123
  return navitagion;
124
124
  };
125
125
 
126
+ const protectFormKeys = (content: any, key: string) => {
127
+ const formComponent = findByComponent(content, "FormPage");
128
+ if (!formComponent) return;
129
+
130
+ const protectedKeys = formComponent.protectedKeys || [];
131
+ if (!protectedKeys.includes(key)) {
132
+ formComponent.protectedKeys = [...protectedKeys, key];
133
+ }
134
+
135
+ return content;
136
+ };
137
+
126
138
  export {
127
139
  getPageParams,
128
140
  getPageData,
@@ -130,4 +142,5 @@ export {
130
142
  getPageNavigation,
131
143
  getDefaultIntegrations,
132
144
  getDefaultPageNavigation,
145
+ protectFormKeys,
133
146
  };
@@ -169,10 +169,13 @@ const getParentKey = (parentModule: any, editorID: number) => {
169
169
  };
170
170
 
171
171
  const checkMaxModules = (content: any, type: string): { isMaxModules: boolean; errorMessage?: string } => {
172
- const { maxModulesPerPage } = getSchema(type);
172
+ const schema = getSchema(type);
173
+ const { maxModulesPerPage } = schema || {};
173
174
  const queue: any[] = [content];
174
175
  let counter = 0;
175
176
 
177
+ if (maxModulesPerPage === undefined) return { isMaxModules: false };
178
+
176
179
  while (queue.length > 0 && counter < maxModulesPerPage) {
177
180
  const obj = queue.shift();
178
181
  const currentObj = obj;
@@ -219,6 +222,21 @@ const evaluateComputedFields = async (page: IPage, operation: "save" | "refresh"
219
222
  return updatedPage;
220
223
  };
221
224
 
225
+ function findByComponent(obj: any, componentName: string) {
226
+ if (typeof obj !== "object" || obj === null) return null;
227
+
228
+ if (obj.component === componentName) return obj;
229
+
230
+ for (const key in obj) {
231
+ if (typeof obj[key] === "object") {
232
+ const found: any = findByComponent(obj[key], componentName);
233
+ if (found) return found;
234
+ }
235
+ }
236
+
237
+ return null;
238
+ }
239
+
222
240
  export {
223
241
  parseData,
224
242
  cleanContent,
@@ -234,4 +252,5 @@ export {
234
252
  getParentKey,
235
253
  checkMaxModules,
236
254
  evaluateComputedFields,
255
+ findByComponent,
237
256
  };
@@ -145,7 +145,10 @@ const updateByEditorID = (content: any, editorID: number, contentKey: string, va
145
145
  } else {
146
146
  content[parentKey] = value;
147
147
  }
148
+
149
+ return content;
148
150
  }
151
+
149
152
  for (const key in content) {
150
153
  if (Object.prototype.hasOwnProperty.call(content, key)) {
151
154
  content[key] = updateByEditorID(content[key], editorID, contentKey, value);
@@ -12,6 +12,7 @@ import {
12
12
  getParentKey,
13
13
  checkMaxModules,
14
14
  evaluateComputedFields,
15
+ findByComponent,
15
16
  } from "./editor";
16
17
  import {
17
18
  getUpdatedComponents,
@@ -67,4 +68,5 @@ export {
67
68
  parseValidationErrors,
68
69
  checkMaxModules,
69
70
  evaluateComputedFields,
71
+ findByComponent,
70
72
  };