@antscorp/antsomi-ui 1.3.5-beta.264 → 1.3.5-beta.266
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/ImageEditor/ImageEditor.d.ts +1 -0
- package/es/components/molecules/ImageEditor/ImageEditor.js +2 -2
- package/es/components/molecules/TemplateSaveAs/components/ImageSlider/ImageSlider.js +10 -14
- package/es/components/molecules/TemplateSaveAs/components/ImageSlider/styled.js +6 -1
- package/es/components/organism/ContentSources/Settings.js +44 -3
- package/es/components/organism/ContentSources/provider.d.ts +3 -0
- package/es/components/organism/ContentSources/provider.js +29 -0
- package/es/components/organism/ContentSources/reducer.d.ts +2 -1
- package/es/components/organism/ContentSources/reducer.js +17 -0
- package/es/components/organism/ContentSources/types.d.ts +7 -1
- package/es/components/organism/index.d.ts +1 -0
- package/es/components/organism/index.js +1 -0
- package/es/constants/queries.d.ts +1 -0
- package/es/constants/queries.js +1 -0
- package/es/queries/BusinessObject/useGetDataTableBO.d.ts +6 -0
- package/es/queries/BusinessObject/useGetDataTableBO.js +26 -0
- package/es/services/ThirParty/TableBO/index.d.ts +6 -0
- package/es/services/ThirParty/TableBO/index.js +28 -0
- package/es/services/index.d.ts +1 -0
- package/es/services/index.js +23 -0
- package/package.json +1 -1
|
@@ -13,6 +13,7 @@ interface ImageEditorProps {
|
|
|
13
13
|
imageUrl?: string;
|
|
14
14
|
defaultValue?: CanvasState;
|
|
15
15
|
showSelection?: boolean;
|
|
16
|
+
style?: Omit<React.CSSProperties, 'width'>;
|
|
16
17
|
}
|
|
17
18
|
export declare const ImageEditor: React.ForwardRefExoticComponent<ImageEditorProps & React.RefAttributes<ImageResizeHandle>>;
|
|
18
19
|
export {};
|
|
@@ -25,7 +25,7 @@ import { downloadURI, getTransformData } from './utils';
|
|
|
25
25
|
import { StageWrapperStyled } from './styled';
|
|
26
26
|
const SNAP_THRESHOLD = 5;
|
|
27
27
|
export const ImageEditor = React.forwardRef((props, ref) => {
|
|
28
|
-
const { defaultValue, className, width, height, hideAction, imageUrl = '', showSelection, } = props;
|
|
28
|
+
const { defaultValue, className, width, height, hideAction, imageUrl = '', showSelection, style, } = props;
|
|
29
29
|
const [color, setColor] = useState('#000');
|
|
30
30
|
const [drawAction, setDrawAction] = useState(DrawAction.Select);
|
|
31
31
|
const [cropZone, setCropZone] = useState();
|
|
@@ -618,7 +618,7 @@ export const ImageEditor = React.forwardRef((props, ref) => {
|
|
|
618
618
|
target.setAbsolutePosition(newPos);
|
|
619
619
|
// selectedNode.setAbsolutePosition(newPos);
|
|
620
620
|
}, []);
|
|
621
|
-
return (React.createElement("div", { style: { width: `${width}px` } },
|
|
621
|
+
return (React.createElement("div", { style: Object.assign({ width: `${width}px` }, (style || {})) },
|
|
622
622
|
React.createElement(Flex, { justify: "space-between", align: "center", style: { marginBottom: '6px', display: hideAction ? 'none' : 'flex' } },
|
|
623
623
|
React.createElement(Flex, { gap: 4 },
|
|
624
624
|
PAINT_OPTIONS.map(({ id, label, icon }) => (React.createElement(Button, { key: id, "aria-label": label, icon: React.createElement(Icon, { type: icon, style: { fontSize: '16px' } }), onClick: () => {
|
|
@@ -110,26 +110,22 @@ export const ImageSlider = props => {
|
|
|
110
110
|
const currentTime = useMemo(() => new Date(), []);
|
|
111
111
|
const timeGenerated = Math.floor(currentTime.getTime() / 1000 - (currentTime.getTime() % 3)) * 1000;
|
|
112
112
|
const currentEditing = useMemo(() => editingThumbnail !== null && editingThumbnail !== void 0 ? editingThumbnail : uploadThumbnail, [editingThumbnail, uploadThumbnail]);
|
|
113
|
-
const imageResizeProps = {
|
|
114
|
-
className: 'image-resize-wrapper',
|
|
115
|
-
width: imageWidth,
|
|
116
|
-
height: imageHeight,
|
|
117
|
-
ref: imageResizeRef,
|
|
118
|
-
hideAction: true,
|
|
119
|
-
imageUrl:
|
|
120
|
-
// latestCanvas && isEditPrevious
|
|
121
|
-
(latestCanvas === null || latestCanvas === void 0 ? void 0 : latestCanvas[currentEditing])
|
|
122
|
-
? undefined
|
|
123
|
-
: getUrlNoCache(thumbnails[currentEditing], timeGenerated),
|
|
124
|
-
defaultValue: latestCanvas === null || latestCanvas === void 0 ? void 0 : latestCanvas[currentEditing],
|
|
125
|
-
};
|
|
126
113
|
const ImageResizeComponent = useFabric ? ImageResizeTuiEditor : ImageResize;
|
|
127
114
|
const showSkeletonMemo = skeleton !== undefined
|
|
128
115
|
? skeleton
|
|
129
116
|
: checkShowSkeletonBaseUrl(getUrlNoCache(thumbnails[currentEditing], timeGenerated));
|
|
130
117
|
return (React.createElement(ImageSliderStyled, { className: className || '', "$skeleton": skeleton, "$imageWidth": imageWidth, "$smallImageWidth": smallImageWidth, "$imageHeight": imageHeight, vertical: true, gap: 10 },
|
|
131
118
|
React.createElement(Flex, { vertical: true, style: { zIndex: 25, display: !isNil(currentEditing) ? 'flex' : 'none' }, className: `edit-thumbnail-container ${!isNil(currentEditing) ? 'is-editing' : ''}` },
|
|
132
|
-
React.createElement(ImageResizeComponent,
|
|
119
|
+
React.createElement(ImageResizeComponent, { style: { visibility: typeof uploadThumbnail === 'number' ? 'hidden' : 'visible' }, className: "image-resize-wrapper", width: imageWidth, height: imageHeight, ref: imageResizeRef, hideAction: true, imageUrl:
|
|
120
|
+
// latestCanvas && isEditPrevious
|
|
121
|
+
(latestCanvas === null || latestCanvas === void 0 ? void 0 : latestCanvas[currentEditing])
|
|
122
|
+
? undefined
|
|
123
|
+
: getUrlNoCache(thumbnails[currentEditing], timeGenerated),
|
|
124
|
+
// imageUrl={getUrlNoCache(
|
|
125
|
+
// thumbnails[editingThumbnail ?? (uploadThumbnail as number)],
|
|
126
|
+
// timeGenerated,
|
|
127
|
+
// )}
|
|
128
|
+
defaultValue: latestCanvas === null || latestCanvas === void 0 ? void 0 : latestCanvas[currentEditing] }),
|
|
133
129
|
typeof uploadThumbnail !== 'number' ? null : (React.createElement(Flex, { className: `image-upload-zone ${!showSkeletonMemo ? 'hide-skeleton' : ''}` },
|
|
134
130
|
React.createElement(Icon, { type: "icon-ants-upload-fill", style: { fontSize: '40px' } }),
|
|
135
131
|
React.createElement(Flex, { vertical: true, align: "flex-start" },
|
|
@@ -80,7 +80,12 @@ export const ImageSliderStyled = styled(Flex) `
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
&:not(.hide-skeleton) {
|
|
83
|
-
background: ${props =>
|
|
83
|
+
background: ${props => {
|
|
84
|
+
var _a;
|
|
85
|
+
return props.$skeleton
|
|
86
|
+
? `url(${SkeletonBg}) no-repeat center center`
|
|
87
|
+
: (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.colorBgSkeleton;
|
|
88
|
+
}};
|
|
84
89
|
|
|
85
90
|
background-size: 90% 90%;
|
|
86
91
|
}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
// Libraries
|
|
2
11
|
import React, { memo, useEffect, useLayoutEffect, useState } from 'react';
|
|
3
12
|
import { get, isArray, isEmpty, set } from 'lodash';
|
|
@@ -16,12 +25,13 @@ import { FILTERS_DEFAULT, ITEM_TYPE_NAME, PRODUCT_ITEM_TYPE_ID, PRODUCT_RANKING_
|
|
|
16
25
|
// Queries
|
|
17
26
|
import { useGetListBO } from '@antscorp/antsomi-ui/es/queries/BusinessObject';
|
|
18
27
|
import { useGetListFallbackBO } from '@antscorp/antsomi-ui/es/queries/ThirdParty';
|
|
28
|
+
import { getDataTableBOQuery } from '@antscorp/antsomi-ui/es/queries/BusinessObject/useGetDataTableBO';
|
|
19
29
|
// Hooks
|
|
20
30
|
import { useDeepCompareEffect } from '@antscorp/antsomi-ui/es/hooks';
|
|
21
31
|
import { useDebounce } from '@antscorp/antsomi-ui/es/hooks/useDebounceV2';
|
|
22
32
|
// Provider
|
|
23
|
-
import { useContentSourceDispatch, useSelectContentSources, useSelectModeView } from './provider';
|
|
24
|
-
import { deleteContentSourceGroup, setContentSourceGroup, updateContentSourceSettings, updateModeView, } from './reducer';
|
|
33
|
+
import { useContentSourceDispatch, useSelectBoIdByGroupFromCS, useSelectContentSources, useSelectModeView, } from './provider';
|
|
34
|
+
import { deleteContentSourceGroup, setContentSourceGroup, setContentSourceGroupBOData, updateContentSourceSettings, updateModeView, } from './reducer';
|
|
25
35
|
// Utils
|
|
26
36
|
import { handleError } from '@antscorp/antsomi-ui/es/utils';
|
|
27
37
|
const PATH = 'src/components/organism/ContentSources/Settings.tsx';
|
|
@@ -29,11 +39,13 @@ const Settings = (props) => {
|
|
|
29
39
|
const { serviceAuth, mode, isShowErrorAlert, initValue, journeySettings, onChange } = props;
|
|
30
40
|
const { url = '', userId, token, accountId } = serviceAuth;
|
|
31
41
|
const { t } = i18nInstance;
|
|
42
|
+
const boIdByGroupCS = useSelectBoIdByGroupFromCS();
|
|
32
43
|
const contentSources = useSelectContentSources();
|
|
33
44
|
const { groups, expanded } = contentSources;
|
|
34
45
|
const modeView = useSelectModeView();
|
|
35
46
|
const isCDP = modeView === 'CDP';
|
|
36
47
|
const [isInitDataCDPDone, setIsInitDataCDPDone] = useState(false);
|
|
48
|
+
const [isLoadingDataTableBO, setIsLoadingDataTableBO] = useState(false);
|
|
37
49
|
const contentSourcesDebounce = useDebounce(contentSources, 400);
|
|
38
50
|
const { data: listBO, isLoading: isLoadingListBO, refetch: refetchListBO, } = useGetListBO({
|
|
39
51
|
url,
|
|
@@ -232,6 +244,35 @@ const Settings = (props) => {
|
|
|
232
244
|
}
|
|
233
245
|
}
|
|
234
246
|
}, [initValue, contentSourceDispatch, isCDP]);
|
|
247
|
+
useDeepCompareEffect(() => {
|
|
248
|
+
let ignore = false;
|
|
249
|
+
if (!isEmpty(boIdByGroupCS) && !isEmpty(serviceAuth)) {
|
|
250
|
+
const groupKeyList = Object.keys(boIdByGroupCS);
|
|
251
|
+
const fetchListCSDataTableBO = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
252
|
+
const listPromises = [];
|
|
253
|
+
groupKeyList.forEach(groupId => {
|
|
254
|
+
const itemTypeId = boIdByGroupCS[groupId];
|
|
255
|
+
const promise = getDataTableBOQuery(serviceAuth, itemTypeId, { groupId });
|
|
256
|
+
listPromises.push(promise);
|
|
257
|
+
});
|
|
258
|
+
setIsLoadingDataTableBO(true);
|
|
259
|
+
const listBOResponses = yield Promise.all(listPromises);
|
|
260
|
+
const boDataByGroupId = {};
|
|
261
|
+
listBOResponses.forEach(item => {
|
|
262
|
+
const { data, params } = item;
|
|
263
|
+
boDataByGroupId[params.groupId] = data.data;
|
|
264
|
+
});
|
|
265
|
+
if (!ignore) {
|
|
266
|
+
contentSourceDispatch(setContentSourceGroupBOData(boDataByGroupId));
|
|
267
|
+
}
|
|
268
|
+
setIsLoadingDataTableBO(false);
|
|
269
|
+
});
|
|
270
|
+
fetchListCSDataTableBO();
|
|
271
|
+
}
|
|
272
|
+
return () => {
|
|
273
|
+
ignore = true;
|
|
274
|
+
};
|
|
275
|
+
}, [boIdByGroupCS, serviceAuth, contentSourceDispatch]);
|
|
235
276
|
// callback data out
|
|
236
277
|
useDeepCompareEffect(() => {
|
|
237
278
|
if (typeof onChange === 'function') {
|
|
@@ -239,7 +280,7 @@ const Settings = (props) => {
|
|
|
239
280
|
}
|
|
240
281
|
}, [contentSourcesDebounce]);
|
|
241
282
|
return (React.createElement(ContentContainer, { className: "contentsource-container" },
|
|
242
|
-
React.createElement(Content, { isLoadingListBO: isLoadingListBO, listBO: listBO, groups: groups, expanded: expanded, onChangeExpand: expanded => {
|
|
283
|
+
React.createElement(Content, { isLoadingListBO: isLoadingListBO || isLoadingDataTableBO, listBO: listBO, groups: groups, expanded: expanded, onChangeExpand: expanded => {
|
|
243
284
|
contentSourceDispatch({
|
|
244
285
|
type: 'EXPANDED',
|
|
245
286
|
payload: {
|
|
@@ -11,4 +11,7 @@ export declare const useContentSourceState: () => ContentSourceState;
|
|
|
11
11
|
export declare const useContentSourceDispatch: () => React.Dispatch<UpdateGroupAction>;
|
|
12
12
|
export declare const useSelectServiceAuth: () => import("@antscorp/antsomi-ui/es/types").PayloadInfo;
|
|
13
13
|
export declare const useSelectContentSources: () => import("./types").TContentSourceSettings;
|
|
14
|
+
export declare const useSelectCSGroups: () => import("./types").TContentSourceGroup[];
|
|
14
15
|
export declare const useSelectModeView: () => import("./types").ContentSourceModeView;
|
|
16
|
+
export declare const useSelectBoIdByGroupFromCS: () => Record<string, number>;
|
|
17
|
+
export declare const useSelectDataTableBOByGroupId: (groupId: string) => Record<string, any>[];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Libraries
|
|
2
2
|
import React, { createContext, useContext, useMemo, useReducer } from 'react';
|
|
3
|
+
import _ from 'lodash';
|
|
3
4
|
// Reducer
|
|
4
5
|
import { contentSourceReducer, initialContentSourceState } from './reducer';
|
|
5
6
|
export const ContentSourceContext = createContext(initialContentSourceState);
|
|
@@ -21,7 +22,35 @@ export const useSelectContentSources = () => {
|
|
|
21
22
|
const { contentSources } = useContentSourceState();
|
|
22
23
|
return useMemo(() => contentSources, [contentSources]);
|
|
23
24
|
};
|
|
25
|
+
export const useSelectCSGroups = () => {
|
|
26
|
+
const { contentSources } = useContentSourceState();
|
|
27
|
+
return useMemo(() => contentSources.groups || [], [contentSources]);
|
|
28
|
+
};
|
|
24
29
|
export const useSelectModeView = () => {
|
|
25
30
|
const { mode } = useContentSourceState();
|
|
26
31
|
return useMemo(() => mode, [mode]);
|
|
27
32
|
};
|
|
33
|
+
export const useSelectBoIdByGroupFromCS = () => {
|
|
34
|
+
const csGroups = useSelectCSGroups();
|
|
35
|
+
const result = useMemo(() => {
|
|
36
|
+
const collectItemTypeId = {};
|
|
37
|
+
csGroups.forEach(group => {
|
|
38
|
+
if (group.itemTypeId !== null) {
|
|
39
|
+
collectItemTypeId[group.groupId] = group.itemTypeId;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return collectItemTypeId;
|
|
43
|
+
}, [csGroups]);
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
export const useSelectDataTableBOByGroupId = (groupId) => {
|
|
47
|
+
const csGroups = useSelectCSGroups();
|
|
48
|
+
const result = useMemo(() => {
|
|
49
|
+
const group = csGroups.find(group => group.groupId === groupId);
|
|
50
|
+
if (group) {
|
|
51
|
+
return _.get(group, 'data', []) || [];
|
|
52
|
+
}
|
|
53
|
+
return [];
|
|
54
|
+
}, [csGroups, groupId]);
|
|
55
|
+
return result;
|
|
56
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TServiceAuth } from '@antscorp/antsomi-ui/es/types';
|
|
2
|
-
import { UpdateGroupAction, TContentSourceSettings, TContentSourceGroup, ActionSetContentSourceGroup, ActionDeleteContentSourceGroup, ContentSourceModeView, ActionUpdateModeView, ActionUpdateContentSourceSettings } from './types';
|
|
2
|
+
import { UpdateGroupAction, TContentSourceSettings, TContentSourceGroup, ActionSetContentSourceGroup, ActionDeleteContentSourceGroup, ContentSourceModeView, ActionUpdateModeView, ActionUpdateContentSourceSettings, ActionSetContentSourceGroupBOData } from './types';
|
|
3
3
|
export interface ContentSourceState {
|
|
4
4
|
serviceAuth: TServiceAuth;
|
|
5
5
|
mode: ContentSourceModeView;
|
|
@@ -15,3 +15,4 @@ export declare const setContentSourceGroup: (payload: {
|
|
|
15
15
|
export declare const deleteContentSourceGroup: (groupId: string) => ActionDeleteContentSourceGroup;
|
|
16
16
|
export declare const updateModeView: (mode: ContentSourceModeView) => ActionUpdateModeView;
|
|
17
17
|
export declare const updateContentSourceSettings: (contentSources: TContentSourceSettings) => ActionUpdateContentSourceSettings;
|
|
18
|
+
export declare const setContentSourceGroupBOData: (boDataByGroupId: Record<string, any[]>) => ActionSetContentSourceGroupBOData;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Libraries
|
|
2
2
|
import produce from 'immer';
|
|
3
|
+
import { has } from 'lodash';
|
|
3
4
|
// Utils
|
|
4
5
|
import { initGroup as initContentSourceGroup } from './utils';
|
|
5
6
|
// Constants
|
|
@@ -61,6 +62,16 @@ export const contentSourceReducer = (state, action) => produce(state, draft => {
|
|
|
61
62
|
}
|
|
62
63
|
break;
|
|
63
64
|
}
|
|
65
|
+
case 'SET_CONTENT_SOURCE_GROUP_BODATA': {
|
|
66
|
+
const { boDataByGroupId } = action.payload;
|
|
67
|
+
draft.contentSources.groups.map(g => {
|
|
68
|
+
if (has(boDataByGroupId, g.groupId)) {
|
|
69
|
+
g.data = boDataByGroupId[g.groupId];
|
|
70
|
+
}
|
|
71
|
+
return g;
|
|
72
|
+
});
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
64
75
|
default: {
|
|
65
76
|
return state;
|
|
66
77
|
}
|
|
@@ -85,3 +96,9 @@ export const updateContentSourceSettings = (contentSources) => ({
|
|
|
85
96
|
contentSources,
|
|
86
97
|
},
|
|
87
98
|
});
|
|
99
|
+
export const setContentSourceGroupBOData = (boDataByGroupId) => ({
|
|
100
|
+
type: 'SET_CONTENT_SOURCE_GROUP_BODATA',
|
|
101
|
+
payload: {
|
|
102
|
+
boDataByGroupId,
|
|
103
|
+
},
|
|
104
|
+
});
|
|
@@ -130,5 +130,11 @@ export interface ActionUpdateContentSourceSettings extends Action {
|
|
|
130
130
|
contentSources: TContentSourceSettings;
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
|
-
export
|
|
133
|
+
export interface ActionSetContentSourceGroupBOData extends Action {
|
|
134
|
+
type: 'SET_CONTENT_SOURCE_GROUP_BODATA';
|
|
135
|
+
payload: {
|
|
136
|
+
boDataByGroupId: Record<string, any[]>;
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
export type UpdateGroupAction = ActionUpdateContentSourceSettings | ActionSetContentSourceGroupBOData | ActionServiceAuth | ActionAddContentSource | ActionUpdateModeView | ActionDeleteContentSourceGroup | ActionSetContentSourceGroup | ActionUpdateSource | ActionUpdateFilter | ActionUpdateFallback | ActionUpdateName | ActionUpdateAlgorithms | ActionUpdateExpanded | ActionUpdateLevel;
|
|
134
140
|
export {};
|
|
@@ -7,3 +7,4 @@ export { Table, ExplorePivotTable, EXPLORE_PIVOT_TABLE_TEST_DATA } from './Table
|
|
|
7
7
|
export { GenerativeInsights } from './GenerativeInsights';
|
|
8
8
|
export { default as ContentSources } from './ContentSources';
|
|
9
9
|
export { LeftMenu, type LeftMenuProps } from './LeftMenu';
|
|
10
|
+
export * from './ContentSources/provider';
|
|
@@ -7,3 +7,4 @@ export { Table, ExplorePivotTable, EXPLORE_PIVOT_TABLE_TEST_DATA } from './Table
|
|
|
7
7
|
export { GenerativeInsights } from './GenerativeInsights';
|
|
8
8
|
export { default as ContentSources } from './ContentSources';
|
|
9
9
|
export { LeftMenu } from './LeftMenu';
|
|
10
|
+
export * from './ContentSources/provider';
|
|
@@ -6,6 +6,7 @@ export declare const QUERY_KEYS: {
|
|
|
6
6
|
GET_LIST_BO: string;
|
|
7
7
|
GET_EVENT_ATTRIBUTE_BO: string;
|
|
8
8
|
GET_BO_DETAIL: string;
|
|
9
|
+
GET_DATA_TABLE_BO: string;
|
|
9
10
|
GET_LIST_PROMOTION_CODE_ATTR: string;
|
|
10
11
|
GET_EVENT_TRACKING_ATTRIBUTES: string;
|
|
11
12
|
GET_LIST_DYNAMIC_CONTENT_ATTR: string;
|
package/es/constants/queries.js
CHANGED
|
@@ -8,6 +8,7 @@ export const QUERY_KEYS = {
|
|
|
8
8
|
GET_LIST_BO: 'GET_LIST_BO',
|
|
9
9
|
GET_EVENT_ATTRIBUTE_BO: 'GET_EVENT_ATTRIBUTE_BO',
|
|
10
10
|
GET_BO_DETAIL: 'GET_BO_DETAIL',
|
|
11
|
+
GET_DATA_TABLE_BO: 'GET_DATA_TABLE_BO',
|
|
11
12
|
// Promotion Code Attr
|
|
12
13
|
GET_LIST_PROMOTION_CODE_ATTR: 'GET_LIST_PROMOTION_CODE_ATTR',
|
|
13
14
|
// Event tracking attributes
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TServiceAuth } from '../../types';
|
|
2
|
+
export declare const getDataTableBOQuery: (serviceAuth: TServiceAuth, itemTypeId: number | string, params?: Record<string, any>) => Promise<{
|
|
3
|
+
data: import("../../services/ThirParty/TableBO").TDataTableBO;
|
|
4
|
+
boId: string | number;
|
|
5
|
+
params: Record<string, any> | undefined;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
// Constants
|
|
11
|
+
import { QUERY_KEYS } from '../../constants/queries';
|
|
12
|
+
// Services
|
|
13
|
+
import { getDataTableBO } from '../../services/ThirParty/TableBO';
|
|
14
|
+
// QueryClients
|
|
15
|
+
import { queryClientAntsomiUI } from '../configs';
|
|
16
|
+
export const getDataTableBOQuery = (serviceAuth, itemTypeId, params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const data = yield queryClientAntsomiUI.fetchQuery({
|
|
18
|
+
queryKey: [QUERY_KEYS.GET_DATA_TABLE_BO, itemTypeId],
|
|
19
|
+
queryFn: () => getDataTableBO(serviceAuth, itemTypeId),
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
data: data !== null && data !== void 0 ? data : [],
|
|
23
|
+
boId: itemTypeId,
|
|
24
|
+
params,
|
|
25
|
+
};
|
|
26
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
// Libraries
|
|
11
|
+
import get from 'lodash/get';
|
|
12
|
+
import omit from 'lodash/omit';
|
|
13
|
+
// Services
|
|
14
|
+
import { services } from '@antscorp/antsomi-ui/es/services';
|
|
15
|
+
export const getDataTableBO = (serviceAuth, id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
try {
|
|
17
|
+
const response = yield services.mediaTemplateDesign.get({
|
|
18
|
+
API_HOST: `${serviceAuth.url}/third-party/data-table-bo`,
|
|
19
|
+
id,
|
|
20
|
+
}, omit(serviceAuth, 'url'));
|
|
21
|
+
return get(response, 'data.data', null);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
return new Promise((_, reject) => {
|
|
25
|
+
reject(error);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
package/es/services/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ type UpdateParams = {
|
|
|
9
9
|
};
|
|
10
10
|
export declare const services: {
|
|
11
11
|
mediaTemplateDesign: {
|
|
12
|
+
get: (params: any, payloadInfo: PayloadInfo) => false | Promise<AxiosResponse<any, any>>;
|
|
12
13
|
getList: (params: any, infos: PayloadInfo) => any;
|
|
13
14
|
create: (params: any, infos: PayloadInfo) => Promise<AxiosResponse<any, any> | any>;
|
|
14
15
|
update: (params: UpdateParams, infos: PayloadInfo) => Promise<AxiosResponse<any, any> | any>;
|
package/es/services/index.js
CHANGED
|
@@ -23,6 +23,29 @@ const { CancelToken } = axios;
|
|
|
23
23
|
const isDebugApi = searchParamsToObject((((_a = window.location) === null || _a === void 0 ? void 0 : _a.href) || '').split('?')[1])['debug-api'] != null;
|
|
24
24
|
export const services = {
|
|
25
25
|
mediaTemplateDesign: {
|
|
26
|
+
get: function get(params, payloadInfo) {
|
|
27
|
+
if (typeof params.API_HOST !== 'undefined' && typeof params.id !== 'undefined') {
|
|
28
|
+
const { API_HOST } = params;
|
|
29
|
+
const { userId, accountId, token } = payloadInfo;
|
|
30
|
+
const cancelToken = params.cancelToken ? params.cancelToken : new CancelToken(() => { });
|
|
31
|
+
const { signal } = params;
|
|
32
|
+
delete params.API_HOST;
|
|
33
|
+
delete params.cancelToken;
|
|
34
|
+
delete params.signal;
|
|
35
|
+
if (has(params, 'url')) {
|
|
36
|
+
delete params.url;
|
|
37
|
+
}
|
|
38
|
+
const snapParams = Object.assign(Object.assign({}, params), { _token: token, _user_id: userId, _account_id: accountId });
|
|
39
|
+
return instance.get(API_HOST + '/' + params.id, {
|
|
40
|
+
params: snapParams,
|
|
41
|
+
cancelToken: cancelToken,
|
|
42
|
+
signal,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
},
|
|
26
49
|
getList: function getList(params, infos) {
|
|
27
50
|
if (typeof params.API_HOST !== 'undefined') {
|
|
28
51
|
const { API_HOST } = params;
|