@antscorp/antsomi-ui 1.3.5-beta.295 → 1.3.5-beta.296
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/AccountListing.d.ts +2 -1
- package/es/components/molecules/AccountSelection/AccountListing.js +5 -45
- package/es/components/molecules/AccountSelection/AccountSelection.js +4 -39
- package/es/components/molecules/AccountSelection/hooks/index.d.ts +1 -0
- package/es/components/molecules/AccountSelection/hooks/index.js +1 -0
- package/es/components/molecules/AccountSelection/hooks/useAccountSelection.d.ts +20 -0
- package/es/components/molecules/AccountSelection/hooks/useAccountSelection.js +49 -0
- package/es/components/molecules/AccountSelection/index.d.ts +1 -0
- package/es/components/molecules/AccountSelection/index.js +1 -0
- package/es/components/molecules/index.d.ts +1 -1
- package/es/components/molecules/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { AccountRecent } from '@antscorp/antsomi-ui/es/models/AccountListing';
|
|
2
3
|
export interface AccountListingProps {
|
|
3
4
|
className?: string;
|
|
4
5
|
apiConfig: {
|
|
@@ -22,7 +23,7 @@ interface AccountData {
|
|
|
22
23
|
}
|
|
23
24
|
export interface AccountListingHandle {
|
|
24
25
|
getUsers: () => {
|
|
25
|
-
recentData
|
|
26
|
+
recentData?: AccountRecent;
|
|
26
27
|
accountData: Array<AccountData>;
|
|
27
28
|
};
|
|
28
29
|
}
|
|
@@ -1,59 +1,19 @@
|
|
|
1
1
|
import Icon from '@antscorp/icons';
|
|
2
|
-
import React, { useCallback, useImperativeHandle,
|
|
3
|
-
import { Divider, Input } from 'antd';
|
|
2
|
+
import React, { useCallback, useImperativeHandle, useState } from 'react';
|
|
4
3
|
import { Scrollbars, Text } from '@antscorp/antsomi-ui/es/components/atoms';
|
|
4
|
+
import { Divider, Input } from 'antd';
|
|
5
5
|
import { AccountItem } from './components';
|
|
6
6
|
import { AccountSelectionStyled } from './styled';
|
|
7
|
-
import {
|
|
7
|
+
import { THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
8
8
|
import { searchStringQuery } from '@antscorp/antsomi-ui/es/utils';
|
|
9
|
-
import {
|
|
9
|
+
import { useAccountSelection } from './hooks';
|
|
10
10
|
export const AccountListing = React.forwardRef((props, ref) => {
|
|
11
11
|
var _a, _b, _c;
|
|
12
12
|
const { className, apiConfig, showAllAccount = true, currentAccount = '', onChange } = props;
|
|
13
|
-
const { domain, token, userId, appCode, menuCode, portalId } = apiConfig;
|
|
14
13
|
// States
|
|
15
14
|
const [searchValue, setSearchValue] = useState('');
|
|
16
|
-
|
|
17
|
-
const { data } = useGetAccountList({
|
|
18
|
-
apiConfig,
|
|
19
|
-
options: {
|
|
20
|
-
enabled: portalId !== PORTALS_IDS.SANDBOX_76753,
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
const { data: permissionAccountList } = useGetPermissionAccountList({
|
|
24
|
-
args: {
|
|
25
|
-
_account_id: userId,
|
|
26
|
-
_user_id: userId,
|
|
27
|
-
_app_code: appCode || '',
|
|
28
|
-
_token: token,
|
|
29
|
-
domain,
|
|
30
|
-
appCode: appCode || '',
|
|
31
|
-
fullParent: true,
|
|
32
|
-
menuCode: menuCode || appCode || '',
|
|
33
|
-
},
|
|
34
|
-
options: {
|
|
35
|
-
enabled: portalId === PORTALS_IDS.SANDBOX_76753,
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
const { data: recentData } = useGetRecentAccount({
|
|
39
|
-
apiConfig,
|
|
40
|
-
options: {
|
|
41
|
-
enabled: portalId !== PORTALS_IDS.SANDBOX_76753,
|
|
42
|
-
},
|
|
43
|
-
});
|
|
15
|
+
const { accountData, recentData } = useAccountSelection(apiConfig);
|
|
44
16
|
const isAllAccount = currentAccount === 'all';
|
|
45
|
-
// Memos
|
|
46
|
-
const accountData = useMemo(() => {
|
|
47
|
-
if (portalId === PORTALS_IDS.SANDBOX_76753) {
|
|
48
|
-
return ((permissionAccountList === null || permissionAccountList === void 0 ? void 0 : permissionAccountList.map(account => ({
|
|
49
|
-
email: account.email,
|
|
50
|
-
userId: account.user_id,
|
|
51
|
-
userName: account.full_name,
|
|
52
|
-
status: 1,
|
|
53
|
-
}))) || []);
|
|
54
|
-
}
|
|
55
|
-
return (data === null || data === void 0 ? void 0 : data.entries) || [];
|
|
56
|
-
}, [data === null || data === void 0 ? void 0 : data.entries, permissionAccountList, portalId]);
|
|
57
17
|
useImperativeHandle(ref, () => ({
|
|
58
18
|
getUsers() {
|
|
59
19
|
return { recentData, accountData };
|
|
@@ -11,57 +11,22 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
// Libraries
|
|
13
13
|
import Icon from '@antscorp/icons';
|
|
14
|
-
import React, { useCallback, useEffect,
|
|
14
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
15
15
|
// Styled
|
|
16
16
|
import { PopoverFieldStyled } from './styled';
|
|
17
17
|
// Components
|
|
18
|
-
import { Tooltip } from 'antd';
|
|
19
18
|
import { Popover } from '@antscorp/antsomi-ui/es/components/atoms';
|
|
19
|
+
import { Tooltip } from 'antd';
|
|
20
20
|
import { AccountListing } from './AccountListing';
|
|
21
|
-
import { useGetAccountList, useGetPermissionAccountList } from '../../..';
|
|
22
21
|
// Constants
|
|
23
|
-
import {
|
|
22
|
+
import { useAccountSelection } from './hooks';
|
|
24
23
|
export const AccountSelection = props => {
|
|
25
24
|
const { show = true, inputStyle = 'input', inputClassName, onChange, getPopupContainer, zIndex } = props, accountListingProps = __rest(props, ["show", "inputStyle", "inputClassName", "onChange", "getPopupContainer", "zIndex"]);
|
|
26
25
|
const { apiConfig, currentAccount = '' } = props;
|
|
27
|
-
const { domain, token, userId, appCode, portalId } = apiConfig;
|
|
28
26
|
// States
|
|
29
27
|
const [inputLabel, setInputLabel] = useState('');
|
|
30
28
|
const [open, setOpen] = useState(false);
|
|
31
|
-
|
|
32
|
-
const { data } = useGetAccountList({
|
|
33
|
-
apiConfig,
|
|
34
|
-
options: {
|
|
35
|
-
enabled: portalId !== PORTALS_IDS.SANDBOX_76753,
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
const { data: permissionAccountList } = useGetPermissionAccountList({
|
|
39
|
-
args: {
|
|
40
|
-
_account_id: userId,
|
|
41
|
-
_user_id: userId,
|
|
42
|
-
_app_code: appCode || '',
|
|
43
|
-
_token: token,
|
|
44
|
-
domain,
|
|
45
|
-
appCode: appCode || '',
|
|
46
|
-
fullParent: true,
|
|
47
|
-
menuCode: appCode || '',
|
|
48
|
-
},
|
|
49
|
-
options: {
|
|
50
|
-
enabled: portalId === PORTALS_IDS.SANDBOX_76753,
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
// Memos
|
|
54
|
-
const accountData = useMemo(() => {
|
|
55
|
-
if (portalId === PORTALS_IDS.SANDBOX_76753) {
|
|
56
|
-
return ((permissionAccountList === null || permissionAccountList === void 0 ? void 0 : permissionAccountList.map(account => ({
|
|
57
|
-
email: account.email,
|
|
58
|
-
userId: account.user_id,
|
|
59
|
-
userName: account.full_name,
|
|
60
|
-
status: 1,
|
|
61
|
-
}))) || []);
|
|
62
|
-
}
|
|
63
|
-
return (data === null || data === void 0 ? void 0 : data.entries) || [];
|
|
64
|
-
}, [data === null || data === void 0 ? void 0 : data.entries, permissionAccountList, portalId]);
|
|
29
|
+
const { accountData } = useAccountSelection(apiConfig);
|
|
65
30
|
// Side Effects
|
|
66
31
|
useEffect(() => {
|
|
67
32
|
var _a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useAccountSelection } from './useAccountSelection';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useAccountSelection } from './useAccountSelection';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AccountRecent } from '@antscorp/antsomi-ui/es/models/AccountListing';
|
|
2
|
+
interface AccountData {
|
|
3
|
+
email: any;
|
|
4
|
+
userId: any;
|
|
5
|
+
userName: any;
|
|
6
|
+
status: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const useAccountSelection: (apiConfig: {
|
|
9
|
+
domain: string;
|
|
10
|
+
token: string;
|
|
11
|
+
userId: number;
|
|
12
|
+
portalId?: number;
|
|
13
|
+
languageCode?: string;
|
|
14
|
+
appCode?: string;
|
|
15
|
+
menuCode?: string;
|
|
16
|
+
}) => {
|
|
17
|
+
recentData?: AccountRecent | undefined;
|
|
18
|
+
accountData: Array<AccountData>;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
// Queries
|
|
4
|
+
import { useGetAccountList, useGetPermissionAccountList, useGetRecentAccount, } from '@antscorp/antsomi-ui/es/queries';
|
|
5
|
+
// Constant
|
|
6
|
+
import { PORTALS_IDS } from '@antscorp/antsomi-ui/es/constants';
|
|
7
|
+
export const useAccountSelection = (apiConfig) => {
|
|
8
|
+
const { domain, token, userId, appCode, menuCode, portalId } = apiConfig;
|
|
9
|
+
const { data } = useGetAccountList({
|
|
10
|
+
apiConfig,
|
|
11
|
+
options: {
|
|
12
|
+
enabled: portalId !== PORTALS_IDS.SANDBOX_76753,
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
const { data: permissionAccountList } = useGetPermissionAccountList({
|
|
16
|
+
args: {
|
|
17
|
+
_account_id: userId,
|
|
18
|
+
_user_id: userId,
|
|
19
|
+
_app_code: appCode || '',
|
|
20
|
+
_token: token,
|
|
21
|
+
domain,
|
|
22
|
+
appCode: appCode || '',
|
|
23
|
+
fullParent: true,
|
|
24
|
+
menuCode: menuCode || appCode || '',
|
|
25
|
+
},
|
|
26
|
+
options: {
|
|
27
|
+
enabled: portalId === PORTALS_IDS.SANDBOX_76753,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const { data: recentData } = useGetRecentAccount({
|
|
31
|
+
apiConfig,
|
|
32
|
+
options: {
|
|
33
|
+
enabled: portalId !== PORTALS_IDS.SANDBOX_76753,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
// Memos
|
|
37
|
+
const accountData = useMemo(() => {
|
|
38
|
+
if (portalId === PORTALS_IDS.SANDBOX_76753) {
|
|
39
|
+
return ((permissionAccountList === null || permissionAccountList === void 0 ? void 0 : permissionAccountList.map(account => ({
|
|
40
|
+
email: account.email,
|
|
41
|
+
userId: account.user_id,
|
|
42
|
+
userName: account.full_name,
|
|
43
|
+
status: 1,
|
|
44
|
+
}))) || []);
|
|
45
|
+
}
|
|
46
|
+
return (data === null || data === void 0 ? void 0 : data.entries) || [];
|
|
47
|
+
}, [data === null || data === void 0 ? void 0 : data.entries, permissionAccountList, portalId]);
|
|
48
|
+
return { recentData, accountData };
|
|
49
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AccountSelection, AccountListing } from './AccountSelection';
|
|
1
|
+
export { AccountSelection, AccountListing, useAccountSelection } from './AccountSelection';
|
|
2
2
|
export { Cascader } from './Cascader';
|
|
3
3
|
export { Dropdown } from './Dropdown';
|
|
4
4
|
export { Modal } from './Modal';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AccountSelection, AccountListing } from './AccountSelection';
|
|
1
|
+
export { AccountSelection, AccountListing, useAccountSelection } from './AccountSelection';
|
|
2
2
|
export { Cascader } from './Cascader';
|
|
3
3
|
export { Dropdown } from './Dropdown';
|
|
4
4
|
export { Modal } from './Modal';
|