@antscorp/antsomi-ui 1.3.5-beta.40 → 1.3.5-beta.41
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.
- package/es/components/molecules/TemplateSaveAs/TemplateSaveAs.d.ts +3 -2
- package/es/components/molecules/TemplateSaveAs/TemplateSaveAs.js +100 -94
- package/es/components/molecules/TemplateSaveAs/TemplateSaveAsModal.js +5 -3
- package/es/components/molecules/TemplateSaveAs/hooks/useTemplateSave.d.ts +7 -1
- package/es/components/molecules/TemplateSaveAs/hooks/useTemplateSave.js +21 -1
- package/es/constants/templateListing.d.ts +0 -2
- package/es/constants/templateListing.js +2 -2
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +1 -0
- package/es/utils/templateListing.d.ts +2 -0
- package/es/utils/templateListing.js +12 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { SelectProps } from 'antd';
|
|
2
|
+
import type { FormInstance, SelectProps } from 'antd';
|
|
3
3
|
import { ShareAccessProps } from '../ShareAccess/types';
|
|
4
4
|
export type categoriesProps = Array<{
|
|
5
5
|
label: string | React.ReactNode;
|
|
@@ -63,8 +63,9 @@ export interface TemplateSaveAsProps {
|
|
|
63
63
|
label?: string;
|
|
64
64
|
placeholder?: string;
|
|
65
65
|
};
|
|
66
|
+
form?: FormInstance<any>;
|
|
66
67
|
value?: TemplateValueOptions;
|
|
67
|
-
onChange?: (value: Partial<TemplateValueOptions
|
|
68
|
+
onChange?: (value: Partial<TemplateValueOptions>, errors?: any[]) => void;
|
|
68
69
|
onEvent?: (value: Partial<TemplateValueOptions>) => void;
|
|
69
70
|
}
|
|
70
71
|
export declare const TemplateSaveAs: React.FC<TemplateSaveAsProps>;
|
|
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
// Libraries
|
|
13
13
|
import React, { useState } from 'react';
|
|
14
|
-
import { Dropdown } from 'antd';
|
|
14
|
+
import { Dropdown, Form } from 'antd';
|
|
15
15
|
import dayjs from 'dayjs';
|
|
16
16
|
// Components
|
|
17
17
|
import { Tooltip, Button, Flex, Input, Typography, Select, ShareAccess, RadioGroup, Radio, Space, Spin, } from '@antscorp/antsomi-ui/es/components';
|
|
@@ -20,7 +20,7 @@ import { TemplateSaveAsStyled } from './styled';
|
|
|
20
20
|
import { ImageSlider } from './components';
|
|
21
21
|
const { Text } = Typography;
|
|
22
22
|
export const TemplateSaveAs = props => {
|
|
23
|
-
const { className, shareAccess, saveOptions, imageReview, categories, omitCategories, templateNames, templateNamesOptions, descriptionOptions, value, onChange, onEvent,
|
|
23
|
+
const { className, shareAccess, saveOptions, imageReview, categories, omitCategories, templateNames, templateNamesOptions, descriptionOptions, form, value, onChange, onEvent,
|
|
24
24
|
// onNamePopupScroll,
|
|
25
25
|
} = props;
|
|
26
26
|
const { show: isShowShareAccess } = shareAccess, shareAccessProps = __rest(shareAccess, ["show"]);
|
|
@@ -32,6 +32,7 @@ export const TemplateSaveAs = props => {
|
|
|
32
32
|
const [templateName, setTemplateName] = useState(defaultNewTemplateName || `Untitled Media Template#${dayjs().format('YYYY-MM-DD HH:mm:ss')}`);
|
|
33
33
|
const [templateNameExist, setTemplateNameExist] = useState((defaultTemplateName === null || defaultTemplateName === void 0 ? void 0 : defaultTemplateName.id) ? defaultTemplateName : templateNames === null || templateNames === void 0 ? void 0 : templateNames[0]);
|
|
34
34
|
const handleChangeValue = (newValue) => {
|
|
35
|
+
var _a, _b;
|
|
35
36
|
if (onEvent) {
|
|
36
37
|
onEvent(newValue);
|
|
37
38
|
}
|
|
@@ -44,7 +45,7 @@ export const TemplateSaveAs = props => {
|
|
|
44
45
|
? saveOption === saveNewValue
|
|
45
46
|
? { id: undefined, label: templateName }
|
|
46
47
|
: templateNameExist
|
|
47
|
-
: newValue.templateName || defaultTemplateName }));
|
|
48
|
+
: newValue.templateName || defaultTemplateName }), (_b = (_a = form === null || form === void 0 ? void 0 : form.getFieldsError()) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.errors);
|
|
48
49
|
}
|
|
49
50
|
};
|
|
50
51
|
const handleAddCategory = ({ parent, parentKey, item, }) => {
|
|
@@ -70,97 +71,102 @@ export const TemplateSaveAs = props => {
|
|
|
70
71
|
categories: [...newCategoryList, Object.assign(Object.assign({}, currCategory), { children: newChildren })],
|
|
71
72
|
});
|
|
72
73
|
};
|
|
73
|
-
return (React.createElement(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
React.createElement(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
74
|
+
return (React.createElement(Form, { form: form, initialValues: {
|
|
75
|
+
'template-name': defaultNewTemplateName ||
|
|
76
|
+
`Untitled Media Template#${dayjs().format('YYYY-MM-DD HH:mm:ss')}`,
|
|
77
|
+
} },
|
|
78
|
+
React.createElement(TemplateSaveAsStyled, { className: className || '', vertical: true },
|
|
79
|
+
React.createElement(Flex, { className: "save-options-container" },
|
|
80
|
+
React.createElement(RadioGroup, { value: saveOption, onChange: e => handleChangeValue({
|
|
81
|
+
saveOption: e.target.value,
|
|
82
|
+
templateName: e.target.value === saveNewValue
|
|
83
|
+
? { id: undefined, label: templateName }
|
|
84
|
+
: templateNameExist,
|
|
85
|
+
}) },
|
|
86
|
+
React.createElement(Radio, { value: saveNewValue }, saveNewText),
|
|
87
|
+
React.createElement(Radio, { value: saveExistValue }, saveExistText))),
|
|
88
|
+
React.createElement(Flex, null,
|
|
89
|
+
React.createElement(Flex, { vertical: true, gap: 20, className: "template-container" },
|
|
90
|
+
React.createElement(Flex, { className: "field-container" },
|
|
91
|
+
React.createElement(Text, { className: "field-title field-title--middle" },
|
|
92
|
+
templateLabel || 'Template name',
|
|
93
|
+
" ",
|
|
94
|
+
React.createElement("span", null, " *")),
|
|
95
|
+
saveOption === saveNewValue ? (React.createElement(Form.Item, { name: "template-name", validateTrigger: "onChange", noStyle: true, rules: [{ required: true }] },
|
|
96
|
+
React.createElement(Input, { debounce: 1000, className: "field-input", value: templateName, onAfterChange: value => {
|
|
97
|
+
handleChangeValue({ templateName: { id: undefined, label: value } });
|
|
98
|
+
setTemplateName(value);
|
|
99
|
+
}, required: true }))) : (React.createElement(Select, { className: "field-input", showSearch: true, searchValue: searchValue, onSearch: onSearch, onPopupScroll: onNamePopupScroll, filterOption: false, dropdownRender: menu => (React.createElement(React.Fragment, null,
|
|
100
|
+
isLoading && templateNames.length === 0 ? null : menu,
|
|
101
|
+
isLoading ? (React.createElement(Space, { style: {
|
|
102
|
+
padding: '4px 0',
|
|
103
|
+
width: '100%',
|
|
104
|
+
justifyContent: 'center',
|
|
105
|
+
alignItems: 'center',
|
|
106
|
+
} },
|
|
107
|
+
React.createElement(Spin, { size: "small" }))) : null)), value: templateNameExist === null || templateNameExist === void 0 ? void 0 : templateNameExist.id, options: (templateNames === null || templateNames === void 0 ? void 0 : templateNames.length) > 0
|
|
108
|
+
? templateNames.map(item => ({ value: item.id, label: item.label }))
|
|
109
|
+
: [], onChange: value => {
|
|
110
|
+
var _a, _b;
|
|
111
|
+
handleChangeValue({
|
|
112
|
+
templateName: {
|
|
113
|
+
id: value,
|
|
114
|
+
label: ((_a = templateNames.find(item => item.id === value)) === null || _a === void 0 ? void 0 : _a.label) || '',
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
setTemplateNameExist({
|
|
107
118
|
id: value,
|
|
108
|
-
label: ((
|
|
109
|
-
}
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
key:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
_b.children.map(selectedItem => (React.createElement(Flex, { key: selectedItem.key, className: "selected-category", justify: "space-between", align: "center" },
|
|
144
|
-
React.createElement(Tooltip, { title: selectedItem.label },
|
|
145
|
-
React.createElement(Text, { ellipsis: true, style: { textOverflow: 'ellipsis' } }, selectedItem.label)),
|
|
146
|
-
' ',
|
|
147
|
-
React.createElement("span", { className: "remove-btn", onClick: () => handleRemoveCategory({
|
|
148
|
-
parent: parentCategory.label,
|
|
149
|
-
item: selectedItem,
|
|
150
|
-
}) }, "\u00D7")))),
|
|
151
|
-
React.createElement(Dropdown, { menu: {
|
|
152
|
-
items: formatData,
|
|
153
|
-
onClick: ({ key }) => {
|
|
154
|
-
handleAddCategory({
|
|
119
|
+
label: ((_b = templateNames.find(item => item.id === value)) === null || _b === void 0 ? void 0 : _b.label) || '',
|
|
120
|
+
});
|
|
121
|
+
} }))),
|
|
122
|
+
React.createElement(Flex, { className: "field-container" },
|
|
123
|
+
React.createElement(Text, { className: "field-title field-title--middle" }, descriptionLabel || 'Description'),
|
|
124
|
+
React.createElement(Input, { placeholder: descriptionPlaceholder || 'Describe your media template', className: "field-input", value: defaultTemplateDesc, debounce: 1000, onAfterChange: value => handleChangeValue({ description: value }) })),
|
|
125
|
+
React.createElement(Flex, { className: "field-container" },
|
|
126
|
+
React.createElement(Text, { className: "field-title" },
|
|
127
|
+
imageReviewLabel || 'Thumbnail template',
|
|
128
|
+
" ",
|
|
129
|
+
React.createElement("span", null, "*")),
|
|
130
|
+
React.createElement(ImageSlider, { thumbnails: thumbnails, isLoading: isLoadingThumbnail, skeleton: skeleton, previewNavigation: previewNavigation, slidesPerView: slidesPerView, defaultThumbnail: defaultThumbnail, onSelectDefault: value => handleChangeValue({ defaultThumbnail: value }), hideThumbnailsList: hideThumbnailsList, hideDefaultButton: hideDefaultButton })), categories === null || categories === void 0 ? void 0 :
|
|
131
|
+
categories.map(parentCategory => {
|
|
132
|
+
var _a, _b, _c;
|
|
133
|
+
const selectedChildren = (_a = categoriesValue
|
|
134
|
+
.find(item => item.label === parentCategory.label)) === null || _a === void 0 ? void 0 : _a.children.map(item => item.label);
|
|
135
|
+
const remainChildren = parentCategory.children.filter(item => !(selectedChildren === null || selectedChildren === void 0 ? void 0 : selectedChildren.includes(item.label)));
|
|
136
|
+
const formatData = remainChildren.map((item, idx) => ({
|
|
137
|
+
label: item.label,
|
|
138
|
+
key: idx,
|
|
139
|
+
}));
|
|
140
|
+
// NOTE: filter to remove device and template categories
|
|
141
|
+
if ((omitCategories === null || omitCategories === void 0 ? void 0 : omitCategories.length) && omitCategories.includes(parentCategory.key.toString()))
|
|
142
|
+
return null;
|
|
143
|
+
return (React.createElement(Flex, { key: parentCategory.key, className: "field-container" },
|
|
144
|
+
React.createElement(Text, { className: "field-title" }, parentCategory.label),
|
|
145
|
+
React.createElement(Flex, { wrap: "wrap", gap: 10, className: "category-container" },
|
|
146
|
+
/* selectedCategory */
|
|
147
|
+
(_b = categoriesValue
|
|
148
|
+
.find(item => item.label === parentCategory.label)) === null || _b === void 0 ? void 0 :
|
|
149
|
+
_b.children.map(selectedItem => (React.createElement(Flex, { key: selectedItem.key, className: "selected-category", justify: "space-between", align: "center" },
|
|
150
|
+
React.createElement(Tooltip, { title: selectedItem.label },
|
|
151
|
+
React.createElement(Text, { ellipsis: true, style: { textOverflow: 'ellipsis' } }, selectedItem.label)),
|
|
152
|
+
' ',
|
|
153
|
+
React.createElement("span", { className: "remove-btn", onClick: () => handleRemoveCategory({
|
|
155
154
|
parent: parentCategory.label,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
155
|
+
item: selectedItem,
|
|
156
|
+
}) }, "\u00D7")))),
|
|
157
|
+
React.createElement(Dropdown, { menu: {
|
|
158
|
+
items: formatData,
|
|
159
|
+
onClick: ({ key }) => {
|
|
160
|
+
handleAddCategory({
|
|
161
|
+
parent: parentCategory.label,
|
|
162
|
+
parentKey: parentCategory.key,
|
|
163
|
+
item: remainChildren[key],
|
|
164
|
+
});
|
|
165
|
+
},
|
|
166
|
+
}, getPopupContainer: triggerNode => triggerNode.parentElement, trigger: ['click'] }, typeof parentCategory.label === 'string' ? (React.createElement(Button, null,
|
|
167
|
+
"+ Add ", (_c = parentCategory.label) === null || _c === void 0 ? void 0 :
|
|
168
|
+
_c.toLowerCase())) : (parentCategory.label)))));
|
|
169
|
+
})),
|
|
170
|
+
isShowShareAccess ? (React.createElement("div", { className: "share-access-container" },
|
|
171
|
+
React.createElement(ShareAccess, Object.assign({ accessInfo: accessInfo, onChange: value => handleChangeValue({ accessInfo: value }) }, shareAccessProps)))) : null))));
|
|
166
172
|
};
|
|
@@ -18,11 +18,13 @@ export const TemplateSaveAsModal = props => {
|
|
|
18
18
|
const { open, onCancel, okText, onOk, title, templateProps, defaultValue } = props, restProps = __rest(props, ["open", "onCancel", "okText", "onOk", "title", "templateProps", "defaultValue"]);
|
|
19
19
|
const { onChange: templateOnChange, value: templateValue } = templateProps, restTemplateProps = __rest(templateProps, ["onChange", "value"]);
|
|
20
20
|
const [internalValue, setInternalValue] = useState(defaultValue || templateValue);
|
|
21
|
+
const [errors, setErrors] = useState();
|
|
21
22
|
useEffect(() => {
|
|
22
23
|
if (defaultValue)
|
|
23
24
|
setInternalValue(defaultValue);
|
|
24
25
|
}, [defaultValue]);
|
|
25
|
-
const handleOnChange = (value) => {
|
|
26
|
+
const handleOnChange = (value, errors) => {
|
|
27
|
+
setErrors(errors);
|
|
26
28
|
if (templateOnChange) {
|
|
27
29
|
templateOnChange(value);
|
|
28
30
|
}
|
|
@@ -32,7 +34,7 @@ export const TemplateSaveAsModal = props => {
|
|
|
32
34
|
}
|
|
33
35
|
};
|
|
34
36
|
const handleOk = (event) => {
|
|
35
|
-
if (onOk) {
|
|
37
|
+
if (onOk && (!errors || errors.length === 0)) {
|
|
36
38
|
// NOTE: If there are templateValue and templateOnChange => controlled component => return templateValue
|
|
37
39
|
onOk(event, templateValue && templateOnChange ? templateValue : internalValue);
|
|
38
40
|
}
|
|
@@ -44,5 +46,5 @@ export const TemplateSaveAsModal = props => {
|
|
|
44
46
|
}
|
|
45
47
|
};
|
|
46
48
|
return (React.createElement(ModalV2, Object.assign({ open: open, onCancel: handleCancel, onOk: handleOk, okText: okText || 'Save', width: 1177, title: title || 'Save as my template' }, restProps),
|
|
47
|
-
React.createElement(TemplateSaveAs, Object.assign({ onChange: handleOnChange, value: templateValue || internalValue }, restTemplateProps))));
|
|
49
|
+
React.createElement(TemplateSaveAs, Object.assign({ onChange: (newValue, errors) => handleOnChange(newValue, errors), value: templateValue || internalValue }, restTemplateProps))));
|
|
48
50
|
};
|
|
@@ -13,7 +13,7 @@ interface TemplateListingOptions {
|
|
|
13
13
|
categoryList?: TGetTemplateCategoryList['options'];
|
|
14
14
|
templateList?: TGetObjectTEmplateList['options'];
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
defaultValue?: Partial<TemplateValueOptions>;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Custom React Hook for managing state and data fetching logic related to a template listing.
|
|
@@ -36,8 +36,14 @@ export declare const useTemplateSave: (options: TemplateListingOptions) => {
|
|
|
36
36
|
thumbnail?: string | undefined;
|
|
37
37
|
}[];
|
|
38
38
|
value: Partial<TemplateValueOptions>;
|
|
39
|
+
formattedCategoriesValue: {
|
|
40
|
+
camelCase: Record<string, any>;
|
|
41
|
+
snakeCase: {};
|
|
42
|
+
};
|
|
39
43
|
isLoadingCategoryList: boolean;
|
|
40
44
|
isLoadingTemplateList: boolean;
|
|
45
|
+
form: import("antd").FormInstance<any>;
|
|
46
|
+
errors: any[] | undefined;
|
|
41
47
|
refetchCategoryList: <TPageData>(options?: (import("@tanstack/query-core").RefetchOptions & import("@tanstack/query-core").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/query-core").QueryObserverResult<TemplateCategory[], any>>;
|
|
42
48
|
refetchTemplateList: <TPageData_1>(options?: (import("@tanstack/query-core").RefetchOptions & import("@tanstack/query-core").RefetchQueryFilters<TPageData_1>) | undefined) => Promise<import("@tanstack/query-core").QueryObserverResult<import("@tanstack/query-core").InfiniteData<import("@antscorp/antsomi-ui/es/types").ResponseListing<import("../../../../models/ObjectTemplate").ObjectTemplate>>, any>>;
|
|
43
49
|
onLoadMore: () => void;
|
|
@@ -3,6 +3,8 @@ import { useCallback, useMemo, useState } from 'react';
|
|
|
3
3
|
import { useGetTemplateCategoryList, useGetObjectTemplateList, } from '@antscorp/antsomi-ui/es/queries/TemplateListing';
|
|
4
4
|
// Hooks
|
|
5
5
|
import { useDeepCompareMemo } from '@antscorp/antsomi-ui/es/hooks';
|
|
6
|
+
import { Form } from 'antd';
|
|
7
|
+
import { snakeCaseToCamelCase } from '@antscorp/antsomi-ui/es/utils';
|
|
6
8
|
/**
|
|
7
9
|
* Custom React Hook for managing state and data fetching logic related to a template listing.
|
|
8
10
|
*
|
|
@@ -17,10 +19,21 @@ import { useDeepCompareMemo } from '@antscorp/antsomi-ui/es/hooks';
|
|
|
17
19
|
* @property {Function} onLoadMore - A function to load more template data when scrolling in the template listing.
|
|
18
20
|
*/
|
|
19
21
|
export const useTemplateSave = (options) => {
|
|
20
|
-
const { service, config, queriesOptions,
|
|
22
|
+
const { service, config, queriesOptions, defaultValue: valueArg } = options;
|
|
21
23
|
const { objectType, categoryCodes, publicLevel, limitListPerPage = 10, getListType, filter, } = config;
|
|
22
24
|
const { categoryList: categoryListOptions, templateList: templateListOptions } = queriesOptions || {};
|
|
23
25
|
const [value, setValue] = useState(valueArg || {});
|
|
26
|
+
const [errors, setErrors] = useState();
|
|
27
|
+
const formattedCategoriesValue = useMemo(() => {
|
|
28
|
+
var _a;
|
|
29
|
+
const snakeCase = {};
|
|
30
|
+
(_a = value.categories) === null || _a === void 0 ? void 0 : _a.forEach(category => {
|
|
31
|
+
snakeCase[category.key] = category.children;
|
|
32
|
+
});
|
|
33
|
+
const camelCase = snakeCaseToCamelCase(snakeCase);
|
|
34
|
+
return { camelCase, snakeCase };
|
|
35
|
+
}, [value]);
|
|
36
|
+
const [form] = Form.useForm();
|
|
24
37
|
const { data: categoryList, isLoading: isLoadingCategoryList, refetch: refetchCategoryList, } = useGetTemplateCategoryList({
|
|
25
38
|
args: {
|
|
26
39
|
auth: service,
|
|
@@ -68,6 +81,8 @@ export const useTemplateSave = (options) => {
|
|
|
68
81
|
}
|
|
69
82
|
}, [fetchNextPage, hasNextPage, isFetchingNextPage]);
|
|
70
83
|
const onChange = (newValue) => {
|
|
84
|
+
var _a, _b;
|
|
85
|
+
setErrors((_b = (_a = form === null || form === void 0 ? void 0 : form.getFieldsError()) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.errors);
|
|
71
86
|
setValue(newValue);
|
|
72
87
|
};
|
|
73
88
|
return {
|
|
@@ -75,9 +90,14 @@ export const useTemplateSave = (options) => {
|
|
|
75
90
|
categoryItems,
|
|
76
91
|
templateItems,
|
|
77
92
|
value,
|
|
93
|
+
// formattedValue
|
|
94
|
+
formattedCategoriesValue,
|
|
78
95
|
// Values
|
|
79
96
|
isLoadingCategoryList,
|
|
80
97
|
isLoadingTemplateList,
|
|
98
|
+
// Form handler
|
|
99
|
+
form,
|
|
100
|
+
errors,
|
|
81
101
|
// Functions
|
|
82
102
|
refetchCategoryList,
|
|
83
103
|
refetchTemplateList,
|
|
@@ -41,8 +41,6 @@ export declare const LAYOUT_TEMPLATE: {
|
|
|
41
41
|
};
|
|
42
42
|
};
|
|
43
43
|
export declare const TEMPLATE_CATEGORY_KEYS: {
|
|
44
|
-
readonly DEVICE_TYPE: "device_type";
|
|
45
|
-
readonly TEMPLATE_TYPE: "template_type";
|
|
46
44
|
readonly INDUSTRY: "industry";
|
|
47
45
|
readonly SEASONALITY: "seasonality";
|
|
48
46
|
readonly GOAL: "goal";
|
|
@@ -41,8 +41,8 @@ export const LAYOUT_TEMPLATE = {
|
|
|
41
41
|
},
|
|
42
42
|
};
|
|
43
43
|
export const TEMPLATE_CATEGORY_KEYS = {
|
|
44
|
-
DEVICE_TYPE: 'device_type',
|
|
45
|
-
TEMPLATE_TYPE: 'template_type',
|
|
44
|
+
// DEVICE_TYPE: 'device_type',
|
|
45
|
+
// TEMPLATE_TYPE: 'template_type',
|
|
46
46
|
INDUSTRY: 'industry',
|
|
47
47
|
SEASONALITY: 'seasonality',
|
|
48
48
|
GOAL: 'goal',
|
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
package/es/utils/index.d.ts
CHANGED
package/es/utils/index.js
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Constants
|
|
2
|
+
import { TEMPLATE_CATEGORY_KEYS } from '../constants';
|
|
3
|
+
export const getCategoriesFromObjectTemplate = (objectTemplate) => {
|
|
4
|
+
const categories = {};
|
|
5
|
+
Object.values(TEMPLATE_CATEGORY_KEYS).forEach(key => {
|
|
6
|
+
var _a, _b, _c;
|
|
7
|
+
if (((_a = objectTemplate.model) === null || _a === void 0 ? void 0 : _a[key]) && ((_c = (_b = objectTemplate.model) === null || _b === void 0 ? void 0 : _b[key]) === null || _c === void 0 ? void 0 : _c.length)) {
|
|
8
|
+
categories[key] = objectTemplate.model[key];
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
return categories;
|
|
12
|
+
};
|