@antscorp/antsomi-ui 1.3.5-beta.323 → 1.3.5-beta.325

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 (35) hide show
  1. package/es/components/molecules/ThumbnailCard/ThumbnailCard.d.ts +4 -1
  2. package/es/components/molecules/ThumbnailCard/ThumbnailCard.js +227 -9
  3. package/es/components/molecules/ThumbnailCard/constants.d.ts +5 -0
  4. package/es/components/molecules/ThumbnailCard/constants.js +22 -0
  5. package/es/components/molecules/ThumbnailCard/styled.js +4 -2
  6. package/es/components/molecules/ThumbnailCard/types.d.ts +11 -2
  7. package/es/components/organism/LeftMenu/components/HomeMenu/index.js +48 -10
  8. package/es/components/organism/LeftMenu/components/HomeMenu/styled.d.ts +1 -0
  9. package/es/components/organism/LeftMenu/components/HomeMenu/styled.js +10 -0
  10. package/es/components/organism/LeftMenu/components/HomeMenu/useHomeMenu.d.ts +4 -0
  11. package/es/components/organism/LeftMenu/components/HomeMenu/useHomeMenu.js +35 -5
  12. package/es/components/organism/LeftMenu/hooks/useLeftMenu.js +8 -17
  13. package/es/components/organism/LeftMenu/stores/index.d.ts +5 -0
  14. package/es/components/organism/LeftMenu/stores/index.js +6 -0
  15. package/es/components/organism/LeftMenu/utils/index.js +2 -2
  16. package/es/components/template/Layout/constants/config.d.ts +7 -0
  17. package/es/components/template/Layout/constants/config.js +7 -0
  18. package/es/components/template/Layout/constants/index.d.ts +1 -0
  19. package/es/components/template/Layout/constants/index.js +1 -0
  20. package/es/config/index.d.ts +1 -0
  21. package/es/config/index.js +1 -0
  22. package/es/constants/api.d.ts +3 -0
  23. package/es/constants/api.js +3 -0
  24. package/es/constants/theme.js +26 -25
  25. package/es/locales/en/translation.json +2 -1
  26. package/es/locales/i18n.d.ts +9 -0
  27. package/es/locales/translations.d.ts +1 -0
  28. package/es/locales/vi/translation.json +9 -1
  29. package/es/providers/ConfigProvider/GlobalStyle.js +1 -1
  30. package/es/queries/LeftMenu/index.d.ts +1 -0
  31. package/es/queries/LeftMenu/index.js +16 -2
  32. package/es/services/LeftMenu/index.d.ts +11 -0
  33. package/es/services/LeftMenu/index.js +31 -3
  34. package/es/types/variables.d.ts +17 -0
  35. package/package.json +2 -2
@@ -1,3 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ThumbnailCardProps } from './types';
3
- export declare const ThumbnailCard: React.FC<ThumbnailCardProps>;
3
+ export declare const ThumbnailCard: {
4
+ <TActionKey extends string[] = []>(props: ThumbnailCardProps<TActionKey>): React.JSX.Element;
5
+ displayName: string;
6
+ };
@@ -19,19 +19,208 @@ var __rest = (this && this.__rest) || function (s, e) {
19
19
  return t;
20
20
  };
21
21
  // Libraries
22
- import Icon from '@antscorp/icons';
22
+ import React from 'react';
23
+ import { Icon } from '@antscorp/antsomi-ui/es/components/atoms';
23
24
  import { Modal } from 'antd';
24
- import React, { memo } from 'react';
25
+ import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
25
26
  // Styled
26
27
  import { ThumbnailCardWrapper } from './styled';
27
28
  // Components
28
- import { Button, Flex, Spin, Typography } from '../../atoms';
29
+ import { Button, Flex, Typography, Spin, Tooltip } from '../../atoms';
29
30
  // Constants
30
- import { THUMBNAIL_CARD_DEFAULT_HEIGHT, THUMBNAIL_CARD_DEFAULT_WIDTH } from './constants';
31
+ import { THUMBNAIL_CARD_ACTION_OPTIONS, THUMBNAIL_CARD_DEFAULT_HEIGHT, THUMBNAIL_CARD_DEFAULT_WIDTH, } from './constants';
31
32
  import { getUrlNoCache, checkShowSkeletonBaseUrl } from '@antscorp/antsomi-ui/es/utils';
32
- export const ThumbnailCard = memo(props => {
33
+ import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
34
+ // export const ThumbnailCard: React.FC<ThumbnailCardProps> = memo(props => {
35
+ // const [modal, contextHolder] = Modal.useModal();
36
+ // const {
37
+ // id,
38
+ // name,
39
+ // width = THUMBNAIL_CARD_DEFAULT_WIDTH,
40
+ // height = THUMBNAIL_CARD_DEFAULT_HEIGHT,
41
+ // thumbnail,
42
+ // thumbnailFit,
43
+ // removable = true,
44
+ // actionAvailable = true,
45
+ // showSkeleton,
46
+ // loading = false,
47
+ // removeModalProps,
48
+ // editBtnProps,
49
+ // previewBtnProps,
50
+ // thumbnailCacheValue,
51
+ // actionButtons,
52
+ // onClickWrapper,
53
+ // ...restOfProps
54
+ // } = props;
55
+ // const { onOk, ...restOfRemoveTemplateModalProps } = removeModalProps || {};
56
+ // const {
57
+ // text: editText = 'Use template',
58
+ // onClick: onClickEdit,
59
+ // ...restOfEditBtnProps
60
+ // } = editBtnProps || {};
61
+ // const {
62
+ // text: previewText = 'Preview',
63
+ // onClick: onClickPreview,
64
+ // ...restOfPreviewBtnProps
65
+ // } = previewBtnProps || {};
66
+ // // Memo
67
+ // const showSkeletonMemo =
68
+ // // NOTES: Hot fix for showSkeleton base url if showSkeleton is not defined
69
+ // typeof showSkeleton === 'undefined'
70
+ // ? checkShowSkeletonBaseUrl(thumbnail)
71
+ // : typeof showSkeleton === 'function'
72
+ // ? showSkeleton(props)
73
+ // : showSkeleton;
74
+ // // Handlers
75
+ // const handleRemoveThumbnail: React.MouseEventHandler<HTMLElement> = e => {
76
+ // e.stopPropagation();
77
+ // modal.confirm({
78
+ // title: 'Remove template',
79
+ // centered: true,
80
+ // icon: <Icon type="icon-ants-info" style={{ fontSize: 16, lineHeight: '25px' }} />,
81
+ // content: (
82
+ // <div>
83
+ // <p>Are you sure you want to remove the template?</p>
84
+ // <p>This action can not be undone.</p>
85
+ // </div>
86
+ // ),
87
+ // okText: 'Remove',
88
+ // cancelText: 'Cancel',
89
+ // closable: true,
90
+ // ...restOfRemoveTemplateModalProps,
91
+ // onOk: async () => {
92
+ // if (onOk) onOk(id);
93
+ // },
94
+ // });
95
+ // };
96
+ // const handleWrapperClick: React.MouseEventHandler<HTMLElement> = e => {
97
+ // e.stopPropagation();
98
+ // onClickWrapper?.(id);
99
+ // };
100
+ // // Handlers
101
+ // const renderActionButtons = () => {
102
+ // if (!actionButtons) return null;
103
+ // return Object.keys(actionButtons)
104
+ // .map(key => {
105
+ // const option = THUMBNAIL_CARD_ACTION_OPTIONS[key];
106
+ // const actionSettings = actionButtons[key as TActionButtonKey];
107
+ // if (actionSettings) {
108
+ // const { buttonProps, key, customRender } = actionSettings;
109
+ // const icon = actionSettings.icon || option.icon || '';
110
+ // const label = actionSettings.label || option.label || '';
111
+ // const ButtonComponent = (
112
+ // <Tooltip title={label}>
113
+ // <Button
114
+ // key={key || option.key}
115
+ // type="primary"
116
+ // icon={
117
+ // <Icon type={icon || option.icon} style={{ fontSize: 24, color: '#FFFFFF' }} />
118
+ // }
119
+ // {...buttonProps}
120
+ // />
121
+ // </Tooltip>
122
+ // );
123
+ // /**
124
+ // * Handle custom render for action button
125
+ // * If customRender is a function, return the function callback the ButtonComponent
126
+ // * If not, return ButtonComponent
127
+ // */
128
+ // return typeof customRender === 'function'
129
+ // ? customRender(ButtonComponent)
130
+ // : ButtonComponent;
131
+ // }
132
+ // return null;
133
+ // })
134
+ // .filter(Boolean);
135
+ // };
136
+ // return (
137
+ // <Flex gap={10} vertical {...restOfProps} style={{ width, ...restOfProps.style }}>
138
+ // <ThumbnailCardWrapper
139
+ // $showSkeleton={showSkeletonMemo}
140
+ // style={{ height, cursor: actionAvailable ? 'default' : 'pointer' }}
141
+ // onClick={handleWrapperClick}
142
+ // >
143
+ // <div className="screen">
144
+ // {thumbnail && (
145
+ // <img
146
+ // src={getUrlNoCache(thumbnail, thumbnailCacheValue)}
147
+ // alt=""
148
+ // style={{ objectFit: thumbnailFit }}
149
+ // onError={e => {
150
+ // e.currentTarget.style.display = 'none';
151
+ // }}
152
+ // />
153
+ // )}
154
+ // </div>
155
+ // {actionAvailable && !loading && (
156
+ // <>
157
+ // <Flex className="center-action" align="center" gap={10} vertical>
158
+ // <Button
159
+ // type="primary"
160
+ // className="animate__animated animate__fadeIn"
161
+ // {...restOfEditBtnProps}
162
+ // onClick={e => {
163
+ // e.stopPropagation();
164
+ // onClickEdit?.(id);
165
+ // }}
166
+ // >
167
+ // <Typography.Text
168
+ // ellipsis={{ tooltip: editText }}
169
+ // style={{ maxWidth: '100%', color: 'inherit' }}
170
+ // >
171
+ // {editText}
172
+ // </Typography.Text>
173
+ // </Button>
174
+ // <Button
175
+ // className="animate__animated animate__fadeIn"
176
+ // onClick={e => {
177
+ // e.stopPropagation();
178
+ // onClickPreview?.(id);
179
+ // }}
180
+ // {...restOfPreviewBtnProps}
181
+ // >
182
+ // <Typography.Text
183
+ // ellipsis={{ tooltip: previewText }}
184
+ // style={{ maxWidth: '100%', color: 'inherit' }}
185
+ // >
186
+ // {previewText}
187
+ // </Typography.Text>
188
+ // </Button>
189
+ // </Flex>
190
+ // <div className="top-right-corner-action animate__animated animate__fadeIn">
191
+ // {renderActionButtons()}
192
+ // {removable && (
193
+ // <Tooltip title={i18nInstance.t(translations.remove).toString()}>
194
+ // <Button
195
+ // type="primary"
196
+ // icon={
197
+ // <Icon
198
+ // type="icon-ants-trash-outline"
199
+ // style={{ fontSize: 24, color: '#FFFFFF' }}
200
+ // />
201
+ // }
202
+ // onClick={handleRemoveThumbnail}
203
+ // />
204
+ // </Tooltip>
205
+ // )}
206
+ // </div>
207
+ // <div className="backdrop" />
208
+ // <div>{contextHolder}</div>
209
+ // </>
210
+ // )}
211
+ // {loading && <Spin className="thumbnail__loading" spinning />}
212
+ // </ThumbnailCardWrapper>
213
+ // {!!name && (
214
+ // <Typography.Text ellipsis={{ tooltip: name }} style={{ maxWidth: '100%' }}>
215
+ // {name}
216
+ // </Typography.Text>
217
+ // )}
218
+ // </Flex>
219
+ // );
220
+ // });
221
+ export const ThumbnailCard = (props) => {
33
222
  const [modal, contextHolder] = Modal.useModal();
34
- const { id, name, width = THUMBNAIL_CARD_DEFAULT_WIDTH, height = THUMBNAIL_CARD_DEFAULT_HEIGHT, thumbnail, thumbnailFit, removable = true, actionAvailable = true, showSkeleton, loading = false, removeModalProps, editBtnProps, previewBtnProps, thumbnailCacheValue, onClickWrapper } = props, restOfProps = __rest(props, ["id", "name", "width", "height", "thumbnail", "thumbnailFit", "removable", "actionAvailable", "showSkeleton", "loading", "removeModalProps", "editBtnProps", "previewBtnProps", "thumbnailCacheValue", "onClickWrapper"]);
223
+ const { id, name, width = THUMBNAIL_CARD_DEFAULT_WIDTH, height = THUMBNAIL_CARD_DEFAULT_HEIGHT, thumbnail, thumbnailFit, removable = true, actionAvailable = true, showSkeleton, loading = false, removeModalProps, editBtnProps, previewBtnProps, thumbnailCacheValue, actionButtons, onClickWrapper } = props, restOfProps = __rest(props, ["id", "name", "width", "height", "thumbnail", "thumbnailFit", "removable", "actionAvailable", "showSkeleton", "loading", "removeModalProps", "editBtnProps", "previewBtnProps", "thumbnailCacheValue", "actionButtons", "onClickWrapper"]);
35
224
  const _a = removeModalProps || {}, { onOk } = _a, restOfRemoveTemplateModalProps = __rest(_a, ["onOk"]);
36
225
  const _b = editBtnProps || {}, { text: editText = 'Use template', onClick: onClickEdit } = _b, restOfEditBtnProps = __rest(_b, ["text", "onClick"]);
37
226
  const _c = previewBtnProps || {}, { text: previewText = 'Preview', onClick: onClickPreview } = _c, restOfPreviewBtnProps = __rest(_c, ["text", "onClick"]);
@@ -57,6 +246,33 @@ export const ThumbnailCard = memo(props => {
57
246
  e.stopPropagation();
58
247
  onClickWrapper === null || onClickWrapper === void 0 ? void 0 : onClickWrapper(id);
59
248
  };
249
+ // Handlers
250
+ const renderActionButtons = () => {
251
+ if (!actionButtons)
252
+ return null;
253
+ return Object.keys(actionButtons)
254
+ .map(key => {
255
+ const option = THUMBNAIL_CARD_ACTION_OPTIONS[key];
256
+ const actionSettings = actionButtons[key];
257
+ if (actionSettings) {
258
+ const { buttonProps, key, customRender } = actionSettings;
259
+ const icon = actionSettings.icon || (option === null || option === void 0 ? void 0 : option.icon) || '';
260
+ const label = actionSettings.label || (option === null || option === void 0 ? void 0 : option.label) || '';
261
+ const ButtonComponent = (React.createElement(Tooltip, { title: label },
262
+ React.createElement(Button, Object.assign({ key: key || (option === null || option === void 0 ? void 0 : option.key), type: "primary", icon: React.createElement(Icon, { type: icon, style: { fontSize: 24, color: '#FFFFFF' } }) }, buttonProps))));
263
+ /**
264
+ * Handle custom render for action button
265
+ * If customRender is a function, return the function callback the ButtonComponent
266
+ * If not, return ButtonComponent
267
+ */
268
+ return typeof customRender === 'function'
269
+ ? customRender(ButtonComponent)
270
+ : ButtonComponent;
271
+ }
272
+ return null;
273
+ })
274
+ .filter(Boolean);
275
+ };
60
276
  return (React.createElement(Flex, Object.assign({ gap: 10, vertical: true }, restOfProps, { style: Object.assign({ width }, restOfProps.style) }),
61
277
  React.createElement(ThumbnailCardWrapper, { "$showSkeleton": showSkeletonMemo, style: { height, cursor: actionAvailable ? 'default' : 'pointer' }, onClick: handleWrapperClick },
62
278
  React.createElement("div", { className: "screen" }, thumbnail && (React.createElement("img", { src: getUrlNoCache(thumbnail, thumbnailCacheValue), alt: "", style: { objectFit: thumbnailFit }, onError: e => {
@@ -74,11 +290,13 @@ export const ThumbnailCard = memo(props => {
74
290
  onClickPreview === null || onClickPreview === void 0 ? void 0 : onClickPreview(id);
75
291
  } }, restOfPreviewBtnProps),
76
292
  React.createElement(Typography.Text, { ellipsis: { tooltip: previewText }, style: { maxWidth: '100%', color: 'inherit' } }, previewText))),
77
- removable && (React.createElement("div", { className: "top-right-corner-action animate__animated animate__fadeIn" },
78
- React.createElement(Button, { type: "primary", icon: React.createElement(Icon, { type: "icon-ants-trash-outline", style: { fontSize: 24, color: '#FFFFFF' } }), onClick: handleRemoveThumbnail }))),
293
+ React.createElement("div", { className: "top-right-corner-action animate__animated animate__fadeIn" },
294
+ renderActionButtons(),
295
+ removable && (React.createElement(Tooltip, { title: i18nInstance.t(translations.remove).toString() },
296
+ React.createElement(Button, { type: "primary", icon: React.createElement(Icon, { type: "icon-ants-trash-outline", style: { fontSize: 24, color: '#FFFFFF' } }), onClick: handleRemoveThumbnail })))),
79
297
  React.createElement("div", { className: "backdrop" }),
80
298
  React.createElement("div", null, contextHolder))),
81
299
  loading && React.createElement(Spin, { className: "thumbnail__loading", spinning: true })),
82
300
  !!name && (React.createElement(Typography.Text, { ellipsis: { tooltip: name }, style: { maxWidth: '100%' } }, name))));
83
- });
301
+ };
84
302
  ThumbnailCard.displayName = 'ThumbnailCard';
@@ -1,3 +1,8 @@
1
1
  export declare const THUMBNAIL_CARD_DEFAULT_WIDTH = 330;
2
2
  export declare const THUMBNAIL_CARD_DEFAULT_HEIGHT = 230;
3
3
  export declare const THUMBNAIL_URL = "https://st-media-template.antsomi.com/base64-img/37563.png";
4
+ export declare const THUMBNAIL_CARD_ACTION_KEYS: {
5
+ readonly EDIT: "EDIT";
6
+ readonly DUPLICATE: "DUPLICATE";
7
+ };
8
+ export declare const THUMBNAIL_CARD_ACTION_OPTIONS: Record<string, any>;
@@ -1,3 +1,25 @@
1
+ // Libraries
2
+ import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
3
+ // Constants
4
+ import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
1
5
  export const THUMBNAIL_CARD_DEFAULT_WIDTH = 330;
2
6
  export const THUMBNAIL_CARD_DEFAULT_HEIGHT = 230;
3
7
  export const THUMBNAIL_URL = 'https://st-media-template.antsomi.com/base64-img/37563.png';
8
+ /* CARD ACTION KEYS */
9
+ export const THUMBNAIL_CARD_ACTION_KEYS = {
10
+ EDIT: 'EDIT',
11
+ DUPLICATE: 'DUPLICATE',
12
+ };
13
+ const { EDIT, DUPLICATE } = THUMBNAIL_CARD_ACTION_KEYS;
14
+ export const THUMBNAIL_CARD_ACTION_OPTIONS = {
15
+ [EDIT]: {
16
+ key: EDIT,
17
+ label: i18nInstance.t(translations.edit.title).toString(),
18
+ icon: 'icon-ants-pencil',
19
+ },
20
+ [DUPLICATE]: {
21
+ key: DUPLICATE,
22
+ label: i18nInstance.t(translations.duplicate.title).toString(),
23
+ icon: 'icon-ants-duplicate',
24
+ },
25
+ };
@@ -27,11 +27,11 @@ export const ThumbnailCardWrapper = styled.div `
27
27
  }
28
28
 
29
29
  .top-right-corner-action {
30
- display: block;
30
+ display: flex;
31
31
  }
32
32
 
33
33
  .backdrop {
34
- opacity: 0.6 !important;
34
+ opacity: 0.5 !important;
35
35
  }
36
36
  }
37
37
 
@@ -66,6 +66,8 @@ export const ThumbnailCardWrapper = styled.div `
66
66
  top: 16px;
67
67
  right: 16px;
68
68
  display: none;
69
+ align-items: center;
70
+ gap: 12px;
69
71
  z-index: 12;
70
72
 
71
73
  button {
@@ -1,5 +1,6 @@
1
1
  import { ModalFuncProps, ButtonProps } from 'antd';
2
- import React, { HTMLAttributes } from 'react';
2
+ import React, { HTMLAttributes, ReactNode } from 'react';
3
+ import { THUMBNAIL_CARD_ACTION_KEYS } from './constants';
3
4
  export type TThumbnailCardId = string | number;
4
5
  export type TRemoveModalProps = Omit<ModalFuncProps, 'onOk'> & {
5
6
  onOk?: (id: TThumbnailCardId) => void;
@@ -8,7 +9,7 @@ export type TThumbnailButton = Omit<ButtonProps, 'onClick'> & {
8
9
  text?: string;
9
10
  onClick?: (id: TThumbnailCardId) => void;
10
11
  };
11
- export interface ThumbnailCardProps extends Omit<HTMLAttributes<HTMLDivElement>, 'id'> {
12
+ export interface ThumbnailCardProps<TActionKey extends string[] = []> extends Omit<HTMLAttributes<HTMLDivElement>, 'id'> {
12
13
  id: TThumbnailCardId;
13
14
  name?: string;
14
15
  width?: number;
@@ -22,6 +23,14 @@ export interface ThumbnailCardProps extends Omit<HTMLAttributes<HTMLDivElement>,
22
23
  actionAvailable?: boolean;
23
24
  removeModalProps?: TRemoveModalProps;
24
25
  thumbnailFit?: React.CSSProperties['objectFit'];
26
+ actionButtons?: Partial<Record<TActionButtonKey<TActionKey>, {
27
+ buttonProps?: ButtonProps;
28
+ key?: string;
29
+ label?: string;
30
+ icon?: string;
31
+ customRender?: (node: ReactNode) => ReactNode;
32
+ }>>;
25
33
  thumbnailCacheValue?: string | number;
26
34
  onClickWrapper?: (id: TThumbnailCardId) => void;
27
35
  }
36
+ export type TActionButtonKey<T extends string[] = []> = (typeof THUMBNAIL_CARD_ACTION_KEYS)[keyof typeof THUMBNAIL_CARD_ACTION_KEYS] | T[number];
@@ -3,20 +3,58 @@ import React, { memo } from 'react';
3
3
  // Components
4
4
  import { ChildMenu } from '../common';
5
5
  import { Flex } from '../../../../atoms';
6
+ import { Modal } from '../../../../molecules';
6
7
  // Constants
7
8
  import Icon from '@antscorp/icons';
8
9
  // Styled
9
- import { CreateButton, HomeMenuWrapper } from './styled';
10
+ import { CreateButton, HomeMenuWrapper, ModalWrapper } from './styled';
10
11
  // Hooks
11
12
  import { useHomeMenu } from './useHomeMenu';
13
+ // const MAP_TITLE = {
14
+ // REMOVE_ACCESS: {
15
+ // HEADING: getTranslateMessage(TRANSLATE_KEY._TITL_REMOV_ACCESS_TAB, 'Remove access to this tab'),
16
+ // BODY: getTranslateMessage(
17
+ // TRANSLATE_KEY.REMOV_ACCESS_TAB,
18
+ // 'This action will remove your access to this tab. You will not see it anymore. Are you sure you want to continue?',
19
+ // ),
20
+ // HEADING_DASHBOARD: getTranslateMessage(
21
+ // TRANSLATE_KEY._TITL_REMOV_ACCESS_DB,
22
+ // 'Remove access to this dashboard',
23
+ // ),
24
+ // BODY_DASHBOARD: getTranslateMessage(
25
+ // TRANSLATE_KEY.REMOV_ACCESS_DB,
26
+ // 'This action will remove your access to selected dashboard. You will not see it anymore. Are you sure you want to continue?',
27
+ // ),
28
+ // },
29
+ // DELETE_TAB: {
30
+ // HEADING: getTranslateMessage(TRANSLATE_KEY._TITL_DELETE_TAB, 'Remove this tab'),
31
+ // BODY: getTranslateMessage(
32
+ // TRANSLATE_KEY.DELETE_TAB_MESS,
33
+ // 'Removing this tab will delete it permanently. Are you sure you want to perform this action?',
34
+ // ),
35
+ // HEADING_DASHBOARD: getTranslateMessage(TRANSLATE_KEY._TITL_DELETE_DB, 'Remove this dashboard'),
36
+ // BODY_DASHBOARD: getTranslateMessage(
37
+ // TRANSLATE_KEY.DELETE_DB_MESS,
38
+ // 'Removing this dashboard will delete it permanently. Are you sure you want to perform this action?',
39
+ // ),
40
+ // },
41
+ // 'my-report-template': {
42
+ // HEADING: getTranslateMessage(TRANSLATE_KEY._TITL_SHARE_RP, 'Share Report'),
43
+ // BODY: getTranslateMessage(
44
+ // TRANSLATE_KEY._SHARE_RP_MESS,
45
+ // 'Sharing this tab with Public access will make your report public for everyone on the portal.',
46
+ // ),
47
+ // },
48
+ // };
12
49
  export const HomeMenu = memo(() => {
13
- const { children, onCreateNewReport, onMenuClick } = useHomeMenu();
14
- // console.log({});
15
- return (React.createElement(HomeMenuWrapper, { gap: 10, vertical: true },
16
- React.createElement(CreateButton, { type: "primary", onClick: onCreateNewReport },
17
- React.createElement(Flex, { gap: 10, align: "center" },
18
- React.createElement(Icon, { type: "icon-ants-plus-slim", style: { fontSize: 14 } }),
19
- React.createElement("span", null, "Create"))),
20
- React.createElement("div", { className: "menu-list" },
21
- React.createElement(ChildMenu, { items: children, onMenuClick: onMenuClick }))));
50
+ const { children, removedDashboardId, isDashboardRemoving, setRemovedDashboardId, onCreateNewReport, onMenuClick, onRemoveDashboard, } = useHomeMenu();
51
+ return (React.createElement(React.Fragment, null,
52
+ React.createElement(HomeMenuWrapper, { gap: 10, vertical: true },
53
+ React.createElement(CreateButton, { type: "primary", onClick: onCreateNewReport },
54
+ React.createElement(Flex, { gap: 10, align: "center" },
55
+ React.createElement(Icon, { type: "icon-ants-plus-slim", style: { fontSize: 14 } }),
56
+ React.createElement("span", null, "Create"))),
57
+ React.createElement("div", { className: "menu-list" },
58
+ React.createElement(ChildMenu, { items: children, onMenuClick: onMenuClick }))),
59
+ React.createElement(Modal, { open: !!removedDashboardId, centered: true, onCancel: () => setRemovedDashboardId(''), title: "Remove this dashboard", okText: "Confirm", cancelText: "Cancel", closable: false, okButtonProps: { loading: isDashboardRemoving }, modalRender: node => React.createElement(ModalWrapper, null, node), onOk: onRemoveDashboard }, "Removing this dashboard will delete it permanently. Are you sure you want to perform this action?")));
22
60
  });
@@ -3,3 +3,4 @@ export declare const HomeMenuWrapper: import("styled-components").StyledComponen
3
3
  export declare const CreateButton: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd").ButtonProps & import("react").RefAttributes<HTMLElement>> & {
4
4
  Group: import("react").FC<import("antd/es/button").ButtonGroupProps>;
5
5
  }, any, {}, never>;
6
+ export declare const ModalWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -35,3 +35,13 @@ export const CreateButton = styled(Button) `
35
35
  font-size: 14px !important;
36
36
  flex-shrink: 0;
37
37
  `;
38
+ export const ModalWrapper = styled.div `
39
+ width: 379px;
40
+
41
+ & > .antsomi-modal-content {
42
+ & > .antsomi-modal-header,
43
+ & > .antsomi-modal-footer {
44
+ margin: 0px;
45
+ }
46
+ }
47
+ `;
@@ -1,10 +1,14 @@
1
1
  /// <reference types="react" />
2
2
  export declare const useHomeMenu: () => {
3
3
  children: import("@antscorp/antsomi-ui/es/components/organism/LeftMenu/types").TMenuItem[];
4
+ removedDashboardId: string;
5
+ isDashboardRemoving: boolean;
6
+ setRemovedDashboardId: import("react").Dispatch<import("react").SetStateAction<string>>;
4
7
  onCreateNewReport: import("react").MouseEventHandler<HTMLElement>;
5
8
  onOptionCallback: (args: {
6
9
  menuItemKey: string;
7
10
  optionKey: string;
8
11
  }) => void;
9
12
  onMenuClick: (key: string, _: any) => void;
13
+ onRemoveDashboard: () => Promise<void>;
10
14
  };
@@ -1,23 +1,37 @@
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
- import { useCallback, useMemo } from 'react';
3
- // import { useHistory } from 'react-router-dom';
11
+ import { useCallback, useMemo, useState } from 'react';
4
12
  // Constants
5
13
  import { CONFIG_OPTIONS } from './constants';
6
14
  import { HOME_REPORT_ROUTES, HOME_ROUTE } from '../../constants';
15
+ import { API_RESPONSE_CODE, CDP_API } from '@antscorp/antsomi-ui/es/constants';
7
16
  // Utils
8
17
  import { getGeneratePath, getMenuItem } from '../../utils';
9
- // Types
18
+ // Hooks
10
19
  import { useLeftMenuStore } from '../../stores';
11
20
  import { useLayoutStore } from '@antscorp/antsomi-ui/es/components/template';
12
21
  import { useCustomRouter } from '@antscorp/antsomi-ui/es/hooks';
22
+ // Queries
23
+ import { useUpdateTask } from '@antscorp/antsomi-ui/es/queries/LeftMenu';
13
24
  export const useHomeMenu = () => {
14
25
  const { pathname, search } = window.location;
15
- // const history = useHistory();
16
26
  const { navigate, replace } = useCustomRouter();
17
27
  const appMenuChildren = useLeftMenuStore(store => store.state.appMenuChildren);
18
28
  const auth = useLeftMenuStore(store => { var _a; return (_a = store.state.appConfig) === null || _a === void 0 ? void 0 : _a.auth; });
29
+ const env = useLeftMenuStore(store => { var _a; return (_a = store.state.appConfig) === null || _a === void 0 ? void 0 : _a.env; });
30
+ const dashboardParams = useLeftMenuStore(store => store.state.dashboardParams);
19
31
  const onClickCreateDashboard = useLayoutStore(store => store.state.leftMenu.onClickCreateDashboard);
32
+ const [removedDashboardId, setRemovedDashboardId] = useState('');
20
33
  const urlParams = useMemo(() => new URLSearchParams(search), [search]);
34
+ const { mutateAsync: removeDashboard, isLoading: isDashboardRemoving } = useUpdateTask();
21
35
  const onOptionCallback = useCallback((args) => {
22
36
  const { optionKey, menuItemKey } = args;
23
37
  switch (optionKey) {
@@ -29,6 +43,7 @@ export const useHomeMenu = () => {
29
43
  break;
30
44
  }
31
45
  case CONFIG_OPTIONS.REMOVE.key:
46
+ setRemovedDashboardId(menuItemKey);
32
47
  break;
33
48
  default:
34
49
  break;
@@ -54,11 +69,26 @@ export const useHomeMenu = () => {
54
69
  navigate(newPathName);
55
70
  }
56
71
  }, [auth, pathname, navigate]);
72
+ const onRemoveDashboard = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
73
+ if (removedDashboardId && auth && env) {
74
+ const params = {
75
+ params: Object.assign(Object.assign({}, dashboardParams), { dashboardId: +removedDashboardId }),
76
+ auth: Object.assign(Object.assign({}, auth), { url: `${CDP_API === null || CDP_API === void 0 ? void 0 : CDP_API[env]}/hub` }),
77
+ };
78
+ const response = yield removeDashboard(params);
79
+ if ((response === null || response === void 0 ? void 0 : response.code) === API_RESPONSE_CODE.SUCCESS) {
80
+ setRemovedDashboardId('');
81
+ }
82
+ }
83
+ }), [auth, dashboardParams, env, removedDashboardId, removeDashboard]);
57
84
  return {
58
85
  children: customChildren,
59
- /* Callbacks */
86
+ removedDashboardId,
87
+ isDashboardRemoving,
88
+ setRemovedDashboardId,
60
89
  onCreateNewReport,
61
90
  onOptionCallback,
62
91
  onMenuClick,
92
+ onRemoveDashboard,
63
93
  };
64
94
  };
@@ -10,13 +10,14 @@ import { useLeftMenuStore } from '../stores';
10
10
  import { POST_MESSAGE_TYPES } from '@antscorp/antsomi-ui/es/constants/postMessage';
11
11
  // Constants
12
12
  import { CDP_API, PERMISSION_API } from '@antscorp/antsomi-ui/es/constants';
13
+ import { DASHBOARD_MODULE_CONFIG } from '../../../template/Layout/constants';
13
14
  const initialState = {
14
15
  hoverItem: '',
15
16
  isExpandMenu: true,
16
17
  };
17
18
  export const useLeftMenu = (props) => {
18
19
  // Props
19
- const { objectType = 'OVERVIEW', objectId = 1, isGrouped = true, appConfig, customization, onActiveMenuCodeChange, } = props;
20
+ const { objectType = DASHBOARD_MODULE_CONFIG.objectType, objectId = DASHBOARD_MODULE_CONFIG.objectId, isGrouped = DASHBOARD_MODULE_CONFIG.isGrouped, appConfig, customization, onActiveMenuCodeChange, } = props;
20
21
  const { isExpandable = true, isCustomized = false, items, activeKey } = customization || {};
21
22
  const { pathname, hash } = window.location;
22
23
  const activeAppCode = useLeftMenuStore(store => store.state.activeAppCode);
@@ -24,20 +25,6 @@ export const useLeftMenu = (props) => {
24
25
  const setLeftMenuState = useLeftMenuStore(store => store.setState);
25
26
  const { auth, languageCode = 'en', env = 'development' } = appConfig || {};
26
27
  const [state, setState] = useState(initialState);
27
- // const { data: menuList } = useGetListMenu({
28
- // args: {
29
- // auth: {
30
- // token: env === 'production' ? auth?.token : '5474r2x214z284d4w2b4y444d464b444q4y274u4t5x5',
31
- // url: 'https://permission.antsomi.com',
32
- // portalId: env === 'production' ? auth?.portalId : 561236459,
33
- // userId: env === 'production' ? auth?.userId : '1600083836',
34
- // accountId: env === 'production' ? auth?.accountId : '1600083836',
35
- // },
36
- // params: {
37
- // type: 'menu-item-permission',
38
- // },
39
- // },
40
- // });
41
28
  const { data: menuList } = useGetListMenu({
42
29
  args: {
43
30
  auth: {
@@ -127,8 +114,12 @@ export const useLeftMenu = (props) => {
127
114
  // eslint-disable-next-line react-hooks/exhaustive-deps
128
115
  }, []);
129
116
  useEffect(() => {
130
- setLeftMenuState({ appConfig, isCustomized });
131
- }, [appConfig, isCustomized, setLeftMenuState]);
117
+ setLeftMenuState({
118
+ appConfig,
119
+ isCustomized,
120
+ dashboardParams: { objectId, isGrouped, objectType },
121
+ });
122
+ }, [appConfig, isCustomized, isGrouped, objectId, objectType, setLeftMenuState]);
132
123
  // Active Custom App Key when active key is changed
133
124
  useEffect(() => {
134
125
  if (activeKey && items)
@@ -11,6 +11,11 @@ export interface LeftMenuState {
11
11
  appMenuChildren: TFeatureMenu[];
12
12
  appConfig?: AppConfigProviderProps;
13
13
  isCustomized?: boolean;
14
+ dashboardParams: {
15
+ objectId: number;
16
+ objectType: string;
17
+ isGrouped: boolean;
18
+ };
14
19
  }
15
20
  interface LeftMenuStore {
16
21
  state: LeftMenuState;
@@ -1,5 +1,6 @@
1
1
  // Libraries
2
2
  import { create } from 'zustand';
3
+ import { DASHBOARD_MODULE_CONFIG } from '../../../template/Layout/constants';
3
4
  const initialState = {
4
5
  activeAppCode: '',
5
6
  customActiveAppKey: '',
@@ -9,6 +10,11 @@ const initialState = {
9
10
  customItems: [],
10
11
  customMenuChildren: [],
11
12
  isCustomized: false,
13
+ dashboardParams: {
14
+ objectId: DASHBOARD_MODULE_CONFIG.objectId,
15
+ objectType: DASHBOARD_MODULE_CONFIG.objectType,
16
+ isGrouped: DASHBOARD_MODULE_CONFIG.isGrouped,
17
+ },
12
18
  };
13
19
  export const useLeftMenuStore = create(set => ({
14
20
  state: initialState,
@@ -172,10 +172,10 @@ export const getMappingAppChildren = (args) => {
172
172
  appItem.children = (_d = appItem.children) === null || _d === void 0 ? void 0 : _d.map(childMenuItem => {
173
173
  switch (childMenuItem.menu_item_code) {
174
174
  case MARKETING_CHANNEL_CODE.ALL_CHANNEL:
175
- childMenuItem.menu_item_path = getGeneratePath(MARKETING_ROUTES.CHANNEL, Object.assign(Object.assign({}, auth), { channelId: MARKETING_CHANNEL_KEY.ALL_CHANNEL }));
175
+ childMenuItem.menu_item_path = getGeneratePath(childMenuItem.menu_item_path || '', Object.assign(Object.assign({}, auth), { channelId: MARKETING_CHANNEL_KEY.ALL_CHANNEL }));
176
176
  break;
177
177
  case MARKETING_CHANNEL_CODE.ORCHESTRATION:
178
- childMenuItem.menu_item_path = getGeneratePath(MARKETING_ROUTES.CHANNEL, Object.assign(Object.assign({}, auth), { channelId: MARKETING_CHANNEL_KEY.JOURNEY_ORCHESTRATION }));
178
+ childMenuItem.menu_item_path = getGeneratePath(childMenuItem.menu_item_path || '', Object.assign(Object.assign({}, auth), { channelId: MARKETING_CHANNEL_KEY.JOURNEY_ORCHESTRATION }));
179
179
  break;
180
180
  default:
181
181
  break;
@@ -0,0 +1,7 @@
1
+ export declare const DASHBOARD_MODULE_CONFIG: {
2
+ key: string;
3
+ module: string;
4
+ objectId: number;
5
+ objectType: string;
6
+ isGrouped: boolean;
7
+ };
@@ -0,0 +1,7 @@
1
+ export const DASHBOARD_MODULE_CONFIG = {
2
+ key: 'dashboard-report',
3
+ module: 'DASHBOARD',
4
+ objectId: 1,
5
+ objectType: 'OVERVIEW',
6
+ isGrouped: true,
7
+ };
@@ -1,2 +1,3 @@
1
1
  export * from './menuCode';
2
2
  export * from './permission';
3
+ export * from './config';
@@ -1,2 +1,3 @@
1
1
  export * from './menuCode';
2
2
  export * from './permission';
3
+ export * from './config';
@@ -6,5 +6,6 @@ export declare const ENV: {
6
6
  export declare const isDev: boolean;
7
7
  export declare const ENDPOINT: {
8
8
  readonly DASHBOARD_V2: "dashboard/v2.0";
9
+ readonly OVERVIEW: "dashboard/v2.0/overview";
9
10
  readonly TOOLKIT_V2: "toolkit/v2.0";
10
11
  };
@@ -10,5 +10,6 @@ const API_VERSION_V2 = '2.0';
10
10
  /* ENDPOINT */
11
11
  export const ENDPOINT = {
12
12
  DASHBOARD_V2: `dashboard/v${API_VERSION_V2}`,
13
+ OVERVIEW: `dashboard/v${API_VERSION_V2}/overview`,
13
14
  TOOLKIT_V2: `toolkit/v${API_VERSION_V2}`,
14
15
  };
@@ -1,3 +1,6 @@
1
+ export declare const API_RESPONSE_CODE: {
2
+ SUCCESS: number;
3
+ };
1
4
  export declare const TINYMCE_API_KEY = "scyw71pj8619analvxs56ppc2w2fj2kpy5vnmflhhc300y35";
2
5
  export declare const CDP_API: {
3
6
  development: string;
@@ -1,6 +1,9 @@
1
1
  // Constants
2
2
  import { ENV } from '../config';
3
3
  import { APP_CODES } from './variables';
4
+ export const API_RESPONSE_CODE = {
5
+ SUCCESS: 200,
6
+ };
4
7
  const { DATAFLOWS, APP_ANTALYSER } = APP_CODES;
5
8
  export const TINYMCE_API_KEY = 'scyw71pj8619analvxs56ppc2w2fj2kpy5vnmflhhc300y35';
6
9
  export const CDP_API = {
@@ -1,4 +1,4 @@
1
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
1
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
2
2
  // Types
3
3
  import { theme } from 'antd';
4
4
  // Variables
@@ -89,18 +89,19 @@ THEME.components = {
89
89
  colorBorder: (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.blue1,
90
90
  colorText: (_b = THEME.token) === null || _b === void 0 ? void 0 : _b.colorPrimary,
91
91
  colorBgContainerDisabled: (_c = THEME.token) === null || _c === void 0 ? void 0 : _c.bw6,
92
- colorTextDisabled: (_d = THEME.token) === null || _d === void 0 ? void 0 : _d.bw0,
92
+ borderColorDisabled: (_d = THEME.token) === null || _d === void 0 ? void 0 : _d.bw6,
93
+ colorTextDisabled: (_e = THEME.token) === null || _e === void 0 ? void 0 : _e.bw0,
93
94
  textHoverBg: '#F2F9FF',
94
95
  /* Text type */
95
- colorBgTextHover: (_e = THEME.token) === null || _e === void 0 ? void 0 : _e.blue,
96
- colorBgTextActive: (_f = THEME.token) === null || _f === void 0 ? void 0 : _f.blue1_1,
96
+ colorBgTextHover: (_f = THEME.token) === null || _f === void 0 ? void 0 : _f.blue,
97
+ colorBgTextActive: (_g = THEME.token) === null || _g === void 0 ? void 0 : _g.blue1_1,
97
98
  },
98
99
  Input: {
99
100
  controlHeight: 32,
100
- colorBgContainerDisabled: (_g = THEME.token) === null || _g === void 0 ? void 0 : _g.bw2,
101
- colorTextDisabled: (_h = THEME.token) === null || _h === void 0 ? void 0 : _h.bw10,
102
- colorBorder: (_j = THEME.token) === null || _j === void 0 ? void 0 : _j.blue1,
103
- colorTextPlaceholder: (_k = THEME.token) === null || _k === void 0 ? void 0 : _k.bw6,
101
+ colorBgContainerDisabled: (_h = THEME.token) === null || _h === void 0 ? void 0 : _h.bw2,
102
+ colorTextDisabled: (_j = THEME.token) === null || _j === void 0 ? void 0 : _j.bw10,
103
+ colorBorder: (_k = THEME.token) === null || _k === void 0 ? void 0 : _k.blue1,
104
+ colorTextPlaceholder: (_l = THEME.token) === null || _l === void 0 ? void 0 : _l.bw6,
104
105
  borderRadius: 0,
105
106
  borderRadiusLG: 0,
106
107
  borderRadiusSM: 0,
@@ -114,10 +115,10 @@ THEME.components = {
114
115
  borderRadiusOuter: 0,
115
116
  borderRadiusXS: 0,
116
117
  optionActiveBg: '#F2F9FF',
117
- optionSelectedBg: (_l = THEME.token) === null || _l === void 0 ? void 0 : _l.blue1_1,
118
- colorBorder: (_m = THEME.token) === null || _m === void 0 ? void 0 : _m.blue1,
118
+ optionSelectedBg: (_m = THEME.token) === null || _m === void 0 ? void 0 : _m.blue1_1,
119
+ colorBorder: (_o = THEME.token) === null || _o === void 0 ? void 0 : _o.blue1,
119
120
  controlItemBgActive: '#E0EBF7',
120
- colorBgContainerDisabled: (_o = THEME.token) === null || _o === void 0 ? void 0 : _o.bw2,
121
+ colorBgContainerDisabled: (_p = THEME.token) === null || _p === void 0 ? void 0 : _p.bw2,
121
122
  fontSizeIcon: 14,
122
123
  paddingSM: 6,
123
124
  },
@@ -131,9 +132,9 @@ THEME.components = {
131
132
  borderRadiusOuter: 0,
132
133
  controlHeight: 30,
133
134
  borderRadiusXS: 0,
134
- colorBorder: (_p = THEME.token) === null || _p === void 0 ? void 0 : _p.blue1,
135
+ colorBorder: (_q = THEME.token) === null || _q === void 0 ? void 0 : _q.blue1,
135
136
  controlItemBgActive: '#E0EBF7',
136
- colorBgContainerDisabled: (_q = THEME.token) === null || _q === void 0 ? void 0 : _q.bw2,
137
+ colorBgContainerDisabled: (_r = THEME.token) === null || _r === void 0 ? void 0 : _r.bw2,
137
138
  // fontSizeIcon: 14,
138
139
  },
139
140
  DatePicker: {
@@ -142,20 +143,20 @@ THEME.components = {
142
143
  borderRadiusSM: 0,
143
144
  borderRadiusOuter: 0,
144
145
  borderRadiusXS: 0,
145
- colorBorder: (_r = THEME.token) === null || _r === void 0 ? void 0 : _r.blue1,
146
+ colorBorder: (_s = THEME.token) === null || _s === void 0 ? void 0 : _s.blue1,
146
147
  controlItemBgActive: '#E0EBF7',
147
- colorBgContainerDisabled: (_s = THEME.token) === null || _s === void 0 ? void 0 : _s.bw2,
148
+ colorBgContainerDisabled: (_t = THEME.token) === null || _t === void 0 ? void 0 : _t.bw2,
148
149
  fontSizeIcon: 14,
149
150
  controlHeight: 31,
150
151
  },
151
152
  Divider: {
152
153
  marginLG: 15,
153
154
  marginXL: 15,
154
- colorSplit: (_t = THEME.token) === null || _t === void 0 ? void 0 : _t.accent3,
155
+ colorSplit: (_u = THEME.token) === null || _u === void 0 ? void 0 : _u.accent3,
155
156
  },
156
157
  Checkbox: {
157
158
  controlInteractiveSize: 18,
158
- colorBorder: (_u = THEME.token) === null || _u === void 0 ? void 0 : _u.colorPrimary,
159
+ colorBorder: (_v = THEME.token) === null || _v === void 0 ? void 0 : _v.colorPrimary,
159
160
  lineWidth: 2,
160
161
  borderRadiusSM: 5,
161
162
  },
@@ -168,7 +169,7 @@ THEME.components = {
168
169
  paddingMD: 0,
169
170
  },
170
171
  Tabs: {
171
- itemColor: (_v = THEME.token) === null || _v === void 0 ? void 0 : _v.bw8,
172
+ itemColor: (_w = THEME.token) === null || _w === void 0 ? void 0 : _w.bw8,
172
173
  horizontalItemPadding: '17px 30px',
173
174
  horizontalItemGutter: 0,
174
175
  lineWidthBold: 3,
@@ -180,7 +181,7 @@ THEME.components = {
180
181
  lineHeight: 1.143,
181
182
  lineHeightLG: 1.143,
182
183
  lineHeightSM: 1.143,
183
- itemHoverColor: (_w = THEME.token) === null || _w === void 0 ? void 0 : _w.colorPrimary,
184
+ itemHoverColor: (_x = THEME.token) === null || _x === void 0 ? void 0 : _x.colorPrimary,
184
185
  },
185
186
  Collapse: {
186
187
  headerBg: '#FFF',
@@ -188,12 +189,12 @@ THEME.components = {
188
189
  headerPadding: '15px 10px',
189
190
  },
190
191
  Switch: {
191
- colorTextQuaternary: (_x = THEME.token) === null || _x === void 0 ? void 0 : _x.bw0,
192
- colorTextTertiary: (_y = THEME.token) === null || _y === void 0 ? void 0 : _y.bw0,
192
+ colorTextQuaternary: (_y = THEME.token) === null || _y === void 0 ? void 0 : _y.bw0,
193
+ colorTextTertiary: (_z = THEME.token) === null || _z === void 0 ? void 0 : _z.bw0,
193
194
  handleSize: 12,
194
195
  handleSizeSM: 7,
195
196
  trackMinWidth: 30,
196
- handleBg: (_z = THEME.token) === null || _z === void 0 ? void 0 : _z.colorPrimary,
197
+ handleBg: (_0 = THEME.token) === null || _0 === void 0 ? void 0 : _0.colorPrimary,
197
198
  },
198
199
  Popover: {
199
200
  borderRadiusLG: 10,
@@ -205,7 +206,7 @@ THEME.components = {
205
206
  controlItemBgHover: '#F2F9FF',
206
207
  },
207
208
  Tooltip: {
208
- colorBgSpotlight: (_0 = THEME.token) === null || _0 === void 0 ? void 0 : _0.bw8,
209
+ colorBgSpotlight: (_1 = THEME.token) === null || _1 === void 0 ? void 0 : _1.bw8,
209
210
  },
210
211
  Menu: {
211
212
  itemHoverBg: '#F2F9FF',
@@ -214,8 +215,8 @@ THEME.components = {
214
215
  itemMarginBlock: 5,
215
216
  itemBorderRadius: 5,
216
217
  subMenuItemBg: 'transparent',
217
- itemDisabledColor: (_1 = THEME.token) === null || _1 === void 0 ? void 0 : _1.colorTextDisabled,
218
- itemActiveBg: (_2 = THEME.token) === null || _2 === void 0 ? void 0 : _2.blue1_1,
218
+ itemDisabledColor: (_2 = THEME.token) === null || _2 === void 0 ? void 0 : _2.colorTextDisabled,
219
+ itemActiveBg: (_3 = THEME.token) === null || _3 === void 0 ? void 0 : _3.blue1_1,
219
220
  },
220
221
  Form: {},
221
222
  };
@@ -543,5 +543,6 @@
543
543
  "column": "Column",
544
544
  "explore": "Explore"
545
545
  }
546
- }
546
+ },
547
+ "remove": "Remove"
547
548
  }
@@ -546,6 +546,7 @@ export declare const translationsJson: {
546
546
  explore: string;
547
547
  };
548
548
  };
549
+ remove: string;
549
550
  };
550
551
  };
551
552
  vi: {
@@ -638,6 +639,14 @@ export declare const translationsJson: {
638
639
  explore: string;
639
640
  };
640
641
  };
642
+ edit: {
643
+ title: string;
644
+ description: string;
645
+ };
646
+ duplicate: {
647
+ title: string;
648
+ };
649
+ remove: string;
641
650
  };
642
651
  };
643
652
  };
@@ -546,6 +546,7 @@ export declare const convertLanguageJsonToObject: (json: any, objToConvertTo?: C
546
546
  explore: string;
547
547
  };
548
548
  };
549
+ remove: string;
549
550
  }>, current?: string) => void;
550
551
  export declare const t: (id: string, ...rest: any[]) => [string, ...any[]];
551
552
  export declare const getTranslateMessage: (id: string, defaultMessage?: string, value?: Record<string, unknown>) => string;
@@ -86,5 +86,13 @@
86
86
  "column": "Cột",
87
87
  "explore": "Khám phá"
88
88
  }
89
- }
89
+ },
90
+ "edit": {
91
+ "title": "Chỉnh sửa",
92
+ "description": ""
93
+ },
94
+ "duplicate": {
95
+ "title": "Sao chép"
96
+ },
97
+ "remove": "Xóa"
90
98
  }
@@ -139,7 +139,7 @@ export const GlobalStyle = () => {
139
139
  color: ${(_h = THEME.token) === null || _h === void 0 ? void 0 : _h.bw6} !important;
140
140
  }
141
141
 
142
- .antsomi-btn-primary:disabled,
142
+ /* .antsomi-btn-primary:disabled, */
143
143
  .antsomi-btn-default:disabled,
144
144
  .antsomi-btn-dashed:disabled,
145
145
  .antsomi-btn-disabled,
@@ -18,6 +18,7 @@ export type TGetDestinationChannel = {
18
18
  options?: UseQueryOptions<any, any, TDestinationChannelResponse, any[]>;
19
19
  };
20
20
  export declare const useGetDashboard: (params: TGetDashboard) => import("@tanstack/react-query").UseQueryResult<TDashboardResponse, any>;
21
+ export declare const useUpdateTask: () => import("@tanstack/react-query").UseMutationResult<any, unknown, import("../../services/LeftMenu").TRemoveDashboardArgs, unknown>;
21
22
  export declare const useGetListMenu: (params: TGetListMenu) => import("@tanstack/react-query").UseQueryResult<TFeatureMenuResponse, any>;
22
23
  export declare const useGetListMenuPermission: (params: TGetListMenuPermission) => import("@tanstack/react-query").UseQueryResult<FeatureMenuPermission[], any>;
23
24
  export declare const useGetDestinationChannel: (params: TGetDestinationChannel) => import("@tanstack/react-query").UseQueryResult<TDestinationChannelResponse, any>;
@@ -1,14 +1,28 @@
1
1
  // Libraries
2
- import { useQuery } from '@tanstack/react-query';
2
+ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
3
3
  // Services
4
4
  import { leftMenuServices, } from '../../services/LeftMenu';
5
5
  // Constants
6
6
  import { QUERY_KEYS } from '../../constants/queries';
7
- const { getDashboard, getListMenu, getListMenuPermission, getDestinationChannel } = leftMenuServices;
7
+ import { API_RESPONSE_CODE } from '../../constants';
8
+ const { getDashboard, removeDashboard, getListMenu, getListMenuPermission, getDestinationChannel } = leftMenuServices;
8
9
  export const useGetDashboard = (params) => {
9
10
  const { options, args } = params;
10
11
  return useQuery(Object.assign({ queryKey: [QUERY_KEYS.GET_DASHBOARD, args.params, args.auth], queryFn: () => getDashboard(params.args), onSuccess() { } }, options));
11
12
  };
13
+ export const useUpdateTask = () => {
14
+ const queryClient = useQueryClient();
15
+ return useMutation(removeDashboard, {
16
+ onSuccess: data => {
17
+ const { code } = data || {};
18
+ if (code === API_RESPONSE_CODE.SUCCESS) {
19
+ queryClient.invalidateQueries([QUERY_KEYS.GET_DASHBOARD], {
20
+ exact: false,
21
+ });
22
+ }
23
+ },
24
+ });
25
+ };
12
26
  export const useGetListMenu = (params) => {
13
27
  const { options, args } = params;
14
28
  return useQuery(Object.assign({ queryKey: [QUERY_KEYS.GET_LIST_MENU, args.params, args.auth], queryFn: () => getListMenu(params.args), onSuccess() { } }, options));
@@ -10,6 +10,16 @@ export type TGetDashboardArgs = {
10
10
  };
11
11
  auth: PayloadInfo;
12
12
  };
13
+ export type TRemoveDashboardArgs = {
14
+ params: {
15
+ dashboardId: number;
16
+ objectType: string;
17
+ objectId: number;
18
+ isGrouped?: boolean;
19
+ languageCode?: string;
20
+ };
21
+ auth: PayloadInfo;
22
+ };
13
23
  export type TGetListMenuArgs = {
14
24
  params: {
15
25
  type?: string;
@@ -34,6 +44,7 @@ export type TGetDestinationChannelArgs = {
34
44
  };
35
45
  export declare const leftMenuServices: {
36
46
  getDashboard: ({ params, auth }: TGetDashboardArgs) => Promise<TDashboardResponse>;
47
+ removeDashboard: ({ params, auth }: TRemoveDashboardArgs) => Promise<any>;
37
48
  getListMenu: ({ params, auth }: TGetListMenuArgs) => Promise<TFeatureMenuResponse>;
38
49
  getListMenuPermission: ({ params, auth, }: TGetListMenuPermissionArgs) => Promise<FeatureMenuPermission[]>;
39
50
  getDestinationChannel: ({ params, auth, }: TGetDestinationChannelArgs) => Promise<TDataResponse<TDestinationChannel>>;
@@ -47,7 +47,35 @@ export const leftMenuServices = {
47
47
  return Promise.reject(error);
48
48
  }
49
49
  }),
50
- getListMenu: (_b) => __awaiter(void 0, [_b], void 0, function* ({ params, auth }) {
50
+ removeDashboard: (_b) => __awaiter(void 0, [_b], void 0, function* ({ params, auth }) {
51
+ try {
52
+ const { dashboardId, objectId, isGrouped = false, languageCode } = params;
53
+ const headers = {
54
+ 'Content-Type': 'application/json; charset=utf-8',
55
+ token: auth.token,
56
+ };
57
+ const REMOVE_STATUS = 3;
58
+ const response = yield axios({
59
+ method: 'PUT',
60
+ url: `${auth.url}/${ENDPOINT.OVERVIEW}/update-status/${dashboardId}`,
61
+ headers,
62
+ params: {
63
+ _user_id: auth.userId,
64
+ _owner_id: (auth === null || auth === void 0 ? void 0 : auth.accountId) || (auth === null || auth === void 0 ? void 0 : auth.userId),
65
+ portalId: auth.portalId,
66
+ languageCode,
67
+ isGrouped,
68
+ objectType: objectId,
69
+ status: REMOVE_STATUS,
70
+ },
71
+ });
72
+ return (response === null || response === void 0 ? void 0 : response.data) || {};
73
+ }
74
+ catch (error) {
75
+ return Promise.reject(error);
76
+ }
77
+ }),
78
+ getListMenu: (_c) => __awaiter(void 0, [_c], void 0, function* ({ params, auth }) {
51
79
  try {
52
80
  const { type } = params;
53
81
  const { url, accountId, portalId, token, userId } = auth;
@@ -68,7 +96,7 @@ export const leftMenuServices = {
68
96
  return Promise.reject(error);
69
97
  }
70
98
  }),
71
- getListMenuPermission: (_c) => __awaiter(void 0, [_c], void 0, function* ({ params, auth, }) {
99
+ getListMenuPermission: (_d) => __awaiter(void 0, [_d], void 0, function* ({ params, auth, }) {
72
100
  try {
73
101
  const { type, languageCode, hasChild, from } = params;
74
102
  const { url, accountId, token, userId } = auth;
@@ -92,7 +120,7 @@ export const leftMenuServices = {
92
120
  return Promise.reject(error);
93
121
  }
94
122
  }),
95
- getDestinationChannel: (_d) => __awaiter(void 0, [_d], void 0, function* ({ params, auth, }) {
123
+ getDestinationChannel: (_e) => __awaiter(void 0, [_e], void 0, function* ({ params, auth, }) {
96
124
  try {
97
125
  const { languageCode, objectType } = params;
98
126
  const { url, token, userId, portalId } = auth;
@@ -1,5 +1,22 @@
1
+ import { ButtonProps } from 'antd';
1
2
  import { GET_LIST_TYPE } from '../constants';
3
+ import { ReactNode } from 'react';
2
4
  export type TUnit = 'px' | '%' | any;
3
5
  export type TAlign = 'left' | 'center' | 'right';
4
6
  export type TGetListType = (typeof GET_LIST_TYPE)[keyof typeof GET_LIST_TYPE];
5
7
  export type TBoolean = 1 | 0;
8
+ /**
9
+ * @typedef {Object} TActionButton
10
+ * @property {ButtonProps} [buttonProps] - Optional properties for the button.
11
+ * @property {string} [key] - Optional unique key for the button.
12
+ * @property {string} [label] - Optional label for the button.
13
+ * @property {string} [icon] - Optional icon for the button.
14
+ * @property {function(ReactNode): ReactNode} [customRender] - Optional custom render function for the button's node.
15
+ */
16
+ export type TActionButton = {
17
+ buttonProps?: ButtonProps;
18
+ key?: string;
19
+ label?: string;
20
+ icon?: string;
21
+ customRender?: (node: ReactNode) => ReactNode;
22
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.323",
3
+ "version": "1.3.5-beta.325",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",
@@ -60,7 +60,7 @@
60
60
  "not op_mini all"
61
61
  ],
62
62
  "dependencies": {
63
- "@antscorp/icons": "^0.27.24",
63
+ "@antscorp/icons": "^0.27.26",
64
64
  "@antscorp/image-editor": "1.0.2",
65
65
  "@antscorp/processing-notification": "^1.0.3",
66
66
  "@dnd-kit/core": "^6.1.0",