@griddo/ax 11.0.29-rc.0 → 11.0.30-rc.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 (141) hide show
  1. package/config/griddo-config/cx-polyfills/componentsBundle.js +1 -1
  2. package/package.json +2 -2
  3. package/scripts/griddo-sync-schemas.js +49 -42
  4. package/src/GlobalStore.tsx +3 -0
  5. package/src/__tests__/components/TableFilters/LiveFilter/LiveFilter.test.tsx +6 -0
  6. package/src/api/forms.tsx +191 -0
  7. package/src/api/index.tsx +2 -0
  8. package/src/components/Browser/index.tsx +42 -37
  9. package/src/components/Browser/style.tsx +3 -3
  10. package/src/components/BrowserContent/index.tsx +1 -1
  11. package/src/components/ConfigPanel/Form/index.tsx +6 -5
  12. package/src/components/ConfigPanel/GlobalPageForm/index.tsx +3 -1
  13. package/src/components/ConfigPanel/Header/index.tsx +1 -0
  14. package/src/components/Fields/ComponentArray/MixableComponentArray/AddItemButton/index.tsx +4 -5
  15. package/src/components/Fields/ComponentArray/MixableComponentArray/index.tsx +4 -4
  16. package/src/components/Fields/ComponentArray/helpers.tsx +1 -1
  17. package/src/components/Fields/FormFieldArray/index.tsx +13 -0
  18. package/src/components/Fields/ReferenceField/AutoPanel/index.tsx +1 -2
  19. package/src/components/Fields/ReferenceField/Context/index.tsx +0 -2
  20. package/src/components/Fields/ReferenceField/ItemList/index.tsx +1 -2
  21. package/src/components/Fields/ReferenceField/ManualPanel/index.tsx +2 -2
  22. package/src/components/Fields/ReferenceField/index.tsx +1 -5
  23. package/src/components/Fields/TranslateButton/index.tsx +48 -10
  24. package/src/components/Fields/Wysiwyg/helpers.tsx +2 -2
  25. package/src/components/Fields/Wysiwyg/index.tsx +4 -11
  26. package/src/components/Fields/index.tsx +2 -0
  27. package/src/components/FieldsBehavior/index.tsx +8 -2
  28. package/src/components/Icon/components/Form.js +12 -0
  29. package/src/components/Icon/svgs/Form.svg +3 -0
  30. package/src/components/LanguageMenu/index.tsx +30 -27
  31. package/src/components/MainWrapper/AppBar/index.tsx +23 -68
  32. package/src/components/MainWrapper/index.tsx +4 -9
  33. package/src/components/MenuItem/index.tsx +2 -2
  34. package/src/components/ResizePanel/index.tsx +3 -2
  35. package/src/components/ResizePanel/style.tsx +11 -9
  36. package/src/components/SearchField/style.tsx +2 -2
  37. package/src/components/SideModal/SideModalOption/index.tsx +3 -2
  38. package/src/components/SideModal/SideModalOption/style.tsx +2 -2
  39. package/src/components/SideModal/index.tsx +11 -4
  40. package/src/components/SideModal/style.tsx +9 -7
  41. package/src/components/TableFilters/LiveFilter/index.tsx +4 -3
  42. package/src/components/index.tsx +4 -0
  43. package/src/containers/App/reducer.tsx +4 -1
  44. package/src/containers/Forms/actions.tsx +853 -0
  45. package/src/containers/Forms/constants.tsx +46 -0
  46. package/src/containers/Forms/index.tsx +4 -0
  47. package/src/containers/Forms/interfaces.tsx +95 -0
  48. package/src/containers/Forms/reducer.tsx +81 -0
  49. package/src/containers/Forms/utils.tsx +42 -0
  50. package/src/containers/Navigation/Menu/actions.tsx +6 -13
  51. package/src/containers/Navigation/Menu/reducer.tsx +0 -4
  52. package/src/containers/PageEditor/actions.tsx +3 -2
  53. package/src/containers/PageEditor/reducer.tsx +2 -2
  54. package/src/forms/editor.tsx +3 -1
  55. package/src/helpers/index.tsx +12 -1
  56. package/src/helpers/schemas.tsx +35 -9
  57. package/src/helpers/structuredData.tsx +3 -1
  58. package/src/helpers/themes.tsx +3 -1
  59. package/src/helpers/thumbnails.tsx +20 -2
  60. package/src/modules/Analytics/GroupPanel/utils.tsx +3 -1
  61. package/src/modules/App/Routing/NavMenu/index.tsx +16 -6
  62. package/src/modules/App/Routing/index.tsx +26 -9
  63. package/src/modules/Categories/CategoriesList/CategoryItem/index.tsx +4 -4
  64. package/src/modules/Categories/CategoriesList/index.tsx +16 -16
  65. package/src/modules/Content/BulkHeader/TableHeader/index.tsx +1 -5
  66. package/src/modules/Content/PageItem/index.tsx +34 -33
  67. package/src/modules/Content/index.tsx +23 -36
  68. package/src/modules/Content/utils.tsx +3 -1
  69. package/src/modules/Forms/FormCategoriesList/BulkHeader/TableHeader/index.tsx +42 -0
  70. package/src/modules/Forms/FormCategoriesList/BulkHeader/TableHeader/style.tsx +36 -0
  71. package/src/modules/Forms/FormCategoriesList/BulkHeader/index.tsx +37 -0
  72. package/src/modules/Forms/FormCategoriesList/BulkHeader/style.tsx +9 -0
  73. package/src/modules/Forms/FormCategoriesList/CategoryItem/index.tsx +125 -0
  74. package/src/modules/Forms/FormCategoriesList/CategoryItem/style.tsx +91 -0
  75. package/src/modules/Forms/FormCategoriesList/CategoryPanel/Form/index.tsx +50 -0
  76. package/src/modules/Forms/FormCategoriesList/CategoryPanel/index.tsx +112 -0
  77. package/src/modules/Forms/FormCategoriesList/CategoryPanel/style.tsx +31 -0
  78. package/src/modules/Forms/FormCategoriesList/atoms.tsx +33 -0
  79. package/src/modules/Forms/FormCategoriesList/hooks.tsx +61 -0
  80. package/src/modules/Forms/FormCategoriesList/index.tsx +245 -0
  81. package/src/modules/Forms/FormCategoriesList/style.tsx +82 -0
  82. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/Field/index.tsx +95 -0
  83. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/TemplateManager/index.tsx +102 -0
  84. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/TemplateManager/style.tsx +9 -0
  85. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/index.tsx +109 -0
  86. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/index.tsx +76 -0
  87. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/style.tsx +28 -0
  88. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Header/index.tsx +132 -0
  89. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Header/style.tsx +30 -0
  90. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/index.tsx +86 -0
  91. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/style.tsx +7 -0
  92. package/src/modules/Forms/FormEditor/Editor/index.tsx +106 -0
  93. package/src/modules/Forms/FormEditor/PageBrowser/index.tsx +96 -0
  94. package/src/modules/Forms/FormEditor/index.tsx +295 -0
  95. package/src/modules/Forms/FormEditor/style.tsx +32 -0
  96. package/src/modules/Forms/FormList/BulkHeader/TableHeader/index.tsx +61 -0
  97. package/src/modules/Forms/FormList/BulkHeader/TableHeader/style.tsx +47 -0
  98. package/src/modules/Forms/FormList/BulkHeader/index.tsx +60 -0
  99. package/src/modules/Forms/FormList/FormItem/index.tsx +218 -0
  100. package/src/modules/Forms/FormList/FormItem/style.tsx +87 -0
  101. package/src/modules/Forms/FormList/Summary/index.tsx +51 -0
  102. package/src/modules/Forms/FormList/Summary/style.tsx +46 -0
  103. package/src/modules/Forms/FormList/TemplateModal/index.tsx +67 -0
  104. package/src/modules/Forms/FormList/TemplateModal/style.tsx +54 -0
  105. package/src/modules/Forms/FormList/index.tsx +266 -0
  106. package/src/modules/Forms/FormList/style.tsx +31 -0
  107. package/src/modules/Forms/FormsMenu/MenuGroup/index.tsx +57 -0
  108. package/src/modules/Forms/FormsMenu/MenuGroup/style.tsx +55 -0
  109. package/src/modules/Forms/FormsMenu/index.tsx +78 -0
  110. package/src/modules/Forms/FormsMenu/style.tsx +9 -0
  111. package/src/modules/Forms/atoms.tsx +111 -0
  112. package/src/modules/Forms/style.tsx +11 -0
  113. package/src/modules/FramePreview/index.tsx +26 -12
  114. package/src/modules/GlobalEditor/index.tsx +52 -21
  115. package/src/modules/Navigation/Defaults/DefaultsEditor/index.tsx +32 -15
  116. package/src/modules/Navigation/Defaults/Item/atoms.tsx +6 -5
  117. package/src/modules/Navigation/Defaults/Item/index.tsx +10 -10
  118. package/src/modules/Navigation/Defaults/index.tsx +7 -6
  119. package/src/modules/Navigation/Menus/List/Nav/index.tsx +2 -10
  120. package/src/modules/Navigation/Menus/List/Table/SidePanel/Form/index.tsx +14 -11
  121. package/src/modules/Navigation/Menus/List/index.tsx +15 -16
  122. package/src/modules/Navigation/Menus/index.tsx +9 -17
  123. package/src/modules/PageEditor/index.tsx +54 -31
  124. package/src/modules/Settings/Globals/index.tsx +3 -1
  125. package/src/modules/Settings/Languages/Table/Item/index.tsx +11 -9
  126. package/src/modules/Sites/SitesList/ListView/BulkHeader/TableHeader/index.tsx +1 -1
  127. package/src/modules/StructuredData/Form/index.tsx +41 -28
  128. package/src/modules/StructuredData/StructuredDataList/BulkHeader/TableHeader/index.tsx +1 -5
  129. package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +6 -8
  130. package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/index.tsx +5 -7
  131. package/src/modules/StructuredData/StructuredDataList/index.tsx +13 -10
  132. package/src/modules/StructuredData/StructuredDataList/utils.tsx +2 -1
  133. package/src/routes/multisite.tsx +53 -16
  134. package/src/routes/site.tsx +1 -0
  135. package/src/schemas/pages/FormPage.tsx +49 -0
  136. package/src/schemas/pages/GlobalPage.tsx +1 -0
  137. package/src/schemas/pages/Page.tsx +4 -1
  138. package/src/schemas/pages/index.tsx +2 -1
  139. package/src/types/forms.tsx +87 -0
  140. package/src/types/index.tsx +43 -7
  141. /package/src/modules/Navigation/Menus/{helpers.tsx → List/helpers.tsx} +0 -0
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import styled from "styled-components";
3
+ import { BulkSelectionOptions } from "@ax/components";
4
+
5
+ const StyledBulkSelectionOptions = styled((props) => <BulkSelectionOptions {...props} />)`
6
+ padding: ${(p) => `${p.theme.spacing.xs} ${p.theme.spacing.m}`};
7
+ `;
8
+
9
+ export { StyledBulkSelectionOptions };
@@ -0,0 +1,125 @@
1
+ import React from "react";
2
+ import { connect } from "react-redux";
3
+ import { DraggableProvided } from "react-beautiful-dnd";
4
+
5
+ import { formsActions } from "@ax/containers/Forms";
6
+ import { useModal } from "@ax/hooks";
7
+ import { FormCategory, ICheck } from "@ax/types";
8
+ import { CheckField, Icon } from "@ax/components";
9
+ import CategoryPanel from "../CategoryPanel";
10
+ import { DeleteModal } from "../atoms";
11
+
12
+ import * as S from "./style";
13
+
14
+ const CategoryItem = (props: ICategoryItemProps): JSX.Element => {
15
+ const { category, isSelected, hoverCheck, isDragging, provided, deleteFormCategory, onChange, toggleToast } = props;
16
+
17
+ const { isOpen, toggleModal } = useModal();
18
+ const { isOpen: isDeleteOpen, toggleModal: toggleDeleteModal } = useModal();
19
+
20
+ const { content } = category;
21
+
22
+ const handleClick = () => !isDragging && toggleModal();
23
+
24
+ const handleCloseModal = () => {
25
+ toggleModal();
26
+ };
27
+
28
+ const handleOnChange = (value: ICheck) => onChange(value);
29
+
30
+ const handleCheckClick = (e: React.MouseEvent<HTMLDivElement>) => e.stopPropagation();
31
+
32
+ const removeCategory = async () => {
33
+ const deleted = await deleteFormCategory(category.id, category.categoryType);
34
+
35
+ if (deleted) {
36
+ isDeleteOpen && toggleDeleteModal();
37
+ toggleToast("1 form category deleted");
38
+ }
39
+ };
40
+
41
+ const menuOptions = [
42
+ {
43
+ label: "delete",
44
+ icon: "delete",
45
+ action: toggleDeleteModal,
46
+ },
47
+ ];
48
+
49
+ const mainDeleteModalAction = {
50
+ title: "Yes, delete it",
51
+ onClick: removeCategory,
52
+ };
53
+
54
+ const secondaryDeleteModalAction = { title: "Cancel", onClick: toggleDeleteModal };
55
+
56
+ return (
57
+ <>
58
+ <S.CategoryRow
59
+ role="rowgroup"
60
+ selected={isSelected}
61
+ onClick={handleClick}
62
+ ref={provided.innerRef}
63
+ {...provided.draggableProps}
64
+ {...provided.dragHandleProps}
65
+ >
66
+ <S.HandleCell>
67
+ <S.IconWrapperDrag role="cell">
68
+ <Icon name="drag" size="16" />
69
+ </S.IconWrapperDrag>
70
+ </S.HandleCell>
71
+ <S.CheckCell role="cell" onClick={handleCheckClick}>
72
+ <CheckField name="check" value={category.id} checked={isSelected || hoverCheck} onChange={handleOnChange} />
73
+ </S.CheckCell>
74
+ <S.NameCell role="cell" clickable={true}>
75
+ <div>{content?.title || ""}</div>
76
+ </S.NameCell>
77
+ <S.CodeCell role="cell" clickable={true}>
78
+ {category.content.code}
79
+ </S.CodeCell>
80
+ <S.ActionsCell role="cell">
81
+ <S.StyledActionMenu icon="more" options={menuOptions} tooltip="Actions" />
82
+ </S.ActionsCell>
83
+ </S.CategoryRow>
84
+ {isOpen && (
85
+ <CategoryPanel
86
+ isOpen={isOpen}
87
+ toggleModal={handleCloseModal}
88
+ item={category}
89
+ toggleToast={toggleToast}
90
+ type={category.categoryType}
91
+ />
92
+ )}
93
+ {isDeleteOpen && (
94
+ <DeleteModal
95
+ isOpen={isDeleteOpen}
96
+ toggleModal={toggleDeleteModal}
97
+ mainModalAction={mainDeleteModalAction}
98
+ secondaryModalAction={secondaryDeleteModalAction}
99
+ />
100
+ )}
101
+ </>
102
+ );
103
+ };
104
+
105
+ interface IProps {
106
+ category: FormCategory;
107
+ isSelected: boolean;
108
+ onChange: (e: any) => void;
109
+ toggleToast(state: any): void;
110
+ hoverCheck?: boolean;
111
+ isDragging: boolean;
112
+ provided: DraggableProvided;
113
+ }
114
+
115
+ interface IDispatchProps {
116
+ deleteFormCategory(id: number | number[], categoryType: string): Promise<boolean>;
117
+ }
118
+
119
+ type ICategoryItemProps = IProps & IDispatchProps;
120
+
121
+ const mapDispatchToProps = {
122
+ deleteFormCategory: formsActions.deleteFormCategory,
123
+ };
124
+
125
+ export default connect(null, mapDispatchToProps)(CategoryItem);
@@ -0,0 +1,91 @@
1
+ import styled from "styled-components";
2
+
3
+ import { Cell, Row } from "@ax/components/TableList/TableItem/style";
4
+ import { ActionMenu } from "@ax/components";
5
+
6
+ const CheckCell = styled(Cell)`
7
+ padding-left: 0;
8
+ padding-right: 0;
9
+ width: 32px;
10
+ label {
11
+ margin-bottom: ${(p) => p.theme.spacing.s};
12
+ }
13
+ `;
14
+
15
+ const NameCell = styled(Cell)<{ clickable: boolean }>`
16
+ ${(p) => p.theme.textStyle.uiL};
17
+ padding-left: ${(p) => p.theme.spacing.xs};
18
+ pointer-events: ${(p) => (p.clickable ? "auto" : "none")};
19
+ color: ${(p) => p.theme.color.textHighEmphasis};
20
+ display: flex;
21
+ flex-flow: row nowrap;
22
+ align-items: center;
23
+ justify-content: flex-start;
24
+ flex-grow: 1;
25
+ `;
26
+
27
+ const ActionsCell = styled(Cell)`
28
+ flex: 0 0 80px;
29
+ `;
30
+
31
+ const CodeCell = styled(Cell)<{ clickable: boolean }>`
32
+ ${(p) => p.theme.textStyle.uiXS};
33
+ pointer-events: ${(p) => (p.clickable ? "auto" : "none")};
34
+ flex: 0 0 250px;
35
+ `;
36
+
37
+ const StyledActionMenu = styled(ActionMenu)`
38
+ opacity: 0;
39
+ width: 32px;
40
+ display: flex;
41
+ margin-left: auto;
42
+ `;
43
+
44
+ const CategoryRow = styled(Row)`
45
+ &:hover {
46
+ ${StyledActionMenu} {
47
+ opacity: 1;
48
+ }
49
+ }
50
+ `;
51
+
52
+ const FlagsWrapper = styled.div`
53
+ display: flex;
54
+ svg {
55
+ margin-right: 2px;
56
+ margin-bottom: -3px; // TODO
57
+ display: inline;
58
+ vertical-align: baseline;
59
+ }
60
+ `;
61
+
62
+ const HandleCell = styled(Cell)`
63
+ flex-flow: row nowrap;
64
+ padding: ${(p) => `0 ${p.theme.spacing.xs} 0 0`};
65
+ align-items: center;
66
+ `;
67
+
68
+ const IconWrapperDrag = styled.div`
69
+ display: flex;
70
+ align-items: center;
71
+ padding: ${(p) => `${p.theme.spacing.s} 0 ${p.theme.spacing.s} ${p.theme.spacing.xs}`};
72
+ height: 100%;
73
+ opacity: 1;
74
+ svg {
75
+ path {
76
+ fill: ${(p) => p.theme.color.textLowEmphasis};
77
+ }
78
+ }
79
+ `;
80
+
81
+ export {
82
+ CheckCell,
83
+ NameCell,
84
+ ActionsCell,
85
+ CodeCell,
86
+ StyledActionMenu,
87
+ CategoryRow,
88
+ FlagsWrapper,
89
+ IconWrapperDrag,
90
+ HandleCell,
91
+ };
@@ -0,0 +1,50 @@
1
+ import React from "react";
2
+
3
+ import { FieldsBehavior } from "@ax/components";
4
+ import { slugify } from "@ax/helpers";
5
+ import { IFormState } from "..";
6
+
7
+ const Form = (props: IFormProps): JSX.Element => {
8
+ const { edit, form, setForm } = props;
9
+
10
+ const setNameValue = (value: string) => {
11
+ if (!edit) {
12
+ setForm({ ...form, name: value, code: slugify(value) });
13
+ } else {
14
+ setForm({ ...form, name: value });
15
+ }
16
+ };
17
+
18
+ const setCodeValue = (value: string) => setForm({ ...form, code: value });
19
+
20
+ return (
21
+ <>
22
+ <FieldsBehavior
23
+ title="Name"
24
+ name="name"
25
+ fieldType="TextField"
26
+ value={form.name}
27
+ onChange={setNameValue}
28
+ autoComplete="category-name"
29
+ mandatory={true}
30
+ />
31
+ <FieldsBehavior
32
+ title="Code"
33
+ name="code"
34
+ fieldType="TextField"
35
+ value={form.code}
36
+ onChange={setCodeValue}
37
+ autoComplete="category-code"
38
+ mandatory={true}
39
+ />
40
+ </>
41
+ );
42
+ };
43
+
44
+ interface IFormProps {
45
+ edit: boolean | undefined;
46
+ form: IFormState;
47
+ setForm: (values: IFormState) => void;
48
+ }
49
+
50
+ export default Form;
@@ -0,0 +1,112 @@
1
+ import React, { useState } from "react";
2
+ import { connect } from "react-redux";
3
+
4
+ import { formsActions } from "@ax/containers/Forms";
5
+ import { FormCategory } from "@ax/types";
6
+ import { Button, FloatingPanel } from "@ax/components";
7
+ import Form from "./Form";
8
+
9
+ import * as S from "./style";
10
+
11
+ const CategoryPanel = (props: IProps): JSX.Element => {
12
+ const { isOpen, item, type, toggleModal, toggleToast, createFormCategory, updateFormCategory } = props;
13
+
14
+ const initState: IFormState = {
15
+ name: item?.content.title || "",
16
+ code: item?.content.code || "",
17
+ };
18
+
19
+ const [form, setForm] = useState(initState);
20
+
21
+ const addItemAction = async () => {
22
+ const newCategory = {
23
+ title: form.name,
24
+ code: form.code,
25
+ };
26
+
27
+ const isCreated = await createFormCategory(newCategory, type);
28
+
29
+ if (isCreated) {
30
+ toggleModal();
31
+ }
32
+ };
33
+
34
+ const editItemAction = async () => {
35
+ let isUpdated = false;
36
+ let toastString = "";
37
+
38
+ const updatedCategory = {
39
+ title: form.name,
40
+ code: form.code,
41
+ };
42
+
43
+ isUpdated = !!item && (await updateFormCategory(item.id, updatedCategory));
44
+ toastString = "1 form category edited";
45
+
46
+ if (isUpdated) {
47
+ toggleToast(toastString);
48
+ }
49
+
50
+ toggleModal();
51
+ };
52
+
53
+ const addButton = {
54
+ label: "Add",
55
+ action: addItemAction,
56
+ disabled: false,
57
+ };
58
+
59
+ const editButton = {
60
+ label: "Update",
61
+ action: editItemAction,
62
+ disabled: false,
63
+ };
64
+
65
+ const title = !item ? "New Category" : "Edit Category";
66
+
67
+ return (
68
+ <FloatingPanel title={title} toggleModal={toggleModal} isOpen={isOpen}>
69
+ <S.Wrapper>
70
+ <Form edit={!!item} form={form} setForm={setForm} />
71
+ <S.Footer>
72
+ {!item ? (
73
+ <Button className="button" type="button" onClick={addButton.action} disabled={addButton.disabled}>
74
+ {addButton.label}
75
+ </Button>
76
+ ) : (
77
+ <Button className="button" type="button" onClick={editButton.action} disabled={editButton.disabled}>
78
+ {editButton.label}
79
+ </Button>
80
+ )}
81
+ </S.Footer>
82
+ </S.Wrapper>
83
+ </FloatingPanel>
84
+ );
85
+ };
86
+
87
+ interface ICategoryPanelProps {
88
+ item?: FormCategory;
89
+ type: string;
90
+ isOpen: boolean;
91
+ toggleModal(): void;
92
+ toggleToast(state: string): void;
93
+ }
94
+
95
+ export interface IFormState {
96
+ name: string;
97
+ code: string;
98
+ }
99
+
100
+ const mapDispatchToProps = {
101
+ createFormCategory: formsActions.createFormCategory,
102
+ updateFormCategory: formsActions.updateFormCategory,
103
+ };
104
+
105
+ interface IDispatchProps {
106
+ createFormCategory: (content: { title: string; code: string }, categoryType: string) => Promise<boolean>;
107
+ updateFormCategory: (id: number, content: { title: string; code: string }) => Promise<boolean>;
108
+ }
109
+
110
+ type IProps = IDispatchProps & ICategoryPanelProps;
111
+
112
+ export default connect(null, mapDispatchToProps)(CategoryPanel);
@@ -0,0 +1,31 @@
1
+ import styled from "styled-components";
2
+
3
+ const Wrapper = styled.div`
4
+ padding: ${(p) => p.theme.spacing.m};
5
+ height: 100%;
6
+ `;
7
+
8
+ const Footer = styled.div`
9
+ position: absolute;
10
+ bottom: ${(p) => p.theme.spacing.m};
11
+ right: ${(p) => p.theme.spacing.m};
12
+ `;
13
+
14
+ const FlagWrapper = styled.div`
15
+ display: flex;
16
+ margin-bottom: ${(p) => p.theme.spacing.xs};
17
+ `;
18
+
19
+ const TranslationText = styled.div`
20
+ ${(p) => p.theme.textStyle.headingXXS};
21
+ color: ${(p) => p.theme.color.textMediumEmphasis};
22
+ margin-left: ${(p) => p.theme.spacing.xs};
23
+ `;
24
+
25
+ const Translation = styled.div`
26
+ ${(p) => p.theme.textStyle.uiL};
27
+ color: ${(p) => p.theme.color.textHighEmphasis};
28
+ margin-bottom: ${(p) => p.theme.spacing.s};
29
+ `;
30
+
31
+ export { Wrapper, Footer, FlagWrapper, TranslationText, Translation };
@@ -0,0 +1,33 @@
1
+ import React from "react";
2
+
3
+ import { IModal } from "@ax/types";
4
+ import { Modal } from "@ax/components";
5
+
6
+ import * as S from "./style";
7
+
8
+ const DeleteModal = (props: IModal): JSX.Element => {
9
+ const { isOpen, toggleModal, mainModalAction, secondaryModalAction } = props;
10
+
11
+ return (
12
+ <Modal
13
+ isOpen={isOpen}
14
+ hide={toggleModal}
15
+ title="Delete category"
16
+ secondaryAction={secondaryModalAction}
17
+ mainAction={mainModalAction}
18
+ size="S"
19
+ height={240}
20
+ >
21
+ <S.ModalContent>
22
+ <p>
23
+ Are you sure you want to delete <strong>this category</strong>? It won&apos;t be assignable to new froms, and
24
+ existing forms with this category will lose it.
25
+ <br />
26
+ <strong>This action cannot be undone</strong>.
27
+ </p>
28
+ </S.ModalContent>
29
+ </Modal>
30
+ );
31
+ };
32
+
33
+ export { DeleteModal };
@@ -0,0 +1,61 @@
1
+ import { useState } from "react";
2
+ import { IQueryValue } from "@ax/types";
3
+
4
+ const useFilterQuery = () => {
5
+ const initialQueryValues: Record<string, IQueryValue[]> = {
6
+ translated: [{ value: "all", label: "All" }],
7
+ };
8
+
9
+ const [query, setQuery] = useState(initialQueryValues);
10
+ const [currentFilterQuery, setCurrentFilterQuery] = useState("");
11
+
12
+ const setFilterQuery = (filterValues: Record<string, IQueryValue[]>) => {
13
+ const { translated } = filterValues;
14
+ let filterQuery = "";
15
+
16
+ const currentQuery = (pointer: string, values: IQueryValue[]): string => {
17
+ const stringValues =
18
+ Array.isArray(values) && values.length
19
+ ? values.map((value) => (value.value !== "all" ? value.value : "")).join(",")
20
+ : "";
21
+
22
+ return !stringValues.length
23
+ ? filterQuery
24
+ : filterQuery.length
25
+ ? filterQuery.concat(`&${pointer}=${stringValues}`)
26
+ : `&${pointer}=${stringValues}`;
27
+ };
28
+
29
+ const isNotInitialValue = (pointer: string) => {
30
+ return filterValues[pointer] && initialQueryValues[pointer] !== filterValues[pointer];
31
+ };
32
+
33
+ if (isNotInitialValue("translated")) filterQuery = currentQuery("translated", translated);
34
+
35
+ setCurrentFilterQuery(filterQuery);
36
+ };
37
+
38
+ const setFiltersSelection = (pointer: string, filter: IQueryValue[]) => {
39
+ const { translated } = query;
40
+ const filterValues = {
41
+ translated: pointer === "translated" ? filter : translated,
42
+ };
43
+
44
+ setQuery(filterValues);
45
+ setFilterQuery(filterValues);
46
+ };
47
+
48
+ const resetFilterQuery = () => {
49
+ setQuery(initialQueryValues);
50
+ setCurrentFilterQuery("");
51
+ };
52
+
53
+ return {
54
+ setFiltersSelection,
55
+ resetFilterQuery,
56
+ filterValues: query,
57
+ filterQuery: currentFilterQuery,
58
+ };
59
+ };
60
+
61
+ export { useFilterQuery };