@antscorp/antsomi-ui 1.3.5-beta.216 → 1.3.5-beta.217
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/AccountSelection/AccountSelection.d.ts +1 -0
- package/es/components/molecules/AccountSelection/AccountSelection.js +46 -7
- package/es/components/molecules/HeaderV2/HeaderV2.d.ts +2 -0
- package/es/components/molecules/HeaderV2/HeaderV2.js +24 -10
- package/es/components/organism/FilterSetting/utils.d.ts +1 -1
- package/es/components/organism/LeftMenu/components/common/ChildMenu/index.js +8 -5
- package/es/components/organism/LeftMenu/components/common/ChildMenu/styled.js +1 -1
- package/es/components/organism/LeftMenu/constants/variables.d.ts +1 -5
- package/es/components/organism/LeftMenu/constants/variables.js +1 -5
- package/es/components/organism/LeftMenu/hooks/useLeftMenu.js +14 -7
- package/es/components/organism/LeftMenu/index.d.ts +2 -1
- package/es/components/organism/LeftMenu/styled.d.ts +1 -0
- package/es/components/organism/LeftMenu/styled.js +12 -0
- package/es/components/organism/LeftMenu/utils/index.d.ts +6 -2
- package/es/components/organism/LeftMenu/utils/index.js +38 -8
- package/es/components/template/Layout/Layout.js +80 -17
- package/es/components/template/Layout/constants/permission.d.ts +14 -0
- package/es/components/template/Layout/constants/permission.js +14 -0
- package/es/components/template/TemplateListing/index.js +4 -2
- package/es/constants/api.d.ts +14 -0
- package/es/constants/api.js +16 -0
- package/es/constants/queries.d.ts +1 -0
- package/es/constants/queries.js +1 -0
- package/es/constants/variables.d.ts +7 -0
- package/es/constants/variables.js +8 -0
- package/es/queries/Permission/index.d.ts +8 -0
- package/es/queries/Permission/index.js +10 -0
- package/es/queries/index.d.ts +1 -0
- package/es/queries/index.js +1 -0
- package/es/services/Permission/index.d.ts +13 -0
- package/es/services/Permission/index.js +39 -0
- package/package.json +1 -1
|
@@ -3,16 +3,54 @@ import React, { useCallback, useMemo, useState } from 'react';
|
|
|
3
3
|
import { Input, Popover, Text } from '@antscorp/antsomi-ui/es/components/atoms';
|
|
4
4
|
import { AccountItem } from './components';
|
|
5
5
|
import { AccountSelectionStyled, PopoverFieldStyled } from './styled';
|
|
6
|
-
import { useGetAccountList, useGetRecentAccount } from '../../..';
|
|
6
|
+
import { useGetAccountList, useGetPermissionAccountList, useGetRecentAccount } from '../../..';
|
|
7
7
|
import { Tooltip } from 'antd';
|
|
8
8
|
import { searchStringQuery } from '@antscorp/antsomi-ui/es/utils';
|
|
9
|
+
import { PORTALS_IDS } from '@antscorp/antsomi-ui/es/constants';
|
|
9
10
|
export const AccountSelection = props => {
|
|
10
11
|
const { show = true, className, apiConfig, showAllAccount = true, currentAccount, inputStyle = 'input', onChange, } = props;
|
|
11
|
-
const {
|
|
12
|
-
const { data
|
|
12
|
+
const { domain, token, userId, appCode, portalId } = apiConfig;
|
|
13
|
+
const { data } = useGetAccountList({
|
|
14
|
+
apiConfig,
|
|
15
|
+
options: {
|
|
16
|
+
enabled: portalId !== PORTALS_IDS.SANDBOX_76753,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
const { data: permissionAccountList } = useGetPermissionAccountList({
|
|
20
|
+
args: {
|
|
21
|
+
_account_id: userId,
|
|
22
|
+
_user_id: userId,
|
|
23
|
+
_app_code: appCode || '',
|
|
24
|
+
_token: token,
|
|
25
|
+
domain,
|
|
26
|
+
appCode: appCode || '',
|
|
27
|
+
fullParent: true,
|
|
28
|
+
menuCode: appCode || '',
|
|
29
|
+
},
|
|
30
|
+
options: {
|
|
31
|
+
enabled: portalId === PORTALS_IDS.SANDBOX_76753,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
const { data: recentData } = useGetRecentAccount({
|
|
35
|
+
apiConfig,
|
|
36
|
+
options: {
|
|
37
|
+
enabled: portalId !== PORTALS_IDS.SANDBOX_76753,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
const accountData = useMemo(() => {
|
|
41
|
+
if (portalId === PORTALS_IDS.SANDBOX_76753) {
|
|
42
|
+
return ((permissionAccountList === null || permissionAccountList === void 0 ? void 0 : permissionAccountList.map(account => ({
|
|
43
|
+
email: account.email,
|
|
44
|
+
userId: account.user_id,
|
|
45
|
+
userName: account.full_name,
|
|
46
|
+
status: 1,
|
|
47
|
+
}))) || []);
|
|
48
|
+
}
|
|
49
|
+
return (data === null || data === void 0 ? void 0 : data.entries) || [];
|
|
50
|
+
}, [data === null || data === void 0 ? void 0 : data.entries, permissionAccountList, portalId]);
|
|
51
|
+
const currentAccountInfo = useMemo(() => accountData === null || accountData === void 0 ? void 0 : accountData.find(account => account.userId === currentAccount), [accountData, currentAccount]);
|
|
13
52
|
const [open, setOpen] = useState(false);
|
|
14
53
|
const [searchValue, setSearchValue] = useState('');
|
|
15
|
-
const currentAccountInfo = useMemo(() => { var _a; return (_a = data === null || data === void 0 ? void 0 : data.entries) === null || _a === void 0 ? void 0 : _a.find(account => account.userId === currentAccount); }, [data, currentAccount]);
|
|
16
54
|
const handleSelectAccount = useCallback((userId) => {
|
|
17
55
|
setOpen(false);
|
|
18
56
|
if (onChange)
|
|
@@ -20,10 +58,11 @@ export const AccountSelection = props => {
|
|
|
20
58
|
}, [onChange]);
|
|
21
59
|
return (show && (React.createElement(Popover, { content: React.createElement(AccountSelectionStyled, { className: className },
|
|
22
60
|
React.createElement(Input, { placeholder: "Search", suffix: React.createElement(Icon, { type: "icon-ants-search-2", style: { fontSize: '24px' } }), value: searchValue, onChange: event => setSearchValue(event.target.value) }),
|
|
23
|
-
|
|
24
|
-
|
|
61
|
+
!!(recentData === null || recentData === void 0 ? void 0 : recentData.value) && (React.createElement(React.Fragment, null,
|
|
62
|
+
React.createElement(Text, { className: "recent-text" }, "Recent"),
|
|
63
|
+
React.createElement("ul", null, recentData === null || recentData === void 0 ? void 0 : recentData.value.map(accountId => accountData === null || accountData === void 0 ? void 0 : accountData.find(account => account.userId === accountId)).filter(Boolean).map(account => (React.createElement(AccountItem, { key: account.userId, userName: account.userName, userId: account.userId, onClick: handleSelectAccount, isSelected: currentAccount === account.userId })))))),
|
|
25
64
|
React.createElement("div", { className: "antsomi-scroll-box account-list" },
|
|
26
|
-
React.createElement("ul", { className: "scroll-content" },
|
|
65
|
+
React.createElement("ul", { className: "scroll-content" }, accountData === null || accountData === void 0 ? void 0 : accountData.filter(account => !(recentData === null || recentData === void 0 ? void 0 : recentData.value.includes(account.userId)) &&
|
|
27
66
|
searchStringQuery(account.userName, searchValue)).map(account => (React.createElement(AccountItem, { key: account.userId, userName: account.userName, userId: account.userId, onClick: handleSelectAccount, isSelected: currentAccount === account.userId }))))),
|
|
28
67
|
showAllAccount ? (React.createElement(Text, { className: `all-account ${currentAccount === 'ALL_ACCOUNT' ? 'is-selected' : ''}`, onClick: () => handleSelectAccount('ALL_ACCOUNT') },
|
|
29
68
|
React.createElement("strong", null, "All account"))) : null), trigger: "click", overlayInnerStyle: { padding: 0 }, placement: "bottomLeft", arrow: false, open: open, onOpenChange: setOpen },
|
|
@@ -9,23 +9,24 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import React, { memo, useEffect, useState } from 'react';
|
|
12
|
+
import React, { memo, useEffect, useMemo, useState } from 'react';
|
|
13
13
|
// Styled
|
|
14
14
|
import { HeaderV2Styled } from './styled';
|
|
15
15
|
// Components
|
|
16
16
|
import { AccountSelection } from '../AccountSelection';
|
|
17
17
|
import { AccountSharing, Help, Notification, } from '../../organism';
|
|
18
18
|
// Constants
|
|
19
|
-
import { CDP_API, IAM_API, ISSUE_API, PERMISSION_API, PLATFORM_API, SOCKET_API, } from '@antscorp/antsomi-ui/es/constants';
|
|
19
|
+
import { APP_CODES, APP_PERMISSION_DOMAIN, CDP_API, IAM_API, ISSUE_API, PERMISSION_API, PLATFORM_API, PORTALS_IDS, SOCKET_API, } from '@antscorp/antsomi-ui/es/constants';
|
|
20
20
|
import { useContextSelector } from 'use-context-selector';
|
|
21
21
|
import { AppConfigContext } from '../../..';
|
|
22
|
+
const { DATAFLOWS } = APP_CODES;
|
|
22
23
|
export const HeaderV2 = memo(props => {
|
|
23
24
|
var _a, _b, _c;
|
|
24
|
-
const { auth, env: envContext, languageCode = 'en', } = useContextSelector(AppConfigContext, state => state);
|
|
25
|
+
const { auth, env: envContext, languageCode = 'en', appCode, } = useContextSelector(AppConfigContext, state => state);
|
|
25
26
|
/** Prefer to use Header in AppConfigContext */
|
|
26
27
|
const { className, style, pageTitle = 'Page Title', accountSelection = {}, helpConfig, notificationConfig = {}, accountSharingConfig, useURLParam, config, } = props;
|
|
27
28
|
/** General config for children component */
|
|
28
|
-
const { env = envContext, language = languageCode, userId = isNaN(Number(auth === null || auth === void 0 ? void 0 : auth.userId)) ? 0 : Number(auth === null || auth === void 0 ? void 0 : auth.userId), portalId = auth === null || auth === void 0 ? void 0 : auth.portalId, token = auth === null || auth === void 0 ? void 0 : auth.token, } = config || {};
|
|
29
|
+
const { env = envContext, language = languageCode, userId = isNaN(Number(auth === null || auth === void 0 ? void 0 : auth.userId)) ? 0 : Number(auth === null || auth === void 0 ? void 0 : auth.userId), portalId = auth === null || auth === void 0 ? void 0 : auth.portalId, token = auth === null || auth === void 0 ? void 0 : auth.token, permissionDomain = PERMISSION_API, iamDomain = IAM_API, } = config || {};
|
|
29
30
|
const { currentAccount, inputStyle = 'select', onSelectAccount } = accountSelection, accountSelectionProps = __rest(accountSelection, ["currentAccount", "inputStyle", "onSelectAccount"]);
|
|
30
31
|
const urlParams = new URLSearchParams(window.location.search);
|
|
31
32
|
const oidParam = urlParams.get('oid');
|
|
@@ -47,17 +48,30 @@ export const HeaderV2 = memo(props => {
|
|
|
47
48
|
}
|
|
48
49
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
49
50
|
}, [oidParam, useURLParam, userId]);
|
|
51
|
+
// Memo
|
|
52
|
+
const accountSelectionDomain = useMemo(() => {
|
|
53
|
+
var _a;
|
|
54
|
+
if (portalId !== PORTALS_IDS.SANDBOX_76753)
|
|
55
|
+
return CDP_API[env || 'development'];
|
|
56
|
+
switch (appCode) {
|
|
57
|
+
case APP_CODES.DATAFLOWS:
|
|
58
|
+
return (_a = APP_PERMISSION_DOMAIN[appCode || '']) === null || _a === void 0 ? void 0 : _a[env || ''];
|
|
59
|
+
default:
|
|
60
|
+
return CDP_API[env || 'development'];
|
|
61
|
+
}
|
|
62
|
+
}, [portalId, env, appCode]);
|
|
50
63
|
if (!env || !language || !userId || !portalId || !token)
|
|
51
64
|
return null;
|
|
52
65
|
const { show: showHelp = true, configs } = helpConfig, helpProps = __rest(helpConfig, ["show", "configs"]);
|
|
53
66
|
const { show: showNotification = true } = notificationConfig;
|
|
54
67
|
const { show: showAccountSharing = true, isShowSharing = true, isShareAccountAccess = true } = accountSharingConfig, accountSharingProps = __rest(accountSharingConfig, ["show", "isShowSharing", "isShareAccountAccess"]);
|
|
55
68
|
const accountSelectionApiConfig = {
|
|
56
|
-
domain:
|
|
69
|
+
domain: accountSelectionDomain,
|
|
57
70
|
languageCode: language,
|
|
58
71
|
userId,
|
|
59
72
|
portalId,
|
|
60
73
|
token,
|
|
74
|
+
appCode,
|
|
61
75
|
};
|
|
62
76
|
const helpConfigProps = Object.assign(Object.assign({}, configs), { portalId: portalId.toString(), userId: userId.toString(), token, domain: CDP_API[env], domainTicket: ISSUE_API[env], domainPlatform: PLATFORM_API, config: Object.assign(Object.assign({}, configs.config), { user_language: language }) });
|
|
63
77
|
const notificationConfigProps = {
|
|
@@ -65,17 +79,17 @@ export const HeaderV2 = memo(props => {
|
|
|
65
79
|
networkId: portalId,
|
|
66
80
|
token,
|
|
67
81
|
lang: language,
|
|
68
|
-
permissionDomain
|
|
82
|
+
permissionDomain,
|
|
69
83
|
socketDomain: SOCKET_API,
|
|
70
84
|
};
|
|
71
85
|
const accountSharingPropsFormatted = {
|
|
72
|
-
permissionDomain
|
|
73
|
-
iamDomain
|
|
86
|
+
permissionDomain,
|
|
87
|
+
iamDomain,
|
|
74
88
|
accountId: userId,
|
|
75
89
|
networkId: portalId,
|
|
76
|
-
urlEditProfile: `${
|
|
90
|
+
urlEditProfile: `${permissionDomain}/${portalId}#/account/profile/`,
|
|
77
91
|
// 6006 is storybook port so direct to sandbox page
|
|
78
|
-
urlLogout:
|
|
92
|
+
urlLogout: window.location.origin,
|
|
79
93
|
token,
|
|
80
94
|
lang: language,
|
|
81
95
|
};
|
|
@@ -40,7 +40,7 @@ export declare const getInputDefaultValue: ({ operator, dataType, property }: {
|
|
|
40
40
|
export declare const validateFilters: (filters: TFilters, validateFirstCondition?: boolean) => any;
|
|
41
41
|
export declare const getScopSuggest: ({ itemTypeId }: {
|
|
42
42
|
itemTypeId: any;
|
|
43
|
-
}) =>
|
|
43
|
+
}) => 1 | 2 | 3;
|
|
44
44
|
export declare const setValueSelectAll: (treeData: any) => any;
|
|
45
45
|
export declare const checkDuplicateArray: (data: any) => any;
|
|
46
46
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Libraries
|
|
2
2
|
import React, { memo, useEffect, useState } from 'react';
|
|
3
3
|
import Icon from '@antscorp/icons';
|
|
4
|
-
import { isEmpty, isNil,
|
|
4
|
+
import { isEmpty, isNil, uniq } from 'lodash';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
import { Link, useLocation } from 'react-router-dom';
|
|
7
7
|
import { useContextSelector } from 'use-context-selector';
|
|
@@ -11,12 +11,13 @@ import { Flex } from '../../../../../atoms';
|
|
|
11
11
|
import { MenuItemImage } from './components';
|
|
12
12
|
// Styled
|
|
13
13
|
import { LabelCustom, MenuWrapper } from './styled';
|
|
14
|
+
import { IconWrapper } from '../../../styled';
|
|
14
15
|
// Constants
|
|
15
16
|
import { ICON_SIZE } from '../../../constants';
|
|
16
17
|
// Contexts
|
|
17
18
|
import { AppConfigContext } from '@antscorp/antsomi-ui/es/providers';
|
|
18
19
|
// Utils
|
|
19
|
-
import { findActiveAppCodeByUrl,
|
|
20
|
+
import { findActiveAppCodeByUrl, findLastMatchedItemByUrl } from '../../../utils';
|
|
20
21
|
import { recursiveFindParentOfActiveItem } from './utils';
|
|
21
22
|
import { random } from '@antscorp/antsomi-ui/es/utils';
|
|
22
23
|
// Hooks
|
|
@@ -40,9 +41,10 @@ export const ChildMenu = memo(props => {
|
|
|
40
41
|
const { isPushDifferentDomain, getPath, navigatePath } = useNavigatePath();
|
|
41
42
|
// Side Effects
|
|
42
43
|
useEffect(() => {
|
|
44
|
+
var _a;
|
|
43
45
|
const url = `${pathname}${hash}${search}`;
|
|
44
46
|
/** Active menu item by current url */
|
|
45
|
-
const activeMenuItem =
|
|
47
|
+
const activeMenuItem = (_a = findLastMatchedItemByUrl({ url, menuItems, auth })) === null || _a === void 0 ? void 0 : _a.menu_item_code;
|
|
46
48
|
if (activeMenuItem && activeMenuItem !== currentActiveItem) {
|
|
47
49
|
setCurrentActiveItem(activeMenuItem);
|
|
48
50
|
/** Find parent key of active menu item to open it */
|
|
@@ -91,8 +93,9 @@ export const ChildMenu = memo(props => {
|
|
|
91
93
|
React.createElement(Icon, { className: "child-menu-item-icon", type: "icon-ants-three-dot-vertical", style: { marginTop: '2px', zIndex: 1000 } })))) : (React.createElement(LabelCustom, { ellipsis: { tooltip: label } }, label));
|
|
92
94
|
return {
|
|
93
95
|
key,
|
|
94
|
-
label:
|
|
95
|
-
icon: !isNil(icon) ? (React.createElement(
|
|
96
|
+
label: !menu_item_path ? (labelComponent()) : isPushDifferentDomain(menu_item_domain, menu_item_path) ? (React.createElement("div", { onClick: () => navigatePath(menu_item_domain, menu_item_path), className: "menu-link" }, labelComponent())) : (React.createElement(Link, { to: getPath(menu_item_domain, menu_item_path), className: "menu-link" }, labelComponent())),
|
|
97
|
+
icon: !isNil(icon) ? (React.createElement(IconWrapper, null,
|
|
98
|
+
React.createElement(Icon, { type: icon }))) : !isNil(logo_url) ? (React.createElement(MenuItemImage, { imageUrl: logo_url, fallbackIcon: (_a = args === null || args === void 0 ? void 0 : args.parent) === null || _a === void 0 ? void 0 : _a.icon, className: classNames({ isActive: currentActiveItem === key }) })) : null,
|
|
96
99
|
children: customMenuItems({ parent: item, items: children }),
|
|
97
100
|
};
|
|
98
101
|
});
|
|
@@ -18,7 +18,6 @@ export const MenuWrapper = styled.div `
|
|
|
18
18
|
height: 100%;
|
|
19
19
|
|
|
20
20
|
li {
|
|
21
|
-
margin: 0 !important;
|
|
22
21
|
width: 100% !important;
|
|
23
22
|
|
|
24
23
|
[role='icon'] {
|
|
@@ -33,6 +32,7 @@ export const MenuWrapper = styled.div `
|
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
[role='menuitem'] {
|
|
35
|
+
margin: 0 !important;
|
|
36
36
|
border-radius: ${(_a = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _a === void 0 ? void 0 : _a.borderRadiusXL}px !important;
|
|
37
37
|
padding-right: 10px !important;
|
|
38
38
|
}
|
|
@@ -26,11 +26,7 @@ export declare const MARKETING_ROUTES: {
|
|
|
26
26
|
};
|
|
27
27
|
export declare const MARKETING_CHANNEL_KEY: {
|
|
28
28
|
readonly ALL_CHANNEL: 0;
|
|
29
|
-
readonly
|
|
30
|
-
};
|
|
31
|
-
export declare const MARKETING_CHANNEL_CODE: {
|
|
32
|
-
readonly ALL_CHANNEL: "ALL_CHANNEL";
|
|
33
|
-
readonly ORCHESTRATION: "ORCHESTRATION";
|
|
29
|
+
readonly JOURNEY_ORCHESTRATION: 8;
|
|
34
30
|
};
|
|
35
31
|
export declare const RENDER_OPTION: {
|
|
36
32
|
readonly CHANNEL: "destination_channel";
|
|
@@ -42,9 +42,5 @@ export const HOME_REPORT_ROUTES = {
|
|
|
42
42
|
export const MARKETING_ROUTES = {
|
|
43
43
|
CHANNEL: '/gen2/:networkId/:user_id/marketing-hub/journeys/:channelId/list',
|
|
44
44
|
};
|
|
45
|
-
export const MARKETING_CHANNEL_KEY = { ALL_CHANNEL: 0,
|
|
46
|
-
export const MARKETING_CHANNEL_CODE = {
|
|
47
|
-
ALL_CHANNEL: 'ALL_CHANNEL',
|
|
48
|
-
ORCHESTRATION: 'ORCHESTRATION',
|
|
49
|
-
};
|
|
45
|
+
export const MARKETING_CHANNEL_KEY = { ALL_CHANNEL: 0, JOURNEY_ORCHESTRATION: 8 };
|
|
50
46
|
export const RENDER_OPTION = { CHANNEL: 'destination_channel' };
|
|
@@ -8,7 +8,7 @@ import { AppConfigContext } from '@antscorp/antsomi-ui/es/providers';
|
|
|
8
8
|
// Queries
|
|
9
9
|
import { useGetDashboard, useGetDestinationChannel, useGetListMenu, useGetListMenuPermission, } from '@antscorp/antsomi-ui/es/queries/LeftMenu';
|
|
10
10
|
// Utils
|
|
11
|
-
import { findActiveAppCodeByUrl,
|
|
11
|
+
import { findActiveAppCodeByUrl, findLastMatchedItemByUrl, findPathOfActiveItem, flattenMenuArray, getMappingAppChildren, recursivePermissionMenu, } from '../utils';
|
|
12
12
|
// Store
|
|
13
13
|
import { useLeftMenuStore } from '../stores';
|
|
14
14
|
import { POST_MESSAGE_TYPES } from '@antscorp/antsomi-ui/es/constants/postMessage';
|
|
@@ -48,10 +48,10 @@ export const useLeftMenu = (props) => {
|
|
|
48
48
|
const { data: menuListPermission } = useGetListMenuPermission({
|
|
49
49
|
args: {
|
|
50
50
|
auth: {
|
|
51
|
-
token: '
|
|
51
|
+
token: '5474r2x214z284d4w2b4y454a4p5x2d4j4n4w2q4a4v5' || (auth === null || auth === void 0 ? void 0 : auth.token),
|
|
52
52
|
url: 'https://permission.antsomi.com',
|
|
53
|
-
userId: '
|
|
54
|
-
accountId: '
|
|
53
|
+
userId: '1600083836' || (auth === null || auth === void 0 ? void 0 : auth.userId),
|
|
54
|
+
accountId: '1600083836' || (auth === null || auth === void 0 ? void 0 : auth.accountId),
|
|
55
55
|
},
|
|
56
56
|
params: {
|
|
57
57
|
type: 'list-app',
|
|
@@ -157,13 +157,20 @@ export const useLeftMenu = (props) => {
|
|
|
157
157
|
* Callback function when url change
|
|
158
158
|
*/
|
|
159
159
|
useEffect(() => {
|
|
160
|
+
var _a;
|
|
160
161
|
const url = `${pathname}${hash}${search}`;
|
|
161
|
-
const matchedCode =
|
|
162
|
+
const matchedCode = (_a = findLastMatchedItemByUrl({
|
|
162
163
|
url,
|
|
163
164
|
menuItems: mappingChildrenMenu,
|
|
164
165
|
auth,
|
|
165
|
-
});
|
|
166
|
-
|
|
166
|
+
})) === null || _a === void 0 ? void 0 : _a.menu_item_code;
|
|
167
|
+
const activeItemPath = matchedCode
|
|
168
|
+
? findPathOfActiveItem({
|
|
169
|
+
activeMenuItem: matchedCode,
|
|
170
|
+
menuItems: mappingChildrenMenu,
|
|
171
|
+
})
|
|
172
|
+
: [];
|
|
173
|
+
onActiveMenuCodeChange === null || onActiveMenuCodeChange === void 0 ? void 0 : onActiveMenuCodeChange(activeItemPath, flattenMenuPermission);
|
|
167
174
|
}, [
|
|
168
175
|
auth,
|
|
169
176
|
flattenMenuPermission,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { TFeatureMenu } from '@antscorp/antsomi-ui/es/models/LeftMenu/FeatureMenu';
|
|
2
3
|
import { FeatureMenuPermission } from '@antscorp/antsomi-ui/es/models/LeftMenu';
|
|
3
4
|
export interface LeftMenuProps {
|
|
4
5
|
objectType?: string;
|
|
@@ -6,6 +7,6 @@ export interface LeftMenuProps {
|
|
|
6
7
|
isGrouped?: boolean;
|
|
7
8
|
style?: React.CSSProperties;
|
|
8
9
|
className?: string;
|
|
9
|
-
onActiveMenuCodeChange?: (
|
|
10
|
+
onActiveMenuCodeChange?: (activeItemPath: TFeatureMenu[], flattenPermissionList?: FeatureMenuPermission[]) => void;
|
|
10
11
|
}
|
|
11
12
|
export declare const LeftMenu: React.FC<LeftMenuProps>;
|
|
@@ -12,3 +12,4 @@ export declare const FeatureMenuItem: import("styled-components").StyledComponen
|
|
|
12
12
|
export declare const ChildMenuWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
13
13
|
isExpand: boolean;
|
|
14
14
|
}, never>;
|
|
15
|
+
export declare const IconWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -4,6 +4,7 @@ import styled from 'styled-components';
|
|
|
4
4
|
// Constants
|
|
5
5
|
import { THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
6
6
|
import { HEADER_HEIGHT } from '../../molecules/HeaderV2/constants';
|
|
7
|
+
import { ICON_SIZE } from './constants';
|
|
7
8
|
// Components
|
|
8
9
|
import { Flex } from '../../atoms';
|
|
9
10
|
export const PopoverWrapper = styled.div `
|
|
@@ -185,3 +186,14 @@ export const ChildMenuWrapper = styled.div `
|
|
|
185
186
|
box-sizing: border-box;
|
|
186
187
|
z-index: 1;
|
|
187
188
|
`;
|
|
189
|
+
export const IconWrapper = styled.div `
|
|
190
|
+
width: 30px;
|
|
191
|
+
height: 30px;
|
|
192
|
+
display: flex;
|
|
193
|
+
justify-content: center;
|
|
194
|
+
align-items: center;
|
|
195
|
+
|
|
196
|
+
i {
|
|
197
|
+
font-size: ${ICON_SIZE};
|
|
198
|
+
}
|
|
199
|
+
`;
|
|
@@ -54,8 +54,12 @@ export declare const findActiveAppCodeByUrl: (args: {
|
|
|
54
54
|
menuItems: TFeatureMenu[];
|
|
55
55
|
auth?: Partial<PayloadInfo>;
|
|
56
56
|
}) => string | undefined;
|
|
57
|
-
export declare const
|
|
57
|
+
export declare const findLastMatchedItemByUrl: (args: {
|
|
58
58
|
url: string;
|
|
59
59
|
menuItems: TFeatureMenu[];
|
|
60
60
|
auth?: Partial<PayloadInfo>;
|
|
61
|
-
}) =>
|
|
61
|
+
}) => TFeatureMenu | undefined;
|
|
62
|
+
export declare const findPathOfActiveItem: (args: {
|
|
63
|
+
activeMenuItem: string;
|
|
64
|
+
menuItems: TFeatureMenu[];
|
|
65
|
+
}) => TFeatureMenu[];
|
|
@@ -13,7 +13,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
13
13
|
import { isArray, isEmpty, sortBy } from 'lodash';
|
|
14
14
|
import { generatePath } from 'react-router-dom';
|
|
15
15
|
// Constants
|
|
16
|
-
import { APP_KEYS, MARKETING_CHANNEL_KEY, HOME_MENU_ITEMS, MARKETING_ROUTES, MENU_ITEM_TYPE,
|
|
16
|
+
import { APP_KEYS, MARKETING_CHANNEL_KEY, HOME_MENU_ITEMS, MARKETING_ROUTES, MENU_ITEM_TYPE, RENDER_OPTION, HOME_REPORT_ROUTES, } from '../constants';
|
|
17
|
+
import { MARKETING_CHANNEL_CODE } from '../../../template/Layout/constants';
|
|
17
18
|
// Utils
|
|
18
19
|
import { handleError } from '@antscorp/antsomi-ui/es/utils';
|
|
19
20
|
const PATH = 'src/components/organism/LeftMenu/utils/index.ts';
|
|
@@ -127,14 +128,14 @@ export const getMappingAppChildren = (args) => {
|
|
|
127
128
|
childMenuItem.menu_item_path = getGeneratePath(MARKETING_ROUTES.CHANNEL, Object.assign(Object.assign({}, auth), { channelId: MARKETING_CHANNEL_KEY.ALL_CHANNEL }));
|
|
128
129
|
break;
|
|
129
130
|
case MARKETING_CHANNEL_CODE.ORCHESTRATION:
|
|
130
|
-
childMenuItem.menu_item_path = getGeneratePath(MARKETING_ROUTES.CHANNEL, Object.assign(Object.assign({}, auth), { channelId: MARKETING_CHANNEL_KEY.
|
|
131
|
+
childMenuItem.menu_item_path = getGeneratePath(MARKETING_ROUTES.CHANNEL, Object.assign(Object.assign({}, auth), { channelId: MARKETING_CHANNEL_KEY.JOURNEY_ORCHESTRATION }));
|
|
131
132
|
break;
|
|
132
133
|
default:
|
|
133
134
|
break;
|
|
134
135
|
}
|
|
135
136
|
if ((childMenuItem === null || childMenuItem === void 0 ? void 0 : childMenuItem.render_option) === RENDER_OPTION.CHANNEL) {
|
|
136
137
|
childMenuItem.children =
|
|
137
|
-
((_a = destinationChannelEntries === null || destinationChannelEntries === void 0 ? void 0 : destinationChannelEntries.filter(item => item.channelId !== MARKETING_CHANNEL_KEY.
|
|
138
|
+
((_a = destinationChannelEntries === null || destinationChannelEntries === void 0 ? void 0 : destinationChannelEntries.filter(item => item.channelId !== MARKETING_CHANNEL_KEY.JOURNEY_ORCHESTRATION)) === null || _a === void 0 ? void 0 : _a.map(item => (Object.assign({}, getInitialFeatureMenuItem({
|
|
138
139
|
menu_item_code: item.channelCode,
|
|
139
140
|
menu_item_name: item.translateLabel,
|
|
140
141
|
logo_url: item.logoUrl,
|
|
@@ -201,14 +202,14 @@ export const findActiveAppCodeByUrl = (args) => {
|
|
|
201
202
|
});
|
|
202
203
|
}
|
|
203
204
|
};
|
|
204
|
-
export const
|
|
205
|
+
export const findLastMatchedItemByUrl = (args) => {
|
|
205
206
|
try {
|
|
206
207
|
const { url, menuItems, auth } = args;
|
|
207
|
-
const
|
|
208
|
+
const matchedItems = [];
|
|
208
209
|
const recursiveFindActiveItem = (items) => {
|
|
209
210
|
for (const item of items) {
|
|
210
211
|
if (!!(item === null || item === void 0 ? void 0 : item.menu_item_path) && url.includes(getGeneratePath(item.menu_item_path, auth))) {
|
|
211
|
-
|
|
212
|
+
matchedItems.push(item);
|
|
212
213
|
}
|
|
213
214
|
if ((item === null || item === void 0 ? void 0 : item.children) && item.children.length) {
|
|
214
215
|
recursiveFindActiveItem(item.children);
|
|
@@ -216,13 +217,42 @@ export const findLastMatchedCodeByUrl = (args) => {
|
|
|
216
217
|
}
|
|
217
218
|
};
|
|
218
219
|
recursiveFindActiveItem(menuItems || []);
|
|
219
|
-
return
|
|
220
|
+
return matchedItems === null || matchedItems === void 0 ? void 0 : matchedItems.pop();
|
|
220
221
|
}
|
|
221
222
|
catch (error) {
|
|
222
223
|
handleError(error, {
|
|
223
224
|
path: PATH,
|
|
224
|
-
name:
|
|
225
|
+
name: findLastMatchedItemByUrl.name,
|
|
225
226
|
args,
|
|
226
227
|
});
|
|
227
228
|
}
|
|
228
229
|
};
|
|
230
|
+
export const findPathOfActiveItem = (args) => {
|
|
231
|
+
try {
|
|
232
|
+
const { activeMenuItem, menuItems } = args;
|
|
233
|
+
const recursiveFindPathOfActiveItem = (menuItems) => {
|
|
234
|
+
let path = [];
|
|
235
|
+
for (const item of menuItems) {
|
|
236
|
+
if (item.menu_item_code === activeMenuItem) {
|
|
237
|
+
path.push(item);
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
const childPath = recursiveFindPathOfActiveItem((item === null || item === void 0 ? void 0 : item.children) || []);
|
|
241
|
+
if (childPath.length) {
|
|
242
|
+
path = [item, ...childPath];
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return path;
|
|
247
|
+
};
|
|
248
|
+
return recursiveFindPathOfActiveItem(menuItems);
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
handleError(error, {
|
|
252
|
+
path: PATH,
|
|
253
|
+
name: findPathOfActiveItem.name,
|
|
254
|
+
args,
|
|
255
|
+
});
|
|
256
|
+
return [];
|
|
257
|
+
}
|
|
258
|
+
};
|
|
@@ -13,7 +13,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
13
13
|
import React, { memo, useCallback, useMemo, useState } from 'react';
|
|
14
14
|
import { useContextSelector } from 'use-context-selector';
|
|
15
15
|
import AntsProcessingNotification from '@antscorp/processing-notification';
|
|
16
|
-
import { merge } from 'lodash';
|
|
16
|
+
import { isEmpty, merge } from 'lodash';
|
|
17
17
|
// Styled
|
|
18
18
|
import { ChildrenWrapper, ContentWrapper, LayoutWrapper, NotificationWrapper } from './styled';
|
|
19
19
|
// Components
|
|
@@ -23,43 +23,106 @@ import { HeaderV2 } from '../../molecules';
|
|
|
23
23
|
// Contexts
|
|
24
24
|
import { AppConfigContext } from '../../..';
|
|
25
25
|
// Constants
|
|
26
|
-
import { PERMISSION_API, SOCKET_API } from '../../../constants';
|
|
26
|
+
import { APP_CODES, APP_IAM_DOMAIN, APP_PERMISSION_DOMAIN, IAM_API, PERMISSION_API, PORTALS_IDS, SOCKET_API, } from '../../../constants';
|
|
27
27
|
// Css
|
|
28
28
|
import '@antscorp/processing-notification/dist/index.css';
|
|
29
29
|
import { useLayoutStore } from './stores';
|
|
30
|
+
// Utils
|
|
30
31
|
import { checkingRoleScope } from './utils';
|
|
32
|
+
import { MENU_PERMISSIONS } from './constants';
|
|
33
|
+
// Types
|
|
34
|
+
const { DATAFLOWS } = APP_CODES;
|
|
31
35
|
export const Layout = memo(props => {
|
|
32
36
|
const { leftMenuProps, headerProps = {}, workspaceProps, processingNotificationProps, children, } = props;
|
|
33
37
|
const _a = leftMenuProps || {}, { className = '' } = _a, restOfLeftMenuProps = __rest(_a, ["className"]);
|
|
34
38
|
const _b = workspaceProps || {}, { workspaceContentProps } = _b, restOfWorkspaceProps = __rest(_b, ["workspaceContentProps"]);
|
|
35
39
|
// Selectors
|
|
36
|
-
const { auth, languageCode } = useContextSelector(AppConfigContext, state => state);
|
|
40
|
+
const { auth, languageCode, appCode, env } = useContextSelector(AppConfigContext, state => state);
|
|
37
41
|
const { token, userId, portalId } = auth || {};
|
|
38
42
|
const headerStore = useLayoutStore(store => store.state.header);
|
|
39
43
|
const [showAccountSelection, setShowAccountSelection] = useState(false);
|
|
40
44
|
// Memo
|
|
45
|
+
const permissionDomain = useMemo(() => {
|
|
46
|
+
var _a;
|
|
47
|
+
/**
|
|
48
|
+
* Check if appCode not exist and portalId is SANDBOX
|
|
49
|
+
* then return production permission api
|
|
50
|
+
*/
|
|
51
|
+
if (!appCode || portalId === PORTALS_IDS.SANDBOX)
|
|
52
|
+
return PERMISSION_API;
|
|
53
|
+
switch (appCode) {
|
|
54
|
+
case DATAFLOWS:
|
|
55
|
+
return ((_a = APP_PERMISSION_DOMAIN[appCode]) === null || _a === void 0 ? void 0 : _a[env || 'development']) || PERMISSION_API;
|
|
56
|
+
default:
|
|
57
|
+
return PERMISSION_API;
|
|
58
|
+
}
|
|
59
|
+
}, [appCode, env, portalId]);
|
|
60
|
+
const iamDomain = useMemo(() => {
|
|
61
|
+
var _a;
|
|
62
|
+
/**
|
|
63
|
+
* Check if appCode not exist and portalId is SANDBOX
|
|
64
|
+
* then return production iam api
|
|
65
|
+
*/
|
|
66
|
+
if (!appCode || portalId === PORTALS_IDS.SANDBOX)
|
|
67
|
+
return IAM_API;
|
|
68
|
+
switch (appCode) {
|
|
69
|
+
case DATAFLOWS:
|
|
70
|
+
return ((_a = APP_IAM_DOMAIN[appCode]) === null || _a === void 0 ? void 0 : _a[env || 'development']) || IAM_API;
|
|
71
|
+
default:
|
|
72
|
+
return IAM_API;
|
|
73
|
+
}
|
|
74
|
+
}, [appCode, env, portalId]);
|
|
41
75
|
const initialHeaderProps = useMemo(() => {
|
|
42
76
|
var _a, _b;
|
|
43
|
-
return (Object.assign(Object.assign({ className: 'layout-header' }, headerProps), {
|
|
77
|
+
return (Object.assign(Object.assign({ className: 'layout-header' }, headerProps), { config: Object.assign(Object.assign({}, headerProps === null || headerProps === void 0 ? void 0 : headerProps.config), { permissionDomain,
|
|
78
|
+
iamDomain }), helpConfig: Object.assign(Object.assign({}, headerProps === null || headerProps === void 0 ? void 0 : headerProps.helpConfig), { configs: Object.assign(Object.assign({}, (_a = headerProps === null || headerProps === void 0 ? void 0 : headerProps.helpConfig) === null || _a === void 0 ? void 0 : _a.configs), { appCode: 'SANDBOX_MARKETING', avatar: '//c0-platform.ants.tech/avatar/2021/09/17/0xgbkurioo.png', config: {
|
|
44
79
|
p_timezone: 'Asia/Singapore',
|
|
45
80
|
api_pid: 33167,
|
|
46
81
|
p_f_longdatetime: "dd MMMM 'at' HH:mm:ss",
|
|
47
82
|
embeddedData: {},
|
|
48
83
|
INSIGHT_U_OGS: 'uogs',
|
|
49
|
-
} }) }), accountSharingConfig: Object.assign(Object.assign({}, headerProps === null || headerProps === void 0 ? void 0 : headerProps.accountSharingConfig), { u_ogs: 'uogs', appCode: 'APP_CUSTOMER_360' }), accountSelection: Object.assign(Object.assign({}, headerProps === null || headerProps === void 0 ? void 0 : headerProps.accountSelection), { show: ((_b = headerProps === null || headerProps === void 0 ? void 0 : headerProps.accountSelection) === null || _b === void 0 ? void 0 : _b.show) && showAccountSelection }) }));
|
|
50
|
-
}, [headerProps, showAccountSelection]);
|
|
84
|
+
} }) }), accountSharingConfig: Object.assign(Object.assign({}, headerProps === null || headerProps === void 0 ? void 0 : headerProps.accountSharingConfig), { u_ogs: 'uogs', appCode: 'APP_CUSTOMER_360' }), accountSelection: Object.assign(Object.assign({}, headerProps === null || headerProps === void 0 ? void 0 : headerProps.accountSelection), { show: !!((_b = headerProps === null || headerProps === void 0 ? void 0 : headerProps.accountSelection) === null || _b === void 0 ? void 0 : _b.show) && showAccountSelection }) }));
|
|
85
|
+
}, [headerProps, permissionDomain, showAccountSelection]);
|
|
51
86
|
const mergeHeaderProps = useMemo(() => merge(initialHeaderProps, headerStore), [initialHeaderProps, headerStore]);
|
|
52
|
-
const antsProcessingNotificationConfig = useMemo(() => (Object.assign({ permissionDomain
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
87
|
+
const antsProcessingNotificationConfig = useMemo(() => (Object.assign({ permissionDomain, socketDomain: SOCKET_API, token, accountId: userId, userId, lang: languageCode, networkId: portalId }, processingNotificationProps)), [permissionDomain, token, userId, languageCode, portalId, processingNotificationProps]);
|
|
88
|
+
const onActiveMenuCodeChange = useCallback((activeItemPath, flattenPermissionList) => {
|
|
89
|
+
if (isEmpty(activeItemPath)) {
|
|
90
|
+
setShowAccountSelection(false);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
let roleScope = false;
|
|
94
|
+
for (const activeItem of activeItemPath) {
|
|
95
|
+
let permissionCode;
|
|
96
|
+
/** Dùng để check xem Permission Code có được lấy từ @constant MENU_PERMISSIONS hay không */
|
|
97
|
+
let isExternalPermissionCode = false;
|
|
98
|
+
/**
|
|
99
|
+
* Kiểm tra nếu MENU_CODE có trong @constant MENU_PERMISSIONS thì lấy Permission từ constant
|
|
100
|
+
* Không thì lấy từ api Permission
|
|
101
|
+
* Nếu ở cả 2 nơi đều không có permission thì không hiện account selection
|
|
102
|
+
*/
|
|
103
|
+
if (Object.keys(MENU_PERMISSIONS).includes(activeItem.menu_item_code)) {
|
|
104
|
+
permissionCode = MENU_PERMISSIONS[activeItem.menu_item_code];
|
|
105
|
+
isExternalPermissionCode = true;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
permissionCode = activeItem.permission_code;
|
|
109
|
+
}
|
|
110
|
+
const menuPermission = flattenPermissionList === null || flattenPermissionList === void 0 ? void 0 : flattenPermissionList.find(item => permissionCode === item.menu_code);
|
|
111
|
+
if (menuPermission) {
|
|
112
|
+
const checkRoleScope = menuPermission
|
|
113
|
+
? checkingRoleScope({ menuCode: activeItem.menu_item_code, menuPermission })
|
|
114
|
+
: false;
|
|
115
|
+
if (checkRoleScope) {
|
|
116
|
+
roleScope = true;
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/** Nếu trong Api Permission không có những có trong @constant MENU_PERMISSIONS thì vẫn trả về True vì có những MENU_CODE mà BA chưa define permission */
|
|
121
|
+
if (isExternalPermissionCode) {
|
|
122
|
+
roleScope = true;
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
63
126
|
setShowAccountSelection(roleScope);
|
|
64
127
|
}, []);
|
|
65
128
|
return (React.createElement(LayoutWrapper, null,
|
|
@@ -4,3 +4,17 @@ export declare const APP_ROLE_SCOPE: {
|
|
|
4
4
|
MANAGEMENT_BY_USER: number;
|
|
5
5
|
EVERYTHING: number;
|
|
6
6
|
};
|
|
7
|
+
export declare const MARKETING_CHANNEL_CODE: {
|
|
8
|
+
readonly ALL_CHANNEL: "ALL_CHANNEL";
|
|
9
|
+
readonly ORCHESTRATION: "ORCHESTRATION";
|
|
10
|
+
readonly CAMPAIGN: "CAMPAIGN";
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Check permissions for showing account selection
|
|
14
|
+
* Nếu PERMISSION_CODE không được tìm thấy trong api get permissions và trong @constant MENU_PERMISSIONS thì sẽ ẩn account selection
|
|
15
|
+
*/
|
|
16
|
+
export declare const MENU_PERMISSIONS: {
|
|
17
|
+
ALL_CHANNEL: string;
|
|
18
|
+
ORCHESTRATION: string;
|
|
19
|
+
CAMPAIGN: string;
|
|
20
|
+
};
|
|
@@ -4,3 +4,17 @@ export const APP_ROLE_SCOPE = {
|
|
|
4
4
|
MANAGEMENT_BY_USER: 3,
|
|
5
5
|
EVERYTHING: 4,
|
|
6
6
|
};
|
|
7
|
+
export const MARKETING_CHANNEL_CODE = {
|
|
8
|
+
ALL_CHANNEL: 'ALL_CHANNEL',
|
|
9
|
+
ORCHESTRATION: 'ORCHESTRATION',
|
|
10
|
+
CAMPAIGN: 'CAMPAIGN',
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Check permissions for showing account selection
|
|
14
|
+
* Nếu PERMISSION_CODE không được tìm thấy trong api get permissions và trong @constant MENU_PERMISSIONS thì sẽ ẩn account selection
|
|
15
|
+
*/
|
|
16
|
+
export const MENU_PERMISSIONS = {
|
|
17
|
+
[MARKETING_CHANNEL_CODE.ALL_CHANNEL]: 'JOURNEY',
|
|
18
|
+
[MARKETING_CHANNEL_CODE.ORCHESTRATION]: 'JOURNEY',
|
|
19
|
+
[MARKETING_CHANNEL_CODE.CAMPAIGN]: 'JOURNEY',
|
|
20
|
+
};
|
|
@@ -64,8 +64,10 @@ export const TemplateListing = memo(props => {
|
|
|
64
64
|
onCancel === null || onCancel === void 0 ? void 0 : onCancel(e);
|
|
65
65
|
setOpenPreviewModal(false);
|
|
66
66
|
};
|
|
67
|
-
return (
|
|
68
|
-
|
|
67
|
+
return (
|
|
68
|
+
/** The className "template-listing-wrapper" is used to detect dom in useListingItemResize hook */
|
|
69
|
+
React.createElement(AntdConfigProviderV2, null,
|
|
70
|
+
React.createElement(TemplateListingWrapper, { className: "template-listing-wrapper" },
|
|
69
71
|
React.createElement(CategoryListing, Object.assign({}, categoryListingProps, { emptyProps: emptyProps })),
|
|
70
72
|
React.createElement(TemplateWrapper, { className: wrapperClassName, style: wrapperStyle },
|
|
71
73
|
header,
|
package/es/constants/api.d.ts
CHANGED
|
@@ -13,3 +13,17 @@ export declare const PLATFORM_API = "https://platform.ants.tech";
|
|
|
13
13
|
export declare const PERMISSION_API = "https://permission.antsomi.com";
|
|
14
14
|
export declare const SOCKET_API = "https://ws.ants.tech";
|
|
15
15
|
export declare const IAM_API = "https://iam.ants.tech";
|
|
16
|
+
export declare const APP_PERMISSION_DOMAIN: {
|
|
17
|
+
[x: string]: {
|
|
18
|
+
development: string;
|
|
19
|
+
sandbox: string;
|
|
20
|
+
production: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export declare const APP_IAM_DOMAIN: {
|
|
24
|
+
[x: string]: {
|
|
25
|
+
development: string;
|
|
26
|
+
sandbox: string;
|
|
27
|
+
production: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
package/es/constants/api.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// Constants
|
|
2
2
|
import { ENV } from '../config';
|
|
3
|
+
import { APP_CODES } from './variables';
|
|
4
|
+
const { DATAFLOWS } = APP_CODES;
|
|
3
5
|
export const TINYMCE_API_KEY = 'scyw71pj8619analvxs56ppc2w2fj2kpy5vnmflhhc300y35';
|
|
4
6
|
export const CDP_API = {
|
|
5
7
|
[ENV.DEV]: 'https://sandbox-app.cdp.asia',
|
|
@@ -15,3 +17,17 @@ export const PLATFORM_API = 'https://platform.ants.tech';
|
|
|
15
17
|
export const PERMISSION_API = 'https://permission.antsomi.com';
|
|
16
18
|
export const SOCKET_API = 'https://ws.ants.tech';
|
|
17
19
|
export const IAM_API = 'https://iam.ants.tech';
|
|
20
|
+
export const APP_PERMISSION_DOMAIN = {
|
|
21
|
+
[DATAFLOWS]: {
|
|
22
|
+
[ENV.DEV]: 'https://sandbox-permission.ants.vn',
|
|
23
|
+
[ENV.SANDBOX]: 'https://sandbox-permission.ants.vn',
|
|
24
|
+
[ENV.PROD]: 'https://permission.antsomi.com',
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
export const APP_IAM_DOMAIN = {
|
|
28
|
+
[DATAFLOWS]: {
|
|
29
|
+
[ENV.DEV]: 'https://sandbox-aacm.ants.vn',
|
|
30
|
+
[ENV.SANDBOX]: 'https://sandbox-aacm.ants.vn',
|
|
31
|
+
[ENV.PROD]: 'https://iam.ants.tech',
|
|
32
|
+
},
|
|
33
|
+
};
|
package/es/constants/queries.js
CHANGED
|
@@ -34,5 +34,6 @@ export const QUERY_KEYS = {
|
|
|
34
34
|
GET_DESTINATION_CHANNEL: 'GET_DESTINATION_CHANNEL',
|
|
35
35
|
// Account Listing
|
|
36
36
|
GET_ACCOUNT_LISTING: 'GET_ACCOUNT_LISTING',
|
|
37
|
+
GET_PERMISSION_ACCOUNT_LISTING: 'GET_PERMISSION_ACCOUNT_LISTING',
|
|
37
38
|
GET_RECENT_ACCOUNT: 'GET_RECENT_ACCOUNT',
|
|
38
39
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { UseQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
import { TGetAccountList } from '../../services/Permission';
|
|
3
|
+
interface GetAccountListProps {
|
|
4
|
+
args: TGetAccountList;
|
|
5
|
+
options?: UseQueryOptions<any, any, any[], any[]>;
|
|
6
|
+
}
|
|
7
|
+
export declare const useGetPermissionAccountList: (props: GetAccountListProps) => import("@tanstack/react-query").UseQueryResult<any[], any>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import { useQuery } from '@tanstack/react-query';
|
|
3
|
+
// Services
|
|
4
|
+
import { permissionService } from '../../services/Permission';
|
|
5
|
+
// Constants
|
|
6
|
+
import { QUERY_KEYS } from '../../constants';
|
|
7
|
+
export const useGetPermissionAccountList = (props) => {
|
|
8
|
+
const { args, options } = props;
|
|
9
|
+
return useQuery(Object.assign({ queryKey: [QUERY_KEYS.GET_PERMISSION_ACCOUNT_LISTING], queryFn: () => permissionService.getAccountList(args) }, options));
|
|
10
|
+
};
|
package/es/queries/index.d.ts
CHANGED
package/es/queries/index.js
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type TGetAccountList = {
|
|
2
|
+
domain: string;
|
|
3
|
+
appCode: string;
|
|
4
|
+
menuCode: string;
|
|
5
|
+
fullParent: boolean;
|
|
6
|
+
_user_id: number;
|
|
7
|
+
_account_id: number;
|
|
8
|
+
_token: string;
|
|
9
|
+
_app_code: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const permissionService: {
|
|
12
|
+
getAccountList: (config: TGetAccountList) => Promise<any>;
|
|
13
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
+
var t = {};
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
+
t[p[i]] = s[p[i]];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
import axios from 'axios';
|
|
22
|
+
import { get } from 'lodash';
|
|
23
|
+
const permissionPath = '/api/permission/index';
|
|
24
|
+
export const permissionService = {
|
|
25
|
+
getAccountList: (config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
try {
|
|
27
|
+
const { domain } = config, restOfConfig = __rest(config, ["domain"]);
|
|
28
|
+
const response = yield axios({
|
|
29
|
+
method: 'GET',
|
|
30
|
+
url: `${domain}${permissionPath}`,
|
|
31
|
+
params: Object.assign({ type: 'list-account' }, restOfConfig),
|
|
32
|
+
});
|
|
33
|
+
return get(response, 'data.data.listAccountId', []);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
return Promise.reject(error);
|
|
37
|
+
}
|
|
38
|
+
}),
|
|
39
|
+
};
|