@griddo/ax 11.13.2 → 11.13.3-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/config/jest/setup.js +10 -0
  2. package/package.json +2 -2
  3. package/src/GlobalStore.tsx +1 -1
  4. package/src/__tests__/components/Fields/AsyncCheckGroup/AsyncCheckGroup.test.tsx +276 -66
  5. package/src/__tests__/components/FloatingMenu/FloatingMenu.test.tsx +300 -99
  6. package/src/__tests__/modules/Settings/Social/Social.test.tsx +12 -4
  7. package/src/api/checkgroups.tsx +4 -3
  8. package/src/api/selects.tsx +12 -5
  9. package/src/components/ActionMenu/index.tsx +1 -3
  10. package/src/components/Browser/index.tsx +12 -3
  11. package/src/components/Browser/style.tsx +7 -0
  12. package/src/components/ConfigPanel/Form/index.tsx +47 -53
  13. package/src/components/Fields/AnalyticsField/PageAnalytics/atoms.tsx +9 -13
  14. package/src/components/Fields/AnalyticsField/PageAnalytics/index.tsx +37 -29
  15. package/src/components/Fields/AnalyticsField/StructuredDataAnalytics/atoms.tsx +9 -13
  16. package/src/components/Fields/AnalyticsField/StructuredDataAnalytics/index.tsx +17 -11
  17. package/src/components/Fields/AnalyticsField/index.tsx +1 -2
  18. package/src/components/Fields/AnalyticsField/utils.tsx +4 -4
  19. package/src/components/Fields/AsyncCheckGroup/index.tsx +97 -79
  20. package/src/components/Fields/AsyncSelect/index.tsx +33 -22
  21. package/src/components/Fields/DateField/DatePickerInput/index.tsx +2 -2
  22. package/src/components/Fields/DateField/index.tsx +3 -3
  23. package/src/components/Fields/IntegrationsField/SideModal/index.tsx +2 -2
  24. package/src/components/Fields/IntegrationsField/index.tsx +14 -10
  25. package/src/components/Fields/MultiCheckSelect/index.tsx +6 -6
  26. package/src/components/Fields/MultiCheckSelectGroup/index.tsx +39 -37
  27. package/src/components/Fields/MultiCheckSelectGroup/style.tsx +1 -1
  28. package/src/components/Fields/ReferenceField/ManualPanel/index.tsx +0 -2
  29. package/src/components/Fields/RichText/index.tsx +15 -7
  30. package/src/components/Fields/TextArea/index.tsx +9 -6
  31. package/src/components/FloatingMenu/index.tsx +32 -31
  32. package/src/components/FloatingMenu/style.tsx +23 -5
  33. package/src/components/Loader/components/SmallCircle.js +3 -3
  34. package/src/components/MainWrapper/AppBar/style.tsx +1 -0
  35. package/src/components/SideModal/index.tsx +1 -1
  36. package/src/components/TableFilters/CategoryFilter/index.tsx +14 -15
  37. package/src/containers/App/actions.tsx +7 -1
  38. package/src/containers/App/constants.tsx +2 -0
  39. package/src/containers/App/interfaces.tsx +5 -0
  40. package/src/containers/App/reducer.tsx +11 -2
  41. package/src/containers/Forms/actions.tsx +5 -7
  42. package/src/containers/Integrations/actions.tsx +1 -3
  43. package/src/containers/Navigation/Menu/actions.tsx +2 -2
  44. package/src/containers/PageEditor/actions.tsx +3 -2
  45. package/src/containers/Settings/DataPacks/actions.tsx +35 -29
  46. package/src/containers/Sites/actions.tsx +40 -33
  47. package/src/containers/StructuredData/actions.tsx +3 -9
  48. package/src/modules/ActivityLog/LogFilters/DateFilter/index.tsx +5 -4
  49. package/src/modules/Content/NewContentModal/PageImporter/index.tsx +1 -2
  50. package/src/modules/Content/index.tsx +8 -3
  51. package/src/modules/Content/style.tsx +7 -0
  52. package/src/modules/Navigation/Defaults/DefaultsEditor/index.tsx +58 -45
  53. package/src/modules/Navigation/Defaults/index.tsx +103 -104
  54. package/src/modules/PageEditor/index.tsx +9 -1
  55. package/src/modules/PublicPreview/index.tsx +2 -1
  56. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/index.tsx +60 -44
  57. package/src/modules/Settings/ContentTypes/DataPacks/Config/index.tsx +32 -37
  58. package/src/modules/Sites/index.tsx +3 -3
  59. package/src/modules/Users/UserList/index.tsx +1 -1
@@ -1,13 +1,16 @@
1
- import React, { useState, useEffect, memo, useRef } from "react";
1
+ import type React from "react";
2
+ import { memo, useEffect, useRef, useState } from "react";
2
3
  import { Editor } from "react-draft-wysiwyg";
3
- import { EditorState, convertFromRaw, convertToRaw, ContentState } from "draft-js";
4
- import { markdownToDraft, draftToMarkdown } from "markdown-draft-js";
4
+
5
+ import { ContentState, convertFromRaw, convertToRaw, EditorState } from "draft-js";
6
+ import { stateFromHTML } from "draft-js-import-html";
5
7
  import draftToHtml from "draftjs-to-html";
6
8
  import htmlToDraft from "html-to-draftjs";
7
- import { stateFromHTML } from "draft-js-import-html";
8
- import { formatIframe } from "./utils";
9
+ import { draftToMarkdown, markdownToDraft } from "markdown-draft-js";
9
10
  import "react-draft-wysiwyg/dist/react-draft-wysiwyg.css";
10
11
 
12
+ import { formatIframe } from "./utils";
13
+
11
14
  import * as S from "./style";
12
15
 
13
16
  const RichText = (props: IRichTextProps): JSX.Element => {
@@ -32,6 +35,7 @@ const RichText = (props: IRichTextProps): JSX.Element => {
32
35
 
33
36
  const [editorState, setEditorState] = useState(() => EditorState.createWithContent(contentState));
34
37
  const timeOutRef = useRef<ReturnType<typeof setTimeout>>();
38
+ const isMountRef = useRef(true);
35
39
 
36
40
  // biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
37
41
  useEffect(() => {
@@ -43,6 +47,10 @@ const RichText = (props: IRichTextProps): JSX.Element => {
43
47
 
44
48
  // biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
45
49
  useEffect(() => {
50
+ if (isMountRef.current) {
51
+ isMountRef.current = false;
52
+ return;
53
+ }
46
54
  if (delayed !== false) {
47
55
  timeOutRef.current && clearTimeout(timeOutRef.current);
48
56
  timeOutRef.current = setTimeout(() => {
@@ -77,9 +85,9 @@ const RichText = (props: IRichTextProps): JSX.Element => {
77
85
  return false;
78
86
  };
79
87
 
80
- const handleOnBlur = (event: React.FocusEvent<HTMLTextAreaElement>, editorState: EditorState) => {
88
+ const handleOnBlur = (_event: React.FocusEvent<HTMLTextAreaElement>, editorState: EditorState) => {
81
89
  const plainContent = editorState.getCurrentContent().getPlainText();
82
- handleValidation && handleValidation(plainContent, validators);
90
+ handleValidation?.(plainContent, validators);
83
91
  };
84
92
 
85
93
  const toolbar = {
@@ -1,4 +1,5 @@
1
- import React, { memo, useEffect, useRef, useState } from "react";
1
+ import type React from "react";
2
+ import { memo, useEffect, useRef, useState } from "react";
2
3
 
3
4
  import * as S from "./style";
4
5
 
@@ -10,10 +11,12 @@ const TextArea = (props: ITextAreaProps): JSX.Element => {
10
11
 
11
12
  // biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
12
13
  useEffect(() => {
13
- timeOutRef.current && clearTimeout(timeOutRef.current);
14
- timeOutRef.current = setTimeout(() => {
15
- delayedChange();
16
- }, 300);
14
+ if (state !== value) {
15
+ timeOutRef.current && clearTimeout(timeOutRef.current);
16
+ timeOutRef.current = setTimeout(() => {
17
+ delayedChange();
18
+ }, 300);
19
+ }
17
20
  }, [state]);
18
21
 
19
22
  // biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
@@ -31,7 +34,7 @@ const TextArea = (props: ITextAreaProps): JSX.Element => {
31
34
  };
32
35
 
33
36
  const handleOnBlur = (e: React.FocusEvent<HTMLTextAreaElement>) => {
34
- handleValidation && handleValidation(e.target.value);
37
+ handleValidation?.(e.target.value);
35
38
  };
36
39
 
37
40
  return (
@@ -1,10 +1,12 @@
1
1
  import type React from "react";
2
- import { useEffect, useRef, useState } from "react";
2
+ import { useCallback, useLayoutEffect, useRef, useState, type ReactNode } from "react";
3
3
 
4
4
  import { useHandleClickOutside } from "@ax/hooks";
5
5
 
6
6
  import * as S from "./style";
7
7
 
8
+ const CLOSED_POSITION = { openUpward: false, leftwardOffset: 0, isVisible: false };
9
+
8
10
  const FloatingMenu = (props: IFloatingProps): JSX.Element => {
9
11
  const {
10
12
  children,
@@ -24,43 +26,37 @@ const FloatingMenu = (props: IFloatingProps): JSX.Element => {
24
26
  const buttonRef = useRef<HTMLDivElement | null>(null);
25
27
  const menuOptionsRef = useRef<HTMLDivElement | null>(null);
26
28
  const [isOpen, setOpen] = useState(false);
29
+ const [menuPosition, setMenuPosition] = useState(CLOSED_POSITION);
27
30
 
28
- useEffect(() => {
29
- if (isOpen && menuOptionsRef?.current) {
30
- const bounding = menuOptionsRef.current.children[0].getBoundingClientRect();
31
- const boundingChild = menuOptionsRef.current.children[0]?.getBoundingClientRect();
32
- if (bounding.bottom > (window.innerHeight || document.documentElement.clientHeight)) {
33
- menuOptionsRef.current.scrollIntoView({ block: "end", behavior: "smooth" });
34
- }
35
- if (boundingChild && boundingChild.right > window.innerWidth) {
36
- menuOptionsRef.current.style.right = "130px";
37
- }
38
- }
31
+ useLayoutEffect(() => {
32
+ if (!isOpen || !menuOptionsRef.current) return;
33
+
34
+ const bounding = menuOptionsRef.current.getBoundingClientRect();
35
+ const openUpward = bounding.bottom > document.documentElement.clientHeight;
36
+ const rightOverflow = bounding.right - document.documentElement.clientWidth;
37
+ const leftwardOffset = rightOverflow > 0 ? rightOverflow : 0;
38
+
39
+ setMenuPosition({ openUpward, leftwardOffset, isVisible: true });
39
40
  }, [isOpen]);
40
41
 
42
+ const closeMenu = useCallback(() => {
43
+ actionOnClose?.();
44
+ setOpen(false);
45
+ setMenuPosition(CLOSED_POSITION);
46
+ }, [actionOnClose]);
47
+
41
48
  const handleClickOutside = (e: MouseEvent) => {
42
49
  if (wrapperRef.current?.contains(e.target as HTMLElement)) {
43
50
  return;
44
51
  }
45
52
 
46
- if (actionOnClose) {
47
- actionOnClose();
48
- }
49
-
50
- setOpen(false);
53
+ closeMenu();
51
54
  };
52
55
 
53
56
  const closeWhenChecked = (e: React.MouseEvent<HTMLDivElement>) => {
54
57
  const target = e.target as HTMLInputElement;
55
58
  const isChecked = target?.checked;
56
- isChecked && setOpen(false);
57
- };
58
-
59
- const closeWhenApply = (e: React.MouseEvent<HTMLDivElement>) => {
60
- const target = e.target as HTMLSpanElement;
61
- if (target.innerHTML === "Apply") {
62
- setOpen(false);
63
- }
59
+ isChecked && closeMenu();
64
60
  };
65
61
 
66
62
  const handleClick = (e: React.MouseEvent<HTMLDivElement>) => {
@@ -70,20 +66,22 @@ const FloatingMenu = (props: IFloatingProps): JSX.Element => {
70
66
  const optionWasSelected = isOpen && menuOptionsRef.current?.contains(e.target as HTMLElement);
71
67
 
72
68
  if (buttonWasClicked) {
73
- setOpen(!isOpen);
69
+ isOpen ? closeMenu() : setOpen(true);
74
70
  }
75
71
 
76
72
  if (optionWasSelected) {
77
- closeOnSelect ? (isCheckGroup ? closeWhenChecked(e) : setOpen(!isOpen)) : setOpen(true);
73
+ if ((e.target as HTMLElement).closest("[data-close-menu]")) {
74
+ closeMenu();
75
+ } else {
76
+ closeOnSelect ? (isCheckGroup ? closeWhenChecked(e) : closeMenu()) : setOpen(true);
77
+ }
78
78
  }
79
-
80
- closeWhenApply(e);
81
79
  };
82
80
 
83
81
  const handleMouseEnter = (e: React.MouseEvent<HTMLDivElement>) =>
84
82
  reactiveToHover && !isOpen ? handleClick(e) : null;
85
83
 
86
- const handleMouseLeave = () => reactiveToHover && isOpen && setOpen(false);
84
+ const handleMouseLeave = () => reactiveToHover && isOpen && closeMenu();
87
85
 
88
86
  useHandleClickOutside(isOpen, handleClickOutside);
89
87
 
@@ -105,6 +103,9 @@ const FloatingMenu = (props: IFloatingProps): JSX.Element => {
105
103
  ref={menuOptionsRef}
106
104
  position={position}
107
105
  offset={offset}
106
+ openUpward={menuPosition.openUpward}
107
+ leftwardOffset={menuPosition.leftwardOffset}
108
+ isVisible={menuPosition.isVisible}
108
109
  data-testid="floating-menu-wrapper"
109
110
  >
110
111
  <S.Menu hasMargin={hasMargin} width={fixedWidth}>
@@ -117,7 +118,7 @@ const FloatingMenu = (props: IFloatingProps): JSX.Element => {
117
118
  };
118
119
 
119
120
  export interface IFloatingProps {
120
- children: JSX.Element | (JSX.Element | boolean | JSX.Element[])[] | boolean;
121
+ children: ReactNode;
121
122
  Button: (props?: any) => React.JSX.Element;
122
123
  isInAppBar?: boolean;
123
124
  position?: string;
@@ -1,6 +1,8 @@
1
1
  import styled from "styled-components";
2
2
 
3
- const Wrapper = styled.div``;
3
+ const Wrapper = styled.div`
4
+ position: relative;
5
+ `;
4
6
 
5
7
  const ButtonWrapper = styled.div`
6
8
  display: flex;
@@ -8,12 +10,28 @@ const ButtonWrapper = styled.div`
8
10
  cursor: pointer;
9
11
  `;
10
12
 
11
- const MenuWrapper = styled.div<{ isInAppBar?: boolean; position: string; offset?: number }>`
13
+ const MenuWrapper = styled.div<{
14
+ isInAppBar?: boolean;
15
+ position: string;
16
+ offset?: number;
17
+ openUpward?: boolean;
18
+ leftwardOffset?: number;
19
+ isVisible?: boolean;
20
+ }>`
21
+ && {
22
+ max-width: initial;
23
+ }
12
24
  position: absolute;
13
25
  z-index: 7;
14
- padding-top: ${(p) => (p.isInAppBar ? p.theme.spacing.s : p.theme.spacing.xs)};
15
- margin-right: ${(p) => (p.isInAppBar ? p.theme.spacing.s : "0")};
16
- ${(p) => p.position}: ${(p) => (p.offset ? `${p.offset}px` : "0")};
26
+ visibility: ${(p) => (p.isVisible ? "visible" : "hidden")};
27
+ ${(p) =>
28
+ p.leftwardOffset
29
+ ? `right: ${p.leftwardOffset}px; left: auto;`
30
+ : `${p.position}: ${p.offset ? `${p.offset}px` : "0"};`}
31
+ ${(p) =>
32
+ p.openUpward
33
+ ? `bottom: 100%; padding-bottom: ${p.theme.spacing.xs};`
34
+ : `top: 100%; padding-top: ${p.isInAppBar ? p.theme.spacing.s : p.theme.spacing.xs};`}
17
35
  `;
18
36
 
19
37
  const Menu = styled.div<{ hasMargin: boolean; width?: number }>`
@@ -8,9 +8,9 @@ function SvgSmallCircle(props) {
8
8
  r="40"
9
9
  fill="none"
10
10
  stroke="#5057FF"
11
- stroke-width="10"
12
- stroke-linecap="round"
13
- stroke-dasharray="200 300"
11
+ strokeWidth="10"
12
+ strokeLinecap="round"
13
+ strokeDasharray="200 300"
14
14
  >
15
15
  <animateTransform
16
16
  attributeName="transform"
@@ -144,6 +144,7 @@ const Header = styled.section<{ inversed?: boolean }>`
144
144
  padding-right: ${(p) => p.theme.spacing.s};
145
145
  margin-bottom: 1px;
146
146
  border-bottom: ${(p) => `1px solid ${p.theme.color.uiLine}`};
147
+ min-width: 1280px;
147
148
 
148
149
  button:first-child {
149
150
  margin-left: ${(p) => p.theme.spacing.m};
@@ -138,7 +138,7 @@ const SideModal = (props: ISideModalProps): JSX.Element | null => {
138
138
  return getCategoryItem(category, i);
139
139
  });
140
140
 
141
- const filteredOptions = options.options?.map((option) => {
141
+ const filteredOptions = options.options?.map((option, i) => {
142
142
  const optionComponent = typeof option === "string" ? option : option.component;
143
143
  const optionKey = typeof option === "string" ? option : (option.id ?? option.editorID ?? optionComponent);
144
144
  const displayName = getDisplayName(optionComponent);
@@ -1,9 +1,9 @@
1
- import React, { useEffect, useState } from "react";
1
+ import { useEffect, useState } from "react";
2
2
 
3
3
  import { CheckGroup, FloatingMenu, Icon, ListTitle } from "@ax/components";
4
4
  import { areEquals, isReqOk, trimText } from "@ax/helpers";
5
5
  import { checkgroups } from "@ax/api";
6
- import { IFilterValue, IQueryValue } from "@ax/types";
6
+ import type { IFilterValue, IQueryValue } from "@ax/types";
7
7
 
8
8
  import * as S from "./style";
9
9
 
@@ -52,24 +52,23 @@ const CategoryFilter = (props: ICategoryFilterProps): JSX.Element => {
52
52
  console.log(e);
53
53
  }
54
54
  setIsLoading(false);
55
- return false;
55
+ return [];
56
56
  };
57
57
 
58
58
  // biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
59
59
  useEffect(() => {
60
60
  getSelectCategories().then((items) => {
61
- items &&
62
- items.forEach((item: { value: string; title: string }) => {
63
- if (hideValues.includes(item.value)) {
64
- setHideFilter(true);
65
- }
66
- const newFilter = {
67
- name: item.value,
68
- value: item.value,
69
- title: item.title,
70
- };
71
- filters.push(newFilter);
72
- });
61
+ items?.forEach((item: { value: string; title: string }) => {
62
+ if (hideValues.includes(item.value)) {
63
+ setHideFilter(true);
64
+ }
65
+ const newFilter = {
66
+ name: item.value,
67
+ value: item.value,
68
+ title: item.title,
69
+ };
70
+ filters.push(newFilter);
71
+ });
73
72
  setOptions(filters);
74
73
  });
75
74
  }, [siteID]);
@@ -11,6 +11,7 @@ import history from "../../routes/history";
11
11
  import {
12
12
  IS_LOGGING_IN,
13
13
  LOGOUT,
14
+ RESET_LOADING,
14
15
  SET_ERROR,
15
16
  SET_GLOBAL_LANGUAGES,
16
17
  SET_GLOBAL_SETTINGS,
@@ -25,6 +26,7 @@ import {
25
26
  import type {
26
27
  IIsLoggingInAction,
27
28
  ILogoutAction,
29
+ IResetLoading,
28
30
  ISetErrorAction,
29
31
  ISetGlobalLanguages,
30
32
  ISetGlobalSettings,
@@ -50,8 +52,12 @@ function setHasAnimation(hasAnimation: boolean): ISetHasAnimation {
50
52
  return { type: SET_HAS_ANIMATION, payload: { hasAnimation } };
51
53
  }
52
54
 
55
+ function resetLoading(): IResetLoading {
56
+ return { type: RESET_LOADING };
57
+ }
58
+
53
59
  const resetStateValues = (dispatch: Dispatch) => {
54
- dispatch(setIsLoading(true));
60
+ dispatch(resetLoading());
55
61
  dispatch(setIsSaving(false));
56
62
  };
57
63
 
@@ -12,10 +12,12 @@ const SET_GLOBAL_SETTINGS = `${NAME}/SET_GLOBAL_SETTINGS`;
12
12
  const SET_USER = `${NAME}/SET_USER`;
13
13
  const SET_SESSION_STARTED_AT = `${NAME}/SET_SESSION_STARTED_AT`;
14
14
  const SET_HAS_ANIMATION = `${NAME}/SET_HAS_ANIMATION`;
15
+ const RESET_LOADING = `${NAME}/RESET_LOADING`;
15
16
 
16
17
  export {
17
18
  IS_LOGGING_IN,
18
19
  LOGOUT,
20
+ RESET_LOADING,
19
21
  SET_ERROR,
20
22
  SET_GLOBAL_LANGUAGES,
21
23
  SET_GLOBAL_SETTINGS,
@@ -1,6 +1,7 @@
1
1
  import type {
2
2
  IS_LOGGING_IN,
3
3
  LOGOUT,
4
+ RESET_LOADING,
4
5
  SET_ERROR,
5
6
  SET_GLOBAL_LANGUAGES,
6
7
  SET_GLOBAL_SETTINGS,
@@ -76,6 +77,10 @@ export interface ISetHasAnimation {
76
77
  payload: { hasAnimation: boolean };
77
78
  }
78
79
 
80
+ export interface IResetLoading {
81
+ type: typeof RESET_LOADING;
82
+ }
83
+
79
84
  export type AppActionsCreators = ISetIsLoading & ISetIsSaving;
80
85
 
81
86
  export type AuthActionsCreators = ISetTokenAction &
@@ -5,6 +5,7 @@ import { REHYDRATE } from "redux-persist/lib/constants";
5
5
  import {
6
6
  IS_LOGGING_IN,
7
7
  LOGOUT,
8
+ RESET_LOADING,
8
9
  SET_ERROR,
9
10
  SET_GLOBAL_LANGUAGES,
10
11
  SET_GLOBAL_SETTINGS,
@@ -20,6 +21,7 @@ import {
20
21
  export interface IAppState {
21
22
  isRehydrated: boolean;
22
23
  isLoading: boolean;
24
+ loadingCount: number;
23
25
  isSaving: boolean;
24
26
  error: IError;
25
27
  user: IUser;
@@ -65,6 +67,7 @@ export interface IGlobalSettings {
65
67
  export const initialState = {
66
68
  isRehydrated: true,
67
69
  isLoading: true,
70
+ loadingCount: 0,
68
71
  isSaving: false,
69
72
  error: {
70
73
  code: undefined,
@@ -103,9 +106,15 @@ export const initialState = {
103
106
  export function reducer(state = initialState, action: any): IAppState {
104
107
  switch (action.type) {
105
108
  case REHYDRATE:
106
- return { ...state, isRehydrated: true, schemasLoading: false, schemasError: null };
109
+ return { ...state, isRehydrated: true, loadingCount: 0, schemasLoading: false, schemasError: null };
110
+ case SET_IS_LOADING: {
111
+ const delta = action.payload.isLoading ? 1 : -1;
112
+ const loadingCount = Math.max(0, state.loadingCount + delta);
113
+ return { ...state, loadingCount, isLoading: loadingCount > 0 };
114
+ }
115
+ case RESET_LOADING:
116
+ return { ...state, loadingCount: 0, isLoading: true };
107
117
  case SET_TOKEN:
108
- case SET_IS_LOADING:
109
118
  case SET_IS_SAVING:
110
119
  case IS_LOGGING_IN:
111
120
  case LOGOUT:
@@ -190,10 +190,10 @@ function getForm(formID: number | null): (dispatch: Dispatch, getState: () => IR
190
190
  const formData: Partial<FormContent> = response.data;
191
191
  if (isNewTranslation) {
192
192
  delete formData.id;
193
- formData["state"] = "inactive";
194
- formData["canBeTranslated"] = true;
195
- formData["originalLanguage"] = formData.language;
196
- formData["formInUse"] = null;
193
+ formData.state = "inactive";
194
+ formData.canBeTranslated = true;
195
+ formData.originalLanguage = formData.language;
196
+ formData.formInUse = null;
197
197
  }
198
198
  generateFormContent(formData)(dispatch, getState);
199
199
  dispatch(setCurrentFormID(response.data.id));
@@ -821,8 +821,6 @@ function orderFormCategory(
821
821
  ): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
822
822
  return async (dispatch, getState) => {
823
823
  try {
824
- dispatch(setIsLoading(true));
825
-
826
824
  const responseActions = {
827
825
  handleSuccess: () => getFormCategories(data.categoryType)(dispatch, getState),
828
826
  handleError: (response: any) => appActions.handleError(response)(dispatch),
@@ -830,7 +828,7 @@ function orderFormCategory(
830
828
 
831
829
  const callback = async () => forms.orderFormCategory(data);
832
830
 
833
- return await handleRequest(callback, responseActions, [])(dispatch);
831
+ return await handleRequest(callback, responseActions, [setIsLoading])(dispatch);
834
832
  } catch (e) {
835
833
  console.log(e);
836
834
  return false;
@@ -188,8 +188,6 @@ function orderIntegration(
188
188
  sites: { currentSiteInfo },
189
189
  } = getState();
190
190
 
191
- dispatch(appActions.setIsLoading(true));
192
-
193
191
  const callback = async () => integrations.orderIntegration(id, newOrder);
194
192
  const responseActions = {
195
193
  handleSuccess: () => {
@@ -198,7 +196,7 @@ function orderIntegration(
198
196
  },
199
197
  handleError: (response: any) => appActions.handleError(response)(dispatch),
200
198
  };
201
- return await handleRequest(callback, responseActions, [])(dispatch);
199
+ return await handleRequest(callback, responseActions, [appActions.setIsLoading])(dispatch);
202
200
  } catch (e) {
203
201
  console.log(e);
204
202
  return false;
@@ -83,7 +83,7 @@ function getMenus(hasLoading = true): (dispatch: Dispatch, getState: () => IRoot
83
83
  return async (dispatch, getState) => {
84
84
  try {
85
85
  const { currentSiteInfo, type } = getStateValues(getState);
86
- const id = currentSiteInfo && currentSiteInfo.id;
86
+ const id = currentSiteInfo?.id;
87
87
 
88
88
  const responseActions = {
89
89
  handleSuccess: (menus: IMenu[]) => {
@@ -114,9 +114,9 @@ function getCurrentMenu(menuType: string): (dispatch: Dispatch, getState: () =>
114
114
  const { savedMenus } = getStateValues(getState);
115
115
  setEditorMenuContent(savedMenus || [], menuType, dispatch);
116
116
  updateTotalItems(dispatch, getState);
117
+ dispatch(setIsLoading(false));
117
118
  } catch (e) {
118
119
  console.log("Error", e);
119
- dispatch(setIsLoading(false));
120
120
  }
121
121
  };
122
122
  }
@@ -392,8 +392,8 @@ function getPage(
392
392
  await getTemplateConfig(template)(dispatch, getState);
393
393
  generateNewPage(dispatch, getState, baseSchema);
394
394
  }
395
- } catch (e) {
396
395
  dispatch(setIsLoading(false));
396
+ } catch (e) {
397
397
  console.log(e); // TODO: capturar error bien
398
398
  }
399
399
  };
@@ -410,8 +410,8 @@ function getTemplatePage(template: string): (dispatch: Dispatch, getState: () =>
410
410
  await getTemplateConfig(template)(dispatch, getState);
411
411
  await getDefaults()(dispatch, getState);
412
412
  generateNewPage(dispatch, getState, baseSchema);
413
- } catch (e) {
414
413
  dispatch(setIsLoading(false));
414
+ } catch (e) {
415
415
  console.log(e); // TODO: capturar error bien
416
416
  }
417
417
  };
@@ -1456,6 +1456,7 @@ function getGlobalFromLocalPage(): (dispatch: Dispatch, getState: any) => Promis
1456
1456
  dispatch(setCurrentPageID(originalGlobalPage));
1457
1457
  structuredDataActions.setSelectedStructuredData(structuredData, "global")(dispatch, getState);
1458
1458
  usersActions.getUserCurrentPermissions()(dispatch, getState);
1459
+ dispatch(setIsLoading(false));
1459
1460
  } catch (e) {
1460
1461
  console.log(e);
1461
1462
  }