@antscorp/antsomi-ui 1.3.5-beta.56 → 1.3.5-beta.58
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.js +24 -20
- package/es/components/template/TemplateListing/hooks/useTemplateListing.js +5 -2
- package/es/constants/queries.d.ts +1 -0
- package/es/constants/queries.js +1 -0
- package/es/queries/TemplateListing/index.d.ts +6 -1
- package/es/queries/TemplateListing/index.js +4 -0
- package/es/services/TemplateListing/index.d.ts +4 -0
- package/es/services/TemplateListing/index.js +12 -0
- package/package.json +1 -1
|
@@ -39,6 +39,12 @@ export const TemplateSaveAs = props => {
|
|
|
39
39
|
}, [searchValueDebounce, onSearch]);
|
|
40
40
|
const [templateName, setTemplateName] = useState(defaultNewTemplateName || `Untitled Media Template#${dayjs().format('YYYY-MM-DD HH:mm:ss')}`);
|
|
41
41
|
const [templateNameExist, setTemplateNameExist] = useState((defaultTemplateName === null || defaultTemplateName === void 0 ? void 0 : defaultTemplateName.id) ? defaultTemplateName : templateNames === null || templateNames === void 0 ? void 0 : templateNames[0]);
|
|
42
|
+
// NOTE: HOTFIX templateNameExist not update when value outside changed
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (defaultTemplateName) {
|
|
45
|
+
setTemplateNameExist(defaultTemplateName);
|
|
46
|
+
}
|
|
47
|
+
}, [defaultTemplateName]);
|
|
42
48
|
const handleChangeValue = (newValue) => {
|
|
43
49
|
var _a, _b;
|
|
44
50
|
if (onEvent) {
|
|
@@ -49,11 +55,7 @@ export const TemplateSaveAs = props => {
|
|
|
49
55
|
// TODO: return saveOption and templateName generate default value if not pass as value props
|
|
50
56
|
defaultThumbnail: newValue.defaultThumbnail || defaultThumbnail, saveOption: !(value === null || value === void 0 ? void 0 : value.saveOption) && !newValue.saveOption
|
|
51
57
|
? saveOption
|
|
52
|
-
: newValue.saveOption || (value === null || value === void 0 ? void 0 : value.saveOption),
|
|
53
|
-
? saveOption === saveNewValue
|
|
54
|
-
? { id: undefined, label: templateName }
|
|
55
|
-
: templateNameExist
|
|
56
|
-
: 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);
|
|
58
|
+
: newValue.saveOption || (value === null || value === void 0 ? void 0 : value.saveOption) }), (_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);
|
|
57
59
|
}
|
|
58
60
|
};
|
|
59
61
|
const handleAddCategory = ({ parentKey, item, }) => {
|
|
@@ -82,12 +84,14 @@ export const TemplateSaveAs = props => {
|
|
|
82
84
|
} },
|
|
83
85
|
React.createElement(TemplateSaveAsStyled, { className: className || '', vertical: true },
|
|
84
86
|
React.createElement(Flex, { className: "save-options-container" },
|
|
85
|
-
React.createElement(RadioGroup, { value: saveOption, onChange: e =>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
React.createElement(RadioGroup, { value: saveOption, onChange: e => {
|
|
88
|
+
handleChangeValue({
|
|
89
|
+
saveOption: e.target.value,
|
|
90
|
+
templateName: e.target.value === saveNewValue
|
|
91
|
+
? { id: templateNameExist.id, label: templateName }
|
|
92
|
+
: templateNameExist,
|
|
93
|
+
});
|
|
94
|
+
} },
|
|
91
95
|
React.createElement(Radio, { value: saveNewValue }, saveNewText),
|
|
92
96
|
React.createElement(Radio, { value: saveExistValue }, saveExistText))),
|
|
93
97
|
React.createElement(Flex, null,
|
|
@@ -109,8 +113,15 @@ export const TemplateSaveAs = props => {
|
|
|
109
113
|
justifyContent: 'center',
|
|
110
114
|
alignItems: 'center',
|
|
111
115
|
} },
|
|
112
|
-
React.createElement(Spin, { size: "small" }))) : null)), value: templateNameExist === null || templateNameExist === void 0 ? void 0 : templateNameExist.id, options:
|
|
113
|
-
|
|
116
|
+
React.createElement(Spin, { size: "small" }))) : null)), value: templateNameExist === null || templateNameExist === void 0 ? void 0 : templateNameExist.id, options:
|
|
117
|
+
// If template exist is not in templateNames list => add to begin of options array
|
|
118
|
+
(templateNames === null || templateNames === void 0 ? void 0 : templateNames.length) > 0
|
|
119
|
+
? [
|
|
120
|
+
...(templateNames.find(item => item.id === templateNameExist.id)
|
|
121
|
+
? []
|
|
122
|
+
: [{ value: templateNameExist.id, label: templateNameExist.label }]),
|
|
123
|
+
...templateNames.map(item => ({ value: item.id, label: item.label })),
|
|
124
|
+
]
|
|
114
125
|
: [], onChange: value => {
|
|
115
126
|
var _a, _b;
|
|
116
127
|
handleChangeValue({
|
|
@@ -135,15 +146,8 @@ export const TemplateSaveAs = props => {
|
|
|
135
146
|
React.createElement(ImageSlider, { thumbnails: thumbnails, isLoading: isLoadingThumbnail, skeleton: skeleton, previewNavigation: previewNavigation, slidesPerView: slidesPerView, defaultThumbnail: defaultThumbnail, onSelectDefault: value => handleChangeValue({ defaultThumbnail: value }), hideThumbnailsList: hideThumbnailsList, hideDefaultButton: hideDefaultButton, imageHeight: imageHeight, imageWidth: imageWidth })), categories === null || categories === void 0 ? void 0 :
|
|
136
147
|
categories.map(parentCategory => {
|
|
137
148
|
var _a, _b;
|
|
138
|
-
// const selectedChildren = categoriesValue
|
|
139
|
-
// .find(item => item.label === parentCategory.label)
|
|
140
|
-
// ?.children.map(item => item.label);
|
|
141
149
|
const selectedChildren = categoriesValue[parentCategory.key];
|
|
142
150
|
const remainChildren = parentCategory.children.filter(item => !(selectedChildren === null || selectedChildren === void 0 ? void 0 : selectedChildren.includes(item.key)));
|
|
143
|
-
// const formatData = remainChildren.map((item, idx) => ({
|
|
144
|
-
// label: item.label,
|
|
145
|
-
// key: idx,
|
|
146
|
-
// }));
|
|
147
151
|
// NOTE: filter to remove device and template categories
|
|
148
152
|
if ((omitCategories === null || omitCategories === void 0 ? void 0 : omitCategories.length) && omitCategories.includes(parentCategory.key.toString()))
|
|
149
153
|
return null;
|
|
@@ -95,7 +95,7 @@ export const useTemplateListing = (options) => {
|
|
|
95
95
|
},
|
|
96
96
|
},
|
|
97
97
|
});
|
|
98
|
-
const { data: templateDetail, isLoading: isLoadingTemplateDetail } = useGetObjectTemplateDetail({
|
|
98
|
+
const { data: templateDetail, isLoading: isLoadingTemplateDetail = false } = useGetObjectTemplateDetail({
|
|
99
99
|
args: {
|
|
100
100
|
params: {
|
|
101
101
|
template_id: selectedTemplateId || '',
|
|
@@ -104,6 +104,9 @@ export const useTemplateListing = (options) => {
|
|
|
104
104
|
},
|
|
105
105
|
auth: serviceAuth,
|
|
106
106
|
},
|
|
107
|
+
options: {
|
|
108
|
+
enabled: !!selectedTemplateId,
|
|
109
|
+
},
|
|
107
110
|
});
|
|
108
111
|
// Variables
|
|
109
112
|
const isLoadingTemplateList = isFetching || isFetchingNextPage;
|
|
@@ -212,7 +215,7 @@ export const useTemplateListing = (options) => {
|
|
|
212
215
|
previewTemplateCategories,
|
|
213
216
|
isLoadingCategoryList,
|
|
214
217
|
isLoadingTemplateList,
|
|
215
|
-
isLoadingTemplateDetail,
|
|
218
|
+
isLoadingTemplateDetail: isLoadingTemplateDetail && !!selectedTemplateId,
|
|
216
219
|
// Functions
|
|
217
220
|
refetchCategoryList,
|
|
218
221
|
refetchTemplateList,
|
package/es/constants/queries.js
CHANGED
|
@@ -22,4 +22,5 @@ export const QUERY_KEYS = {
|
|
|
22
22
|
GET_TEMPLATE_CATEGORY_LIST: 'GET_TEMPLATE_CATEGORY_LIST',
|
|
23
23
|
GET_OBJECT_TEMPLATE_LIST: 'GET_OBJECT_TEMPLATE_LIST',
|
|
24
24
|
GET_OBJECT_TEMPLATE_DETAIL: 'GET_OBJECT_TEMPLATE_DETAIL',
|
|
25
|
+
GET_SAVE_AS_GALLERY_PERMISSION_EMAILS: 'GET_SAVE_AS_GALLERY_PERMISSION_EMAILS',
|
|
25
26
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UseInfiniteQueryOptions, UseMutationOptions, UseQueryOptions } from '@tanstack/react-query';
|
|
2
2
|
import { TemplateCategory } from '@antscorp/antsomi-ui/es/models/TemplateCategory';
|
|
3
|
-
import { TBulkUpdateObjectTemplateArgs, TGetCategoryListArgs, TGetObjectTemplateDetailArgs, TGetObjectTemplateListArgs, TUpdateObjectTemplateArgs, TValidateObjectTemplateNameArgs } from '@antscorp/antsomi-ui/es/services/TemplateListing';
|
|
3
|
+
import { TBulkUpdateObjectTemplateArgs, TGetCategoryListArgs, TGetObjectTemplateDetailArgs, TGetObjectTemplateListArgs, TGetSaveAsGalleryPermissionArgs, TUpdateObjectTemplateArgs, TValidateObjectTemplateNameArgs } from '@antscorp/antsomi-ui/es/services/TemplateListing';
|
|
4
4
|
import { ResponseCheckNameExist, ResponseListing } from '../../types';
|
|
5
5
|
import { ObjectTemplate } from '../../models/ObjectTemplate';
|
|
6
6
|
import { TCreateObjectTemplateArgs } from '../../services/TemplateListing';
|
|
@@ -8,6 +8,10 @@ export type TGetTemplateCategoryList = {
|
|
|
8
8
|
args: TGetCategoryListArgs;
|
|
9
9
|
options?: UseQueryOptions<any, any, TemplateCategory[], any[]>;
|
|
10
10
|
};
|
|
11
|
+
export type TGetSaveAsGalleryPermissionEmails = {
|
|
12
|
+
args: TGetSaveAsGalleryPermissionArgs;
|
|
13
|
+
options?: UseQueryOptions<any, any, string[], any[]>;
|
|
14
|
+
};
|
|
11
15
|
export type TGetObjectTEmplateList = {
|
|
12
16
|
args: TGetObjectTemplateListArgs;
|
|
13
17
|
options?: UseInfiniteQueryOptions<any, any, ResponseListing<ObjectTemplate>, (string | number)[]>;
|
|
@@ -35,6 +39,7 @@ export type TUsePersistTemplate = {
|
|
|
35
39
|
}, unknown>;
|
|
36
40
|
};
|
|
37
41
|
export declare const useGetTemplateCategoryList: (params: TGetTemplateCategoryList) => import("@tanstack/react-query").UseQueryResult<TemplateCategory[], any>;
|
|
42
|
+
export declare const useGetSaveAsGalleryPermissionEmails: (params: TGetSaveAsGalleryPermissionEmails) => import("@tanstack/react-query").UseQueryResult<string[], any>;
|
|
38
43
|
export declare const useGetObjectTemplateList: (params: TGetObjectTEmplateList) => import("@tanstack/react-query").UseInfiniteQueryResult<ResponseListing<ObjectTemplate>, any>;
|
|
39
44
|
export declare const useGetObjectTemplateDetail: (params: TGetObjectTemplateDetail) => import("@tanstack/react-query").UseQueryResult<ObjectTemplate, any>;
|
|
40
45
|
export declare const useValidateTemplateName: (params: TUseValidateTemplateName) => import("@tanstack/react-query").UseMutationResult<ResponseCheckNameExist, any, TValidateObjectTemplateNameArgs, unknown>;
|
|
@@ -20,6 +20,10 @@ export const useGetTemplateCategoryList = (params) => {
|
|
|
20
20
|
const { options, args } = params;
|
|
21
21
|
return useQuery(Object.assign({ queryKey: [QUERY_KEYS.GET_TEMPLATE_CATEGORY_LIST, args.params], queryFn: () => category.getList(params.args), onSuccess() { } }, options));
|
|
22
22
|
};
|
|
23
|
+
export const useGetSaveAsGalleryPermissionEmails = (params) => {
|
|
24
|
+
const { options } = params;
|
|
25
|
+
return useQuery(Object.assign({ queryKey: [QUERY_KEYS.GET_SAVE_AS_GALLERY_PERMISSION_EMAILS], queryFn: () => objectTemplate.getSaveAsGalleryPermission(params.args), onSuccess() { } }, options));
|
|
26
|
+
};
|
|
23
27
|
export const useGetObjectTemplateList = (params) => {
|
|
24
28
|
const { options, args } = params;
|
|
25
29
|
return useInfiniteQuery(Object.assign({ queryKey: [QUERY_KEYS.GET_OBJECT_TEMPLATE_LIST, args.params], queryFn: ({ pageParam = 1 }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -42,6 +42,9 @@ export type TCreateObjectTemplateArgs = {
|
|
|
42
42
|
data: Partial<TObjectTemplate>;
|
|
43
43
|
auth: TServiceAuth;
|
|
44
44
|
};
|
|
45
|
+
export type TGetSaveAsGalleryPermissionArgs = {
|
|
46
|
+
auth: TServiceAuth;
|
|
47
|
+
};
|
|
45
48
|
export type TValidateObjectTemplateNameArgs = {
|
|
46
49
|
params: {
|
|
47
50
|
template_name: string;
|
|
@@ -61,5 +64,6 @@ export declare const templateListingServices: {
|
|
|
61
64
|
update: ({ data, auth }: TUpdateObjectTemplateArgs) => Promise<ObjectTemplate>;
|
|
62
65
|
bulkUpdate: ({ params, auth }: TBulkUpdateObjectTemplateArgs) => Promise<any>;
|
|
63
66
|
validateName: ({ params, auth, }: TValidateObjectTemplateNameArgs) => Promise<ResponseCheckNameExist>;
|
|
67
|
+
getSaveAsGalleryPermission: ({ auth, }: TGetSaveAsGalleryPermissionArgs) => Promise<string[]>;
|
|
64
68
|
};
|
|
65
69
|
};
|
|
@@ -145,5 +145,17 @@ export const templateListingServices = {
|
|
|
145
145
|
return Promise.reject(error);
|
|
146
146
|
}
|
|
147
147
|
}),
|
|
148
|
+
getSaveAsGalleryPermission: ({ auth, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
149
|
+
try {
|
|
150
|
+
const response = yield axios({
|
|
151
|
+
method: 'GET',
|
|
152
|
+
url: `${auth.url}/${OBJECT_TEMPLATE_ROUTE}/save-as-gallery-permission-emails`,
|
|
153
|
+
});
|
|
154
|
+
return get(response, 'data.data', []);
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
return Promise.reject(error);
|
|
158
|
+
}
|
|
159
|
+
}),
|
|
148
160
|
},
|
|
149
161
|
};
|