@griddo/ax 11.10.23 → 11.10.24

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 (58) hide show
  1. package/config/griddo-config/index.js +1 -0
  2. package/package.json +2 -2
  3. package/src/Style/index.tsx +10 -8
  4. package/src/__tests__/components/ConfigPanel/ConfigPanel.test.tsx +10 -8
  5. package/src/__tests__/components/ConfigPanel/Form/ConnectedField/PageConnectedField/PageConnectedField.test.tsx +86 -8
  6. package/src/__tests__/components/SideModal/SideModal.test.tsx +64 -0
  7. package/src/__tests__/hooks/useSchemas.test.tsx +224 -0
  8. package/src/__tests__/services/SchemasService.test.ts +135 -0
  9. package/src/api/schemas.tsx +11 -1
  10. package/src/components/ConfigPanel/GlobalPageForm/index.tsx +11 -17
  11. package/src/components/Fields/Wysiwyg/helpers.tsx +14 -4
  12. package/src/components/Loader/components/Dots.js +4 -5
  13. package/src/components/PageFinder/index.tsx +15 -9
  14. package/src/components/ResizePanel/index.tsx +13 -3
  15. package/src/components/ResizePanel/style.tsx +2 -9
  16. package/src/containers/App/actions.tsx +96 -24
  17. package/src/containers/App/constants.tsx +7 -0
  18. package/src/containers/App/interfaces.tsx +26 -8
  19. package/src/containers/App/reducer.tsx +24 -9
  20. package/src/containers/Sites/actions.tsx +49 -49
  21. package/src/forms/editor.tsx +4 -3
  22. package/src/helpers/index.tsx +76 -94
  23. package/src/helpers/schemas.tsx +144 -36
  24. package/src/helpers/structuredData.tsx +36 -7
  25. package/src/helpers/themes.tsx +26 -8
  26. package/src/hooks/index.tsx +5 -0
  27. package/src/hooks/useSchemas.ts +151 -0
  28. package/src/locales/en-US.ts +1 -0
  29. package/src/locales/es-ES.ts +1 -0
  30. package/src/modules/Analytics/GroupPanel/index.tsx +9 -6
  31. package/src/modules/Analytics/GroupPanel/utils.tsx +12 -28
  32. package/src/modules/Content/PageItem/index.tsx +33 -36
  33. package/src/modules/Content/index.tsx +34 -30
  34. package/src/modules/Content/utils.tsx +16 -12
  35. package/src/modules/Forms/FormEditor/index.tsx +13 -14
  36. package/src/modules/FramePreview/index.tsx +8 -8
  37. package/src/modules/GlobalEditor/index.tsx +57 -42
  38. package/src/modules/MediaGallery/ImageModal/index.tsx +15 -9
  39. package/src/modules/MediaGallery/ImageModal/style.tsx +16 -1
  40. package/src/modules/PublicPreview/index.tsx +4 -3
  41. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/index.tsx +4 -5
  42. package/src/modules/Settings/Globals/index.tsx +10 -11
  43. package/src/modules/Sites/index.tsx +13 -5
  44. package/src/modules/StructuredData/Form/index.tsx +25 -29
  45. package/src/modules/StructuredData/StructuredDataList/OptionTable/index.tsx +15 -6
  46. package/src/modules/StructuredData/StructuredDataList/index.tsx +22 -14
  47. package/src/modules/StructuredData/StructuredDataList/utils.tsx +12 -11
  48. package/src/schemas/index.tsx +5 -4
  49. package/src/schemas/pages/Page.ts +308 -0
  50. package/src/schemas/pages/index.ts +9 -0
  51. package/src/services/SchemasService.ts +240 -0
  52. package/src/services/index.ts +9 -0
  53. package/src/types/index.tsx +48 -39
  54. package/tsconfig.paths.json +1 -0
  55. package/src/schemas/pages/Page.tsx +0 -301
  56. package/src/schemas/pages/index.tsx +0 -5
  57. /package/src/schemas/pages/{FormPage.tsx → FormPage.ts} +0 -0
  58. /package/src/schemas/pages/{GlobalPage.tsx → GlobalPage.ts} +0 -0
@@ -1,9 +1,15 @@
1
- import React, { useState, useRef, useEffect } from "react";
2
- import { connect } from "react-redux";
3
- import { RouteComponentProps } from "react-router-dom";
1
+ import { useEffect, useRef, useState } from "react";
4
2
  import { withErrorBoundary } from "react-error-boundary";
3
+ import { connect } from "react-redux";
4
+ import type { RouteComponentProps } from "react-router-dom";
5
5
 
6
- import {
6
+ import { ErrorPage, ErrorToast, Loading, MainWrapper, Notification, OcassionalToast } from "@ax/components";
7
+ import { appActions } from "@ax/containers/App";
8
+ import { formsActions } from "@ax/containers/Forms";
9
+ import { findFieldsErrors } from "@ax/forms";
10
+ import { RouteLeavingGuard } from "@ax/guards";
11
+ import { useDefaultTheme, useModal, usePermission, useShouldBeSaved } from "@ax/hooks";
12
+ import type {
7
13
  FormContent,
8
14
  FormLanguage,
9
15
  FormState,
@@ -13,17 +19,10 @@ import {
13
19
  IRootState,
14
20
  ISite,
15
21
  } from "@ax/types";
16
- import { MainWrapper, Loading, ErrorToast, Notification, ErrorPage, OcassionalToast } from "@ax/components";
17
- import { appActions } from "@ax/containers/App";
18
- import { formsActions } from "@ax/containers/Forms";
19
- import { RouteLeavingGuard } from "@ax/guards";
20
- import { useModal, usePermission, useShouldBeSaved } from "@ax/hooks";
21
- import { getDefaultTheme } from "@ax/helpers";
22
- import { findFieldsErrors } from "@ax/forms";
23
22
 
24
- import Editor from "./Editor";
25
- import FormUseModal from "../FormUseModal";
26
23
  import { DeleteModal, UnPublishModal, UpdateModal } from "../atoms";
24
+ import FormUseModal from "../FormUseModal";
25
+ import Editor from "./Editor";
27
26
 
28
27
  import * as S from "./style";
29
28
 
@@ -93,7 +92,7 @@ const FormEditor = (props: IProps) => {
93
92
 
94
93
  const toastMsg = "This form is used in some pages. Changes will apply to all pages where it’s in use.";
95
94
  const backLinkRoute = isSiteView ? "/sites/forms" : "/forms";
96
- const theme = getDefaultTheme();
95
+ const { defaultTheme: theme } = useDefaultTheme();
97
96
 
98
97
  // biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
99
98
  useEffect(() => {
@@ -1,13 +1,11 @@
1
- import React from "react";
2
1
  import { connect } from "react-redux";
3
2
 
4
- import { getDefaultTheme } from "@ax/helpers";
5
- import { Loading, BrowserContent } from "@ax/components";
6
- import { FormContent, ILanguage, IRootState, ISite, ISocialState } from "@ax/types";
7
- import { pageEditorActions } from "@ax/containers/PageEditor";
3
+ import { BrowserContent, Loading } from "@ax/components";
8
4
  import { formsActions } from "@ax/containers/Forms";
5
+ import { pageEditorActions } from "@ax/containers/PageEditor";
9
6
  import { findByEditorID } from "@ax/forms";
10
- import { useOnMessageReceivedFromOutside, useURLSearchParam } from "@ax/hooks";
7
+ import { useDefaultTheme, useOnMessageReceivedFromOutside, useURLSearchParam } from "@ax/hooks";
8
+ import type { FormContent, ILanguage, IRootState, ISite, ISocialState } from "@ax/types";
11
9
 
12
10
  import * as S from "./style";
13
11
 
@@ -53,6 +51,7 @@ const FramePreview = (props: IProps) => {
53
51
 
54
52
  const selectEditorID = (
55
53
  selectedComponent: { editorID: number; component: any; type: string; parentEditorID: number },
54
+ // biome-ignore lint/correctness/noUnusedFunctionParameters: TODO: fix this
56
55
  parentComponent: string | undefined | null,
57
56
  e: React.SyntheticEvent,
58
57
  ) => {
@@ -78,7 +77,7 @@ const FramePreview = (props: IProps) => {
78
77
  }
79
78
  };
80
79
 
81
- const globalTheme = getDefaultTheme();
80
+ const { defaultTheme: globalTheme, isLoading: schemasLoading } = useDefaultTheme();
82
81
  const theme = currentSiteInfo ? currentSiteInfo.theme : globalTheme;
83
82
  const langs = currentSiteInfo ? siteLangs : globalLangs;
84
83
  const siteID = currentSiteInfo ? currentSiteInfo.id : canonicalSite;
@@ -100,9 +99,10 @@ const FramePreview = (props: IProps) => {
100
99
  duplicateModuleAction: duplicateModuleSelected,
101
100
  };
102
101
 
103
- if (isLoading) return <Loading />;
102
+ if (isLoading || schemasLoading) return <Loading />;
104
103
 
105
104
  return (
105
+ // biome-ignore lint/suspicious/noAssignInExpressions: TODO: fix this
106
106
  <S.Wrapper ref={(ref: any) => ((window as any).browserRef = ref)}>
107
107
  <BrowserContent
108
108
  cloudinaryName={cloudinaryName}
@@ -1,8 +1,29 @@
1
- import { useEffect, useState, useRef } from "react";
1
+ import { useEffect, useRef, useState } from "react";
2
+ import { withErrorBoundary } from "react-error-boundary";
2
3
  import { connect } from "react-redux";
3
4
  import type { RouteComponentProps } from "react-router-dom";
4
- import { withErrorBoundary } from "react-error-boundary";
5
5
 
6
+ import {
7
+ CancelScheduleModal,
8
+ ErrorPage,
9
+ ErrorToast,
10
+ Loading,
11
+ MainWrapper,
12
+ Modal,
13
+ Notification,
14
+ OcassionalToast,
15
+ RestoreModal,
16
+ ScheduleModal,
17
+ } from "@ax/components";
18
+ import { appActions } from "@ax/containers/App";
19
+ import { pageEditorActions } from "@ax/containers/PageEditor";
20
+ import { pageStatus } from "@ax/containers/PageEditor/interfaces";
21
+ import { sitesActions } from "@ax/containers/Sites";
22
+ import { structuredDataActions } from "@ax/containers/StructuredData";
23
+ import { usersActions } from "@ax/containers/Users";
24
+ import { RouteLeavingGuard } from "@ax/guards";
25
+ import { dateToString } from "@ax/helpers";
26
+ import { useDefaultTheme, useIsDirty, useModal, usePermission } from "@ax/hooks";
6
27
  import type {
7
28
  IErrorItem,
8
29
  ILanguage,
@@ -13,27 +34,6 @@ import type {
13
34
  ISite,
14
35
  IUserEditing,
15
36
  } from "@ax/types";
16
- import {
17
- MainWrapper,
18
- Loading,
19
- ErrorToast,
20
- Notification,
21
- Modal,
22
- ErrorPage,
23
- CancelScheduleModal,
24
- ScheduleModal,
25
- RestoreModal,
26
- OcassionalToast,
27
- } from "@ax/components";
28
- import { pageEditorActions } from "@ax/containers/PageEditor";
29
- import { structuredDataActions } from "@ax/containers/StructuredData";
30
- import { usersActions } from "@ax/containers/Users";
31
- import { appActions } from "@ax/containers/App";
32
- import { sitesActions } from "@ax/containers/Sites";
33
- import { pageStatus } from "@ax/containers/PageEditor/interfaces";
34
- import { RouteLeavingGuard } from "@ax/guards";
35
- import { useIsDirty, useModal, usePermission } from "@ax/hooks";
36
- import { dateToString, getDefaultTheme } from "@ax/helpers";
37
37
 
38
38
  import Editor from "./Editor";
39
39
  import Preview from "./Preview";
@@ -74,7 +74,7 @@ const GlobalEditor = (props: IProps) => {
74
74
  const isAllowedToCreatePages = usePermission("global.globalData.createAllGlobalData");
75
75
  const isAllowedToDeletePage = usePermission("global.globalData.deleteAllGlobalData");
76
76
  const isAllowedToEditContentPage = usePermission("global.globalData.editAllGlobalData");
77
-
77
+ //
78
78
  const defaultTab = isAllowedToEditContentPage ? "edit" : "view";
79
79
 
80
80
  const { isOpen, toggleModal } = useModal();
@@ -85,7 +85,10 @@ const GlobalEditor = (props: IProps) => {
85
85
  const [toastMsg, setToastMsg] = useState<string | null>(null);
86
86
  const { isDirty, setIsDirty, resetDirty } = useIsDirty(editorContent, isNewTranslation);
87
87
  const [errorPagesChecked, setErrorPagesChecked] = useState(false);
88
- const [scheduleDate, setScheduleDate] = useState({ date: dateToString(new Date(), "yyy/MM/dd"), time: "12:00 am" });
88
+ const [scheduleDate, setScheduleDate] = useState({
89
+ date: dateToString(new Date(), "yyy/MM/dd"),
90
+ time: "12:00 am",
91
+ });
89
92
  const { isOpen: isScheduleOpen, toggleModal: toggleScheduleModal } = useModal();
90
93
  const { isOpen: isCancelScheduleOpen, toggleModal: toggleCancelScheduleModal } = useModal();
91
94
  const { isOpen: isRestoreOpen, toggleModal: toggleRestoreModal } = useModal();
@@ -113,7 +116,7 @@ const GlobalEditor = (props: IProps) => {
113
116
 
114
117
  const backLinkRoute = "/data";
115
118
 
116
- const theme = getDefaultTheme();
119
+ const { defaultTheme: theme } = useDefaultTheme();
117
120
 
118
121
  // biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
119
122
  useEffect(() => {
@@ -189,7 +192,7 @@ const GlobalEditor = (props: IProps) => {
189
192
  const isSaved =
190
193
  pageID && !isNewTranslation
191
194
  ? await updatePageStatus([pageID], pageStatus.UPLOAD_PENDING)
192
- : await savePage({ publishPage});
195
+ : await savePage({ publishPage });
193
196
 
194
197
  if (isSaved) {
195
198
  resetDirty();
@@ -209,7 +212,7 @@ const GlobalEditor = (props: IProps) => {
209
212
  status: pageStatus.UPLOAD_PENDING,
210
213
  };
211
214
 
212
- const isSaved = await savePage({publishPage});
215
+ const isSaved = await savePage({ publishPage });
213
216
  if (isSaved) {
214
217
  resetDirty();
215
218
  }
@@ -265,7 +268,7 @@ const GlobalEditor = (props: IProps) => {
265
268
  const handleCreateDraft = async () => {
266
269
  const { savePage } = props;
267
270
 
268
- const isSaved = await savePage({ createDraft: true});
271
+ const isSaved = await savePage({ createDraft: true });
269
272
  if (isSaved) resetDirty();
270
273
  };
271
274
 
@@ -386,10 +389,10 @@ const GlobalEditor = (props: IProps) => {
386
389
  const handleSavePage = async (setToast?: (msg: string) => void) => {
387
390
  const { savePage } = props;
388
391
 
389
- const isSaved = await savePage({setToast});
390
- if (isSaved){
391
- resetDirty();
392
- setToastMsg(null);
392
+ const isSaved = await savePage({ setToast });
393
+ if (isSaved) {
394
+ resetDirty();
395
+ setToastMsg(null);
393
396
  }
394
397
  };
395
398
 
@@ -494,14 +497,20 @@ const GlobalEditor = (props: IProps) => {
494
497
  onClick: handleSchedulePublication,
495
498
  };
496
499
 
497
- const secondaryScheduleModalAction = { title: "Cancel", onClick: toggleScheduleModal };
500
+ const secondaryScheduleModalAction = {
501
+ title: "Cancel",
502
+ onClick: toggleScheduleModal,
503
+ };
498
504
 
499
505
  const mainCancelScheduleModalAction = {
500
506
  title: "Cancel Schedule",
501
507
  onClick: handleCancelSchedulePublication,
502
508
  };
503
509
 
504
- const secondaryCancelScheduleModalAction = { title: "Back", onClick: toggleCancelScheduleModal };
510
+ const secondaryCancelScheduleModalAction = {
511
+ title: "Back",
512
+ onClick: toggleCancelScheduleModal,
513
+ };
505
514
 
506
515
  const tabIcons = isAllowedToEditContentPage
507
516
  ? [
@@ -511,11 +520,11 @@ const GlobalEditor = (props: IProps) => {
511
520
  : [{ name: "view", text: "Preview mode" }];
512
521
 
513
522
  const handleSelectedTab = async (tab: string) => {
514
- if(tab === "view" && (!isPublished || isDraft)){
523
+ if (tab === "view" && (!isPublished || isDraft)) {
515
524
  handleSavePage(setToastMsg);
516
525
  }
517
526
  setSelectedTab(tab);
518
- }
527
+ };
519
528
 
520
529
  const tabsPreview = {
521
530
  icons: tabIcons,
@@ -656,9 +665,8 @@ const GlobalEditor = (props: IProps) => {
656
665
  {isOpen && (
657
666
  <S.ModalContent>
658
667
  <p>
659
- <strong>{userEditing?.name}</strong> is currently working on this page. You can preview
660
- the page but <strong>you cannot make changes to it</strong> until {userEditing?.name}{" "}
661
- leaves the page.
668
+ <strong>{userEditing?.name}</strong> is currently working on this page. You can preview the page but{" "}
669
+ <strong>you cannot make changes to it</strong> until {userEditing?.name} leaves the page.
662
670
  </p>
663
671
  </S.ModalContent>
664
672
  )}
@@ -772,7 +780,12 @@ const mapDispatchToProps = {
772
780
 
773
781
  interface IPageEditorDispatchProps {
774
782
  getPage(pageID?: number, global?: boolean): Promise<void>;
775
- savePage(data?: {createDraft?: boolean; publishPage?: { status: string }; publishDraft?: boolean; setToast?: (msg: string) => void}): Promise<boolean>;
783
+ savePage(data?: {
784
+ createDraft?: boolean;
785
+ publishPage?: { status: string };
786
+ publishDraft?: boolean;
787
+ setToast?: (msg: string) => void;
788
+ }): Promise<boolean>;
776
789
  deletePage(params?: ISavePageParams): Promise<boolean>;
777
790
  validatePage(publish?: boolean): Promise<boolean>;
778
791
  updatePageStatus(id: number[], status: string): Promise<boolean>;
@@ -793,6 +806,8 @@ interface IPageEditorDispatchProps {
793
806
 
794
807
  type IProps = IPageEditorStateProps & IPageEditorDispatchProps & RouteComponentProps;
795
808
 
796
- const GlobalEditorWithErrorBoundary = withErrorBoundary(GlobalEditor, { fallback: <ErrorPage type="wrongEditor" /> });
809
+ const GlobalEditorWithErrorBoundary = withErrorBoundary(GlobalEditor, {
810
+ fallback: <ErrorPage type="wrongEditor" />,
811
+ });
797
812
 
798
813
  export default connect(mapStateToProps, mapDispatchToProps)(GlobalEditorWithErrorBoundary);
@@ -1,11 +1,15 @@
1
- import React, { useState } from "react";
2
- import { IGetFolderParams, IImage } from "@ax/types";
3
- import { Button, ErrorToast, IconAction, Toast, Tooltip } from "@ax/components";
1
+ import { useState } from "react";
2
+
3
+ import { Button, ErrorToast, IconAction, Loader, Toast, Tooltip } from "@ax/components";
4
4
  import { useModal, useToast } from "@ax/hooks";
5
- import ImageDragAndDrop from "../ImageDragAndDrop";
5
+ import type { IGetFolderParams, IImage } from "@ax/types";
6
+
7
+ import { type Fields, GriddoImageExp } from "@griddo/core";
8
+
9
+ import type { IImageFormState } from "..";
6
10
  import { NotSavedModal } from "../atoms";
11
+ import ImageDragAndDrop from "../ImageDragAndDrop";
7
12
  import DetailPanel from "./DetailPanel";
8
- import { IImageFormState } from "..";
9
13
 
10
14
  import * as S from "./style";
11
15
 
@@ -26,7 +30,7 @@ const ImageModal = (props: IProps) => {
26
30
  getParams,
27
31
  } = props;
28
32
 
29
- const { name, id, site, alt, url } = image;
33
+ const { name, id, site } = image;
30
34
 
31
35
  const [isDNDVisible, setDNDVisible] = useState(false);
32
36
  const [isArrowPrev, setIsArrowPrev] = useState(false);
@@ -89,9 +93,11 @@ const ImageModal = (props: IProps) => {
89
93
  <IconAction icon="leftArrow" onClick={handleArrowClick(true)} disabled={index === 0} />
90
94
  <S.FilePreview>
91
95
  <S.ImageWrapper>
92
- <div>
93
- <img src={url} alt={alt} />
94
- </div>
96
+ <S.SpinnerWrapper>
97
+ <Loader name="dots" />
98
+ </S.SpinnerWrapper>
99
+ {/* Fields.Image (Core) y IImage (AX) no son **exactamente** iguales por lo que se ha decidido castearlo (aunque es lo mismo que poner any)...*/}
100
+ <GriddoImageExp key={image.id} image={image as unknown as Fields.Image} widths={["1000"]} />
95
101
  {isDNDVisible && (
96
102
  <S.DragAndDropWrapper>
97
103
  <ImageDragAndDrop
@@ -1,4 +1,4 @@
1
- import styled from "styled-components";
1
+ import styled, { keyframes } from "styled-components";
2
2
 
3
3
  const Wrapper = styled.div`
4
4
  display: flex;
@@ -91,6 +91,20 @@ const DragAndDropWrapper = styled.div`
91
91
  width: 100%;
92
92
  `;
93
93
 
94
+ const fadeIn = keyframes`
95
+ to { opacity: 1; }
96
+ }`;
97
+
98
+ const SpinnerWrapper = styled.div`
99
+ opacity: 0;
100
+ position: absolute;
101
+ top: 50%;
102
+ left: 50%;
103
+ transform: translate(-50%, -50%);
104
+ z-Index: -1;
105
+ animation: ${fadeIn} 1s linear infinite;
106
+ `;
107
+
94
108
  export {
95
109
  Wrapper,
96
110
  FilePreview,
@@ -103,4 +117,5 @@ export {
103
117
  ActionItem,
104
118
  TextType,
105
119
  DragAndDropWrapper,
120
+ SpinnerWrapper,
106
121
  };
@@ -2,8 +2,9 @@ import React, { useEffect, useState } from "react";
2
2
  import { useParams } from "react-router-dom";
3
3
 
4
4
  import { pages } from "@ax/api";
5
- import { getDefaultTheme, isReqOk } from "@ax/helpers";
6
5
  import { BrowserContent, Loading } from "@ax/components";
6
+ import { isReqOk } from "@ax/helpers";
7
+ import { useDefaultTheme } from "@ax/hooks";
7
8
 
8
9
  import * as S from "./style";
9
10
 
@@ -38,13 +39,13 @@ const PublicPreview = () => {
38
39
  };
39
40
  }, []);
40
41
 
41
- const globalTheme = getDefaultTheme();
42
+ const { defaultTheme: globalTheme, isLoading: schemasLoading } = useDefaultTheme();
42
43
  const theme = state && state.site ? state.siteInfo.theme : globalTheme;
43
44
  const socials = state && state.site ? state.siteInfo.socials : [];
44
45
  const langs = state && state.site ? state.siteInfo.siteLanguages : [];
45
46
  const siteID = state && state.siteInfo ? state.siteInfo.siteId : undefined;
46
47
 
47
- if (isLoading || !state) return <Loading />;
48
+ if (isLoading || schemasLoading || !state) return <Loading />;
48
49
 
49
50
  return (
50
51
  <S.Wrapper ref={(ref: any) => ((window as any).browserRef = ref)}>
@@ -1,15 +1,14 @@
1
- import React from "react";
2
1
  import { connect } from "react-redux";
3
2
 
4
3
  import { ResizePanel } from "@ax/components";
5
- import { IRootState } from "@ax/types";
6
- import { getDefaultTheme } from "@ax/helpers";
4
+ import { useDefaultTheme } from "@ax/hooks";
5
+ import type { IRootState } from "@ax/types";
7
6
 
8
- import TemplateBrowser from "./TemplateBrowser";
9
7
  import ConfigPanel from "./ConfigPanel";
8
+ import TemplateBrowser from "./TemplateBrowser";
10
9
 
11
10
  const Editor = (props: IProps) => {
12
- const theme = getDefaultTheme();
11
+ const { defaultTheme: theme } = useDefaultTheme();
13
12
 
14
13
  return <ResizePanel leftPanel={<TemplateBrowser />} rightPanel={<ConfigPanel theme={theme} {...props} />} />;
15
14
  };
@@ -1,19 +1,17 @@
1
- import React, { useState } from "react";
1
+ import { useState } from "react";
2
2
  import { connect } from "react-redux";
3
- import { config } from "components";
4
3
 
5
- const themes = config.schemas.config.themes;
6
-
7
- import { IGriddoTheme, IImage, INavItem, IRootState, ISettingsForm } from "@ax/types";
8
- import { RouteLeavingGuard } from "@ax/guards";
9
- import { useModal, useShouldBeSaved } from "@ax/hooks";
4
+ import { ErrorToast, FieldGroup, FieldsBehavior, MainWrapper, Modal, Nav, Notification } from "@ax/components";
10
5
  import { appActions } from "@ax/containers/App";
11
- import { FieldsBehavior, FieldGroup, MainWrapper, ErrorToast, Nav, Notification, Modal } from "@ax/components";
12
6
  import { sitesActions } from "@ax/containers/Sites";
7
+ import { RouteLeavingGuard } from "@ax/guards";
13
8
  import { getNavigationModules } from "@ax/helpers";
9
+ import { useModal, useShouldBeSaved, useThemes } from "@ax/hooks";
10
+ import type { IImage, INavItem, IRootState, ISettingsForm } from "@ax/types";
14
11
 
15
- import NavigationModules from "./NavigationModules";
16
12
  import { timezones } from "./constants";
13
+ import NavigationModules from "./NavigationModules";
14
+
17
15
  import * as S from "./style";
18
16
 
19
17
  const Globals = (props: IProps): JSX.Element => {
@@ -22,6 +20,7 @@ const Globals = (props: IProps): JSX.Element => {
22
20
  const [isNavigationNotificationOpen, setIsNavigationNotificationOpen] = useState(false);
23
21
  const [tempTheme, setTempTheme] = useState<string | undefined>();
24
22
  const { isOpen, toggleModal } = useModal();
23
+ const { themes } = useThemes();
25
24
 
26
25
  const title = "General settings";
27
26
 
@@ -43,8 +42,8 @@ const Globals = (props: IProps): JSX.Element => {
43
42
  const setNameValue = (value: string) => setValue({ name: value });
44
43
  const setTimezoneValue = (value: string) => setValue({ timezone: value });
45
44
  const setThemeValue = (value: string) => {
46
- const theme = (themes as IGriddoTheme[]).find((th) => th.value === value);
47
- if (theme && theme.elements) {
45
+ const theme = themes?.find((theme) => theme.value === value);
46
+ if (theme?.elements) {
48
47
  setTempTheme(value);
49
48
  toggleModal();
50
49
  } else {
@@ -1,14 +1,14 @@
1
- import React, { useLayoutEffect } from "react";
2
-
1
+ import { useLayoutEffect } from "react";
3
2
  import { connect } from "react-redux";
4
- import { withRouter, RouteComponentProps } from "react-router-dom";
3
+ import { type RouteComponentProps, withRouter } from "react-router-dom";
5
4
 
6
- import { IGetRoles, ILanguage, IRootState, ISite } from "@ax/types";
7
5
  import { appActions } from "@ax/containers/App";
8
- import { sitesActions } from "@ax/containers/Sites";
9
6
  import { dataPacksActions } from "@ax/containers/Settings/DataPacks";
7
+ import { sitesActions } from "@ax/containers/Sites";
10
8
  import { structuredDataActions } from "@ax/containers/StructuredData";
11
9
  import { usersActions } from "@ax/containers/Users";
10
+ import { schemasService } from "@ax/services";
11
+ import type { IGetRoles, ILanguage, IRootState, ISite } from "@ax/types";
12
12
 
13
13
  import SitesList from "./SitesList";
14
14
 
@@ -25,12 +25,18 @@ const Sites = (props: ISitesProps): JSX.Element => {
25
25
  updateCurrentSearch,
26
26
  resetCurrentData,
27
27
  setIsLoading,
28
+ loadSchemas,
28
29
  } = props;
29
30
 
30
31
  // biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
31
32
  useLayoutEffect(() => {
32
33
  const fetchInitialData = async () => {
33
34
  setIsLoading(true);
35
+
36
+ // Cargar schemas primero (después del login)
37
+ await loadSchemas();
38
+ console.log("------------SCHEMAS LOADED-----------");
39
+
34
40
  setCurrentSiteInfo(null);
35
41
  updateCurrentSearch("");
36
42
  resetCurrentData();
@@ -78,6 +84,7 @@ interface IDispatchProps {
78
84
  updateCurrentSearch(query: string): Promise<void>;
79
85
  resetCurrentData(): Promise<void>;
80
86
  setIsLoading(isLoading: boolean): void;
87
+ loadSchemas(): Promise<boolean>;
81
88
  }
82
89
 
83
90
  export type ISitesProps = IStateProps & IDispatchProps & RouteComponentProps;
@@ -92,6 +99,7 @@ const mapDispatchToProps = {
92
99
  updateCurrentSearch: structuredDataActions.updateCurrentSearch,
93
100
  resetCurrentData: structuredDataActions.resetCurrentData,
94
101
  setIsLoading: appActions.setIsLoading,
102
+ loadSchemas: appActions.loadSchemas,
95
103
  };
96
104
 
97
105
  export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Sites));
@@ -1,7 +1,23 @@
1
- import React, { useEffect, useState } from "react";
1
+ import { useEffect, useState } from "react";
2
2
  import { connect } from "react-redux";
3
3
 
4
4
  import {
5
+ CancelScheduleModal,
6
+ ErrorToast,
7
+ Loading,
8
+ MainWrapper,
9
+ Notification,
10
+ RestoreModal,
11
+ ScheduleModal,
12
+ } from "@ax/components";
13
+ import { appActions } from "@ax/containers/App";
14
+ import { dataPacksActions } from "@ax/containers/Settings/DataPacks";
15
+ import { structuredDataActions } from "@ax/containers/StructuredData";
16
+ import { setIsSavedData } from "@ax/forms";
17
+ import { RouteLeavingGuard } from "@ax/guards";
18
+ import { dateToString, getActivatedDataPacksIds } from "@ax/helpers";
19
+ import { useDefaultTheme, useIsDirty, useModal } from "@ax/hooks";
20
+ import type {
5
21
  IDataLanguage,
6
22
  IDataPack,
7
23
  IErrorItem,
@@ -11,22 +27,6 @@ import {
11
27
  ISchemaField,
12
28
  ISite,
13
29
  } from "@ax/types";
14
- import { structuredDataActions } from "@ax/containers/StructuredData";
15
- import {
16
- MainWrapper,
17
- ErrorToast,
18
- Notification,
19
- Loading,
20
- CancelScheduleModal,
21
- ScheduleModal,
22
- RestoreModal,
23
- } from "@ax/components";
24
- import { dateToString, getActivatedDataPacksIds, getDefaultTheme } from "@ax/helpers";
25
- import { appActions } from "@ax/containers/App";
26
- import { RouteLeavingGuard } from "@ax/guards";
27
- import { useIsDirty, useModal } from "@ax/hooks";
28
- import { setIsSavedData } from "@ax/forms";
29
- import { dataPacksActions } from "@ax/containers/Settings/DataPacks";
30
30
 
31
31
  import ConnectedField from "./ConnectedField";
32
32
 
@@ -108,7 +108,7 @@ const Form = (props: IProps) => {
108
108
  const deletedNotificationText =
109
109
  "This content type has been deleted and can’t be edited. It will be permanently removed from the trash after 30 days.";
110
110
 
111
- const theme = getDefaultTheme();
111
+ const { defaultTheme: theme } = useDefaultTheme();
112
112
 
113
113
  // biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
114
114
  useEffect(() => {
@@ -180,17 +180,13 @@ const Form = (props: IProps) => {
180
180
 
181
181
  const getCurrentLanguages = () => {
182
182
  const availables: ILanguage[] = [];
183
-
184
- form?.dataLanguages &&
185
- form.dataLanguages.forEach(
186
- (dataLang: IDataLanguage) =>
187
- languages &&
188
- languages.forEach((language) => {
189
- if (language.id === dataLang.language) {
190
- availables.push(language);
191
- }
192
- }),
193
- );
183
+ form?.dataLanguages?.forEach((dataLang: IDataLanguage) => {
184
+ languages?.forEach((language) => {
185
+ if (language.id === dataLang.language) {
186
+ availables.push(language);
187
+ }
188
+ });
189
+ });
194
190
 
195
191
  return availables;
196
192
  };
@@ -1,11 +1,20 @@
1
- import React, { useReducer, useEffect } from "react";
1
+ import { useEffect, useReducer } from "react";
2
2
 
3
- import { IStructuredDataFilter, IStructuredDataValue } from "@ax/types";
4
- import { getDefaultTheme, getThumbnailProps } from "@ax/helpers";
5
3
  import { MenuItem, RadioGroup } from "@ax/components";
4
+ import { getThumbnailProps } from "@ax/helpers";
5
+ import { useDefaultTheme } from "@ax/hooks";
6
+ import type { IStructuredDataFilter, IStructuredDataValue } from "@ax/types";
7
+
8
+ import { MainActionButton, SecondaryActionButton } from "./../atoms";
9
+ import {
10
+ type IOptionTableStore,
11
+ reducer,
12
+ setColumnValues,
13
+ setOption,
14
+ setSelectedType,
15
+ setShowThumbnail,
16
+ } from "./store";
6
17
 
7
- import { reducer, IOptionTableStore, setColumnValues, setShowThumbnail, setSelectedType, setOption } from "./store";
8
- import { SecondaryActionButton, MainActionButton } from "./../atoms";
9
18
  import * as S from "./style";
10
19
 
11
20
  const OptionTable = (props: IOptionTableProps): JSX.Element => {
@@ -48,7 +57,7 @@ const OptionTable = (props: IOptionTableProps): JSX.Element => {
48
57
  return columns.includes(optionValues[0]);
49
58
  };
50
59
 
51
- const theme = getDefaultTheme();
60
+ const { defaultTheme: theme } = useDefaultTheme();
52
61
 
53
62
  const thumbnailProps =
54
63
  state.showThumbnail &&