@antscorp/antsomi-ui 1.3.5-beta.324 → 1.3.5-beta.327

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.
@@ -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,7 +19,7 @@ var __rest = (this && this.__rest) || function (s, e) {
19
19
  return t;
20
20
  };
21
21
  // Libraries
22
- import React, { memo } from 'react';
22
+ import React from 'react';
23
23
  import { Icon } from '@antscorp/antsomi-ui/es/components/atoms';
24
24
  import { Modal } from 'antd';
25
25
  import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
@@ -31,10 +31,196 @@ import { Button, Flex, Typography, Spin, Tooltip } from '../../atoms';
31
31
  import { THUMBNAIL_CARD_ACTION_OPTIONS, THUMBNAIL_CARD_DEFAULT_HEIGHT, THUMBNAIL_CARD_DEFAULT_WIDTH, } from './constants';
32
32
  import { getUrlNoCache, checkShowSkeletonBaseUrl } from '@antscorp/antsomi-ui/es/utils';
33
33
  import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
34
- export const ThumbnailCard = memo(props => {
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) => {
35
222
  const [modal, contextHolder] = Modal.useModal();
36
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"]);
37
- console.log({ actionButtons });
38
224
  const _a = removeModalProps || {}, { onOk } = _a, restOfRemoveTemplateModalProps = __rest(_a, ["onOk"]);
39
225
  const _b = editBtnProps || {}, { text: editText = 'Use template', onClick: onClickEdit } = _b, restOfEditBtnProps = __rest(_b, ["text", "onClick"]);
40
226
  const _c = previewBtnProps || {}, { text: previewText = 'Preview', onClick: onClickPreview } = _c, restOfPreviewBtnProps = __rest(_c, ["text", "onClick"]);
@@ -70,10 +256,10 @@ export const ThumbnailCard = memo(props => {
70
256
  const actionSettings = actionButtons[key];
71
257
  if (actionSettings) {
72
258
  const { buttonProps, key, customRender } = actionSettings;
73
- const icon = actionSettings.icon || option.icon || '';
74
- const label = actionSettings.label || option.label || '';
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) || '';
75
261
  const ButtonComponent = (React.createElement(Tooltip, { title: label },
76
- React.createElement(Button, Object.assign({ key: key || option.key, type: "primary", icon: React.createElement(Icon, { type: icon || option.icon, style: { fontSize: 24, color: '#FFFFFF' } }) }, buttonProps))));
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))));
77
263
  /**
78
264
  * Handle custom render for action button
79
265
  * If customRender is a function, return the function callback the ButtonComponent
@@ -112,5 +298,5 @@ export const ThumbnailCard = memo(props => {
112
298
  React.createElement("div", null, contextHolder))),
113
299
  loading && React.createElement(Spin, { className: "thumbnail__loading", spinning: true })),
114
300
  !!name && (React.createElement(Typography.Text, { ellipsis: { tooltip: name }, style: { maxWidth: '100%' } }, name))));
115
- });
301
+ };
116
302
  ThumbnailCard.displayName = 'ThumbnailCard';
@@ -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
  };
@@ -40,7 +40,7 @@ export const HOME_REPORT_ROUTES = {
40
40
  };
41
41
  /* MARKETING APP */
42
42
  export const MARKETING_ROUTES = {
43
- CHANNEL: '/gen2/:networkId/:user_id/marketing-hub/journeys/:channelId/list',
43
+ CHANNEL: '/gen2/:networkId/:user_id/marketing-hub/journeys/:channelId',
44
44
  };
45
45
  export const MARKETING_CHANNEL_KEY = { ALL_CHANNEL: 0, JOURNEY_ORCHESTRATION: 8 };
46
46
  export const RENDER_OPTION = { CHANNEL: 'destination_channel' };
@@ -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 = {
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.324",
3
+ "version": "1.3.5-beta.327",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",