@antscorp/antsomi-ui 1.3.5-beta.178 → 1.3.5-beta.179
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.
|
@@ -14,10 +14,16 @@ import { get, omit } from 'lodash';
|
|
|
14
14
|
import { templateListingServices, } from '@antscorp/antsomi-ui/es/services/TemplateListing';
|
|
15
15
|
// Constants
|
|
16
16
|
import { QUERY_KEYS } from '../../constants/queries';
|
|
17
|
+
import { PUBLIC_LEVEL } from '../../constants';
|
|
17
18
|
const { category, objectTemplate } = templateListingServices;
|
|
18
19
|
export const useGetTemplateCategoryList = (params) => {
|
|
19
20
|
const { options, args } = params;
|
|
20
|
-
return useQuery(Object.assign({ queryKey: [QUERY_KEYS.GET_TEMPLATE_CATEGORY_LIST, args.params], queryFn: () =>
|
|
21
|
+
return useQuery(Object.assign({ queryKey: [QUERY_KEYS.GET_TEMPLATE_CATEGORY_LIST, args.params], queryFn: () => {
|
|
22
|
+
var _a;
|
|
23
|
+
return ((_a = args === null || args === void 0 ? void 0 : args.params) === null || _a === void 0 ? void 0 : _a.publicLevel) === PUBLIC_LEVEL.PUBLIC
|
|
24
|
+
? category.getPublicList(params.args)
|
|
25
|
+
: category.getList(params.args);
|
|
26
|
+
}, onSuccess() { } }, options));
|
|
21
27
|
};
|
|
22
28
|
export const useGetSaveAsGalleryPermissionEmails = (params) => {
|
|
23
29
|
const { options } = params;
|
|
@@ -26,7 +32,10 @@ export const useGetSaveAsGalleryPermissionEmails = (params) => {
|
|
|
26
32
|
export const useGetObjectTemplateList = (params) => {
|
|
27
33
|
const { options, args } = params;
|
|
28
34
|
return useInfiniteQuery(Object.assign({ queryKey: [QUERY_KEYS.GET_OBJECT_TEMPLATE_LIST, args.params], queryFn: (_a) => __awaiter(void 0, [_a], void 0, function* ({ pageParam = 1 }) {
|
|
29
|
-
|
|
35
|
+
var _b;
|
|
36
|
+
const res = ((_b = args === null || args === void 0 ? void 0 : args.params) === null || _b === void 0 ? void 0 : _b.public_level) === PUBLIC_LEVEL.PUBLIC
|
|
37
|
+
? yield objectTemplate.getPublicList(Object.assign(Object.assign({}, args), { params: Object.assign(Object.assign({}, args.params), { page: pageParam }) }))
|
|
38
|
+
: yield objectTemplate.getList(Object.assign(Object.assign({}, args), { params: Object.assign(Object.assign({}, args.params), { page: pageParam }) }));
|
|
30
39
|
return res;
|
|
31
40
|
}), getNextPageParam: lastPage => {
|
|
32
41
|
const { meta } = lastPage;
|
|
@@ -29,6 +29,7 @@ export type TGetObjectTemplateListArgs = {
|
|
|
29
29
|
} & PaginationRequest;
|
|
30
30
|
auth: TServiceAuth;
|
|
31
31
|
};
|
|
32
|
+
export type TGetPublicObjectTemplateListArgs = Omit<TGetObjectTemplateListArgs, 'auth'>;
|
|
32
33
|
export type TBulkUpdateObjectTemplateArgs = {
|
|
33
34
|
params: {
|
|
34
35
|
template_ids: number[];
|
|
@@ -58,9 +59,11 @@ export type TValidateObjectTemplateNameArgs = {
|
|
|
58
59
|
export declare const templateListingServices: {
|
|
59
60
|
category: {
|
|
60
61
|
getList: ({ params, auth }: TGetCategoryListArgs) => Promise<TemplateCategory[]>;
|
|
62
|
+
getPublicList: ({ params, auth }: TGetCategoryListArgs) => Promise<TemplateCategory[]>;
|
|
61
63
|
};
|
|
62
64
|
objectTemplate: {
|
|
63
65
|
getList: ({ params, auth, }: TGetObjectTemplateListArgs) => Promise<ResponseListing<ObjectTemplate>>;
|
|
66
|
+
getPublicList: ({ params, auth, }: TGetObjectTemplateListArgs) => Promise<ResponseListing<ObjectTemplate>>;
|
|
64
67
|
getDetail: ({ params, auth }: TGetObjectTemplateDetailArgs) => Promise<ObjectTemplate>;
|
|
65
68
|
create: ({ data, auth }: TCreateObjectTemplateArgs) => Promise<ObjectTemplate>;
|
|
66
69
|
update: ({ data, auth }: TUpdateObjectTemplateArgs) => Promise<ObjectTemplate>;
|
|
@@ -43,9 +43,23 @@ export const templateListingServices = {
|
|
|
43
43
|
return Promise.reject(error);
|
|
44
44
|
}
|
|
45
45
|
}),
|
|
46
|
+
getPublicList: (_b) => __awaiter(void 0, [_b], void 0, function* ({ params, auth }) {
|
|
47
|
+
try {
|
|
48
|
+
const { objectTypes = [], categoryCodes } = params;
|
|
49
|
+
const response = yield axios({
|
|
50
|
+
method: 'GET',
|
|
51
|
+
url: `${auth.url}/${TEMPLATE_CATEGORY_ROUTE}/get-public`,
|
|
52
|
+
params: Object.assign({ _token: auth.token, objectTypes: objectTypes.join(',') }, (!isEmpty(categoryCodes) ? { categoryCodes: categoryCodes === null || categoryCodes === void 0 ? void 0 : categoryCodes.join(',') } : {})),
|
|
53
|
+
});
|
|
54
|
+
return get(response, 'data.data', []);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
return Promise.reject(error);
|
|
58
|
+
}
|
|
59
|
+
}),
|
|
46
60
|
},
|
|
47
61
|
objectTemplate: {
|
|
48
|
-
getList: (
|
|
62
|
+
getList: (_c) => __awaiter(void 0, [_c], void 0, function* ({ params, auth, }) {
|
|
49
63
|
try {
|
|
50
64
|
const response = yield axios({
|
|
51
65
|
method: 'GET',
|
|
@@ -62,7 +76,24 @@ export const templateListingServices = {
|
|
|
62
76
|
return Promise.reject(error);
|
|
63
77
|
}
|
|
64
78
|
}),
|
|
65
|
-
|
|
79
|
+
getPublicList: (_d) => __awaiter(void 0, [_d], void 0, function* ({ params, auth, }) {
|
|
80
|
+
try {
|
|
81
|
+
const response = yield axios({
|
|
82
|
+
method: 'GET',
|
|
83
|
+
url: `${auth.url}/${OBJECT_TEMPLATE_ROUTE}/public/get-gallery-template-list`,
|
|
84
|
+
params: Object.assign({}, params),
|
|
85
|
+
});
|
|
86
|
+
const { entities, meta } = get(response, 'data.data', {});
|
|
87
|
+
return {
|
|
88
|
+
entities: entities.map(entity => new ObjectTemplate(entity)),
|
|
89
|
+
meta,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
return Promise.reject(error);
|
|
94
|
+
}
|
|
95
|
+
}),
|
|
96
|
+
getDetail: (_e) => __awaiter(void 0, [_e], void 0, function* ({ params, auth }) {
|
|
66
97
|
try {
|
|
67
98
|
const { template_id } = params, restOfPrams = __rest(params, ["template_id"]);
|
|
68
99
|
const response = yield axios({
|
|
@@ -76,7 +107,7 @@ export const templateListingServices = {
|
|
|
76
107
|
return Promise.reject(error);
|
|
77
108
|
}
|
|
78
109
|
}),
|
|
79
|
-
create: (
|
|
110
|
+
create: (_f) => __awaiter(void 0, [_f], void 0, function* ({ data, auth }) {
|
|
80
111
|
try {
|
|
81
112
|
const response = yield axios({
|
|
82
113
|
method: 'POST',
|
|
@@ -94,7 +125,7 @@ export const templateListingServices = {
|
|
|
94
125
|
return Promise.reject(error);
|
|
95
126
|
}
|
|
96
127
|
}),
|
|
97
|
-
update: (
|
|
128
|
+
update: (_g) => __awaiter(void 0, [_g], void 0, function* ({ data, auth }) {
|
|
98
129
|
try {
|
|
99
130
|
const { template_id } = data, restOfData = __rest(data, ["template_id"]);
|
|
100
131
|
const response = yield axios({
|
|
@@ -113,7 +144,7 @@ export const templateListingServices = {
|
|
|
113
144
|
return Promise.reject(error);
|
|
114
145
|
}
|
|
115
146
|
}),
|
|
116
|
-
bulkUpdate: (
|
|
147
|
+
bulkUpdate: (_h) => __awaiter(void 0, [_h], void 0, function* ({ params, auth }) {
|
|
117
148
|
try {
|
|
118
149
|
const response = yield axios({
|
|
119
150
|
method: 'POST',
|
|
@@ -132,7 +163,7 @@ export const templateListingServices = {
|
|
|
132
163
|
return Promise.reject(error);
|
|
133
164
|
}
|
|
134
165
|
}),
|
|
135
|
-
validateName: (
|
|
166
|
+
validateName: (_j) => __awaiter(void 0, [_j], void 0, function* ({ params, auth, }) {
|
|
136
167
|
try {
|
|
137
168
|
const response = yield axios({
|
|
138
169
|
method: 'POST',
|
|
@@ -145,7 +176,7 @@ export const templateListingServices = {
|
|
|
145
176
|
return Promise.reject(error);
|
|
146
177
|
}
|
|
147
178
|
}),
|
|
148
|
-
getSaveAsGalleryPermission: (
|
|
179
|
+
getSaveAsGalleryPermission: (_k) => __awaiter(void 0, [_k], void 0, function* ({ auth, }) {
|
|
149
180
|
try {
|
|
150
181
|
const response = yield axios({
|
|
151
182
|
method: 'GET',
|