@antscorp/antsomi-ui 1.3.5-beta.352 → 1.3.5-beta.353
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/EditorTab/EditorTab.d.ts +4 -1
- package/es/components/molecules/EditorTab/EditorTab.js +51 -68
- package/es/components/molecules/EditorTab/styled.js +10 -3
- package/es/components/molecules/SelectAccount/AccountChip.d.ts +13 -0
- package/es/components/molecules/SelectAccount/AccountChip.js +31 -0
- package/es/components/molecules/SelectAccount/AccountList.d.ts +4 -0
- package/es/components/molecules/SelectAccount/AccountList.js +47 -0
- package/es/components/molecules/SelectAccount/ButtonAdd.d.ts +3 -0
- package/es/components/molecules/SelectAccount/ButtonAdd.js +29 -0
- package/es/components/molecules/SelectAccount/ButtonViewAll.d.ts +3 -0
- package/es/components/molecules/SelectAccount/ButtonViewAll.js +37 -0
- package/es/components/molecules/SelectAccount/Content.d.ts +2 -0
- package/es/components/molecules/SelectAccount/Content.js +40 -0
- package/es/components/molecules/SelectAccount/context/SelectAccountContext.d.ts +4 -0
- package/es/components/molecules/SelectAccount/context/SelectAccountContext.js +51 -0
- package/es/components/molecules/SelectAccount/context/index.d.ts +1 -0
- package/es/components/molecules/SelectAccount/context/index.js +1 -0
- package/es/components/molecules/SelectAccount/context/reducer.d.ts +3 -0
- package/es/components/molecules/SelectAccount/context/reducer.js +95 -0
- package/es/components/molecules/SelectAccount/hook/index.d.ts +1 -0
- package/es/components/molecules/SelectAccount/hook/index.js +1 -0
- package/es/components/molecules/SelectAccount/hook/useGetAbstractUsers.d.ts +11 -0
- package/es/components/molecules/SelectAccount/hook/useGetAbstractUsers.js +9 -0
- package/es/components/molecules/SelectAccount/index.d.ts +4 -0
- package/es/components/molecules/SelectAccount/index.js +21 -0
- package/es/components/molecules/SelectAccount/styled.d.ts +23 -0
- package/es/components/molecules/SelectAccount/styled.js +164 -0
- package/es/components/molecules/SelectAccount/type.d.ts +79 -0
- package/es/components/molecules/SelectAccount/type.js +1 -0
- package/es/components/molecules/index.d.ts +1 -0
- package/es/components/molecules/index.js +1 -0
- package/es/constants/queries.d.ts +1 -0
- package/es/constants/queries.js +2 -0
- package/es/constants/variables.d.ts +3 -0
- package/es/constants/variables.js +4 -0
- package/es/providers/ConfigProvider/GlobalStyle.js +20 -6
- package/es/services/Abstract/index.d.ts +15 -0
- package/es/services/Abstract/index.js +45 -0
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ModalFuncProps } from 'antd';
|
|
2
3
|
interface EditorTabItem {
|
|
3
4
|
showIcon?: boolean;
|
|
4
5
|
showDropdown?: boolean;
|
|
@@ -14,13 +15,15 @@ interface EditorTabProps {
|
|
|
14
15
|
showArrow?: boolean;
|
|
15
16
|
showDropdown?: boolean;
|
|
16
17
|
editNameOnConfigure?: boolean;
|
|
18
|
+
newTabText?: string;
|
|
17
19
|
showComposeNewQuery?: boolean;
|
|
18
20
|
className?: string;
|
|
19
21
|
leftBlockClassName?: string;
|
|
20
22
|
tabItemClassName?: string;
|
|
21
23
|
listTab?: EditorTabItem[];
|
|
22
24
|
activeId?: string;
|
|
23
|
-
|
|
25
|
+
confirmOnRemoveTab?: boolean;
|
|
26
|
+
modalFuncProps?: ModalFuncProps;
|
|
24
27
|
onActiveTab: (id: string) => void;
|
|
25
28
|
onCloseTab: (tab: EditorTabItem, index: number, newTabs: EditorTabItem[]) => void;
|
|
26
29
|
onConfigure: (id: string) => void;
|
|
@@ -1,9 +1,18 @@
|
|
|
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
|
// Lib
|
|
2
|
-
import React, {
|
|
11
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
12
|
import classnames from 'classnames';
|
|
4
13
|
// Components
|
|
5
14
|
import Icon from '@antscorp/icons/main';
|
|
6
|
-
import { Button, Typography, Dropdown, ContentEditable } from '@antscorp/antsomi-ui/es/components';
|
|
15
|
+
import { Button, Typography, Dropdown, ContentEditable, Modal, } from '@antscorp/antsomi-ui/es/components';
|
|
7
16
|
// Styles
|
|
8
17
|
import { EditorTabStyled } from './styled';
|
|
9
18
|
// Utils
|
|
@@ -11,15 +20,15 @@ import { handleError } from '@antscorp/antsomi-ui/es/utils';
|
|
|
11
20
|
const PATH = 'src/components/EditorTab/index.jsx';
|
|
12
21
|
export const EditorTab = props => {
|
|
13
22
|
var _a;
|
|
14
|
-
const { listTab = [], activeId = '',
|
|
23
|
+
const { listTab = [], activeId = '', showArrow, showDropdown, editNameOnConfigure,
|
|
15
24
|
// disabledScroll,
|
|
16
|
-
onCloseTab, onActiveTab, onAddTab, onConfigure, onSaveName, showComposeNewQuery, className, leftBlockClassName, tabItemClassName, } = props;
|
|
17
|
-
const [activeTabId, setActiveTabId] = useState(
|
|
25
|
+
onCloseTab, onActiveTab, onAddTab, onConfigure, onSaveName, newTabText, showComposeNewQuery, className, leftBlockClassName, tabItemClassName, confirmOnRemoveTab = true, modalFuncProps, } = props;
|
|
26
|
+
const [activeTabId, setActiveTabId] = useState(activeId || ((_a = listTab === null || listTab === void 0 ? void 0 : listTab[0]) === null || _a === void 0 ? void 0 : _a.id));
|
|
18
27
|
const [arrTabs, setArrTabs] = useState(listTab || []);
|
|
19
28
|
const [isEditable, setIsEditable] = useState();
|
|
29
|
+
const [modal, contextModal] = Modal.useModal();
|
|
20
30
|
// Ref
|
|
21
31
|
const leftBlockRef = useRef(null);
|
|
22
|
-
const activeTabIdx = useMemo(() => arrTabs.findIndex(tab => tab.id === activeId), [activeId, arrTabs]);
|
|
23
32
|
useEffect(() => {
|
|
24
33
|
if (listTab.length - arrTabs.length === 1) {
|
|
25
34
|
setActiveTabId(listTab[listTab.length - 1].id);
|
|
@@ -27,58 +36,46 @@ export const EditorTab = props => {
|
|
|
27
36
|
setArrTabs(listTab);
|
|
28
37
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
38
|
}, [listTab]);
|
|
30
|
-
// useEffect(() => {
|
|
31
|
-
// if (onActiveTab) onActiveTab(activeTabId);
|
|
32
|
-
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
-
// }, [activeTabId]);
|
|
34
39
|
useEffect(() => {
|
|
35
|
-
|
|
40
|
+
var _a;
|
|
41
|
+
const tabEl = (_a = leftBlockRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('.tab-item.active');
|
|
36
42
|
if (tabEl) {
|
|
37
|
-
tabEl.scrollIntoView({ block: '
|
|
43
|
+
tabEl.scrollIntoView({ block: 'nearest', inline: 'center', behavior: 'smooth' });
|
|
38
44
|
}
|
|
39
45
|
}, [activeTabId]);
|
|
40
46
|
useEffect(() => {
|
|
41
|
-
// if (activeId && activeTabId !== activeId) {
|
|
42
|
-
// setActiveTabId(activeId);
|
|
43
|
-
// }
|
|
44
47
|
setActiveTabId(prev => (activeId && prev !== activeId ? activeId : prev));
|
|
45
48
|
}, [activeId]);
|
|
46
49
|
const handleAddNew = () => {
|
|
47
50
|
onAddTab();
|
|
48
51
|
};
|
|
49
|
-
const
|
|
52
|
+
const modalConfirmAsync = useCallback(() => modal.confirm(Object.assign({ title: 'Remove this tab', content: 'Removing this tab will delete it permanently. Are you sure you want to perform this action?', okText: 'Confirm', icon: React.createElement("span", { style: { display: 'none' } }), className: 'editor-tab__modal-confirm' }, modalFuncProps)), [modalFuncProps, modal]);
|
|
53
|
+
const handleActiveTab = useCallback((tabId) => {
|
|
54
|
+
setActiveTabId(tabId);
|
|
55
|
+
if (onActiveTab)
|
|
56
|
+
onActiveTab(tabId);
|
|
57
|
+
}, [onActiveTab]);
|
|
58
|
+
const handleCloseTab = (e, tab, idx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
59
|
e.stopPropagation();
|
|
51
60
|
if (arrTabs.length < 2) {
|
|
52
61
|
return;
|
|
53
62
|
}
|
|
63
|
+
const isConfirm = confirmOnRemoveTab ? yield modalConfirmAsync() : true;
|
|
64
|
+
if (!isConfirm)
|
|
65
|
+
return;
|
|
54
66
|
if (activeTabId === tab.id) {
|
|
55
67
|
if (idx === arrTabs.length - 1) {
|
|
56
|
-
|
|
57
|
-
if (onActiveTab)
|
|
58
|
-
onActiveTab(arrTabs[idx - 1].id);
|
|
68
|
+
handleActiveTab(arrTabs[idx - 1].id);
|
|
59
69
|
}
|
|
60
70
|
else if (arrTabs.length > 1) {
|
|
61
|
-
|
|
62
|
-
if (onActiveTab)
|
|
63
|
-
onActiveTab(arrTabs[idx - 1].id);
|
|
71
|
+
handleActiveTab(arrTabs[idx + 1].id);
|
|
64
72
|
}
|
|
65
73
|
}
|
|
66
|
-
const newTabs =
|
|
67
|
-
newTabs.splice(idx, 1);
|
|
74
|
+
const newTabs = arrTabs.filter(item => item.id !== tab.id);
|
|
68
75
|
onCloseTab(tab, idx, newTabs);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// onCloseTab(tab, idx, newTabs);
|
|
73
|
-
// return newTabs;
|
|
74
|
-
// });
|
|
75
|
-
};
|
|
76
|
-
const handleActiveTab = tab => {
|
|
77
|
-
setActiveTabId(tab.id);
|
|
78
|
-
if (onActiveTab)
|
|
79
|
-
onActiveTab(tab.id);
|
|
80
|
-
};
|
|
81
|
-
const onWheelLeftBlock = event => {
|
|
76
|
+
setArrTabs(newTabs);
|
|
77
|
+
});
|
|
78
|
+
const onWheelLeftBlock = useCallback(event => {
|
|
82
79
|
try {
|
|
83
80
|
if (!event.deltaY) {
|
|
84
81
|
return;
|
|
@@ -92,42 +89,33 @@ export const EditorTab = props => {
|
|
|
92
89
|
args: {},
|
|
93
90
|
});
|
|
94
91
|
}
|
|
95
|
-
};
|
|
96
|
-
const onClickArrow = (direction = 'left') => {
|
|
92
|
+
}, []);
|
|
93
|
+
const onClickArrow = useCallback((direction = 'left') => {
|
|
97
94
|
const idx = arrTabs.findIndex(tab => tab.id === activeTabId);
|
|
98
95
|
if (idx !== -1) {
|
|
99
96
|
switch (direction) {
|
|
100
97
|
case 'left':
|
|
101
|
-
if (idx
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
setActiveTabId(arrTabs[idx - 1].id);
|
|
105
|
-
if (onActiveTab)
|
|
106
|
-
onActiveTab(arrTabs[idx - 1].id);
|
|
98
|
+
if (idx !== 0)
|
|
99
|
+
handleActiveTab(arrTabs[idx - 1].id);
|
|
107
100
|
break;
|
|
108
101
|
case 'right':
|
|
109
|
-
if (idx
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
setActiveTabId(arrTabs[idx + 1].id);
|
|
113
|
-
if (onActiveTab)
|
|
114
|
-
onActiveTab(arrTabs[idx + 1].id);
|
|
102
|
+
if (idx !== arrTabs.length - 1)
|
|
103
|
+
handleActiveTab(arrTabs[idx + 1].id);
|
|
115
104
|
break;
|
|
116
105
|
default:
|
|
117
106
|
break;
|
|
118
107
|
}
|
|
119
108
|
}
|
|
120
|
-
};
|
|
109
|
+
}, [activeTabId, arrTabs, handleActiveTab]);
|
|
121
110
|
return (React.createElement(EditorTabStyled, { className: className || '' },
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}), onClick: () => onClickArrow('left') },
|
|
111
|
+
contextModal,
|
|
112
|
+
showArrow && (React.createElement("div", { className: "navigate-button", onClick: () => onClickArrow('left') },
|
|
125
113
|
React.createElement(Icon, { type: "icon-ants-angle-left" }))),
|
|
126
114
|
React.createElement("div", { ref: leftBlockRef, className: classnames('left-block', leftBlockClassName), onWheel: onWheelLeftBlock }, arrTabs && arrTabs.length
|
|
127
115
|
? arrTabs.map((tab, idx) => {
|
|
128
116
|
const { showIcon = true, closeable = true } = tab;
|
|
129
117
|
// const { showIcon = true, showDropdown = true, closeable = true } = tab;
|
|
130
|
-
return (React.createElement("div", { key: tab.id,
|
|
118
|
+
return (React.createElement("div", { key: tab.id, onClick: () => handleActiveTab(tab.id), className: classnames('tab-item', tabItemClassName, {
|
|
131
119
|
active: tab.id === activeTabId,
|
|
132
120
|
}) },
|
|
133
121
|
showIcon &&
|
|
@@ -141,7 +129,7 @@ export const EditorTab = props => {
|
|
|
141
129
|
{ label: 'Configure', key: 'configure', style: { minWidth: '135px' } },
|
|
142
130
|
{ label: 'Remove', key: 'remove', style: { minWidth: '135px' } },
|
|
143
131
|
],
|
|
144
|
-
onClick: ({ key, domEvent })
|
|
132
|
+
onClick: (_a) => __awaiter(void 0, [_a], void 0, function* ({ key, domEvent }) {
|
|
145
133
|
switch (key) {
|
|
146
134
|
case 'configure':
|
|
147
135
|
if (editNameOnConfigure)
|
|
@@ -149,24 +137,19 @@ export const EditorTab = props => {
|
|
|
149
137
|
onConfigure === null || onConfigure === void 0 ? void 0 : onConfigure(tab.id);
|
|
150
138
|
break;
|
|
151
139
|
case 'remove':
|
|
152
|
-
handleCloseTab(domEvent, tab, idx);
|
|
140
|
+
yield handleCloseTab(domEvent, tab, idx);
|
|
153
141
|
break;
|
|
154
142
|
default:
|
|
155
143
|
break;
|
|
156
144
|
}
|
|
157
|
-
},
|
|
145
|
+
}),
|
|
158
146
|
}, placement: "bottomRight", trigger: ['click'], destroyPopupOnHide: true },
|
|
159
|
-
React.createElement(Button, { icon: React.createElement(Icon, { type: "icon-ants-three-dot-vertical", overlayStyle: { fontSize: 12 } }),
|
|
160
|
-
// icon={<Icon type="icon-ants-angle-left" overlayStyle={{ fontSize: 12 }} />}
|
|
161
|
-
// style={{ transform: 'rotate(-90deg)' }}
|
|
162
|
-
size: "small" }))) : closeable ? (React.createElement(Button, { icon: React.createElement(Icon, { type: "icon-ants-remove-slim", onClick: e => handleCloseTab(e, tab, idx), overlayStyle: { fontSize: 12 } }), size: "small" })) : null));
|
|
147
|
+
React.createElement(Button, { icon: React.createElement(Icon, { type: "icon-ants-three-dot-vertical", overlayStyle: { fontSize: 12 } }), size: "small" }))) : closeable ? (React.createElement(Button, { onClick: e => handleCloseTab(e, tab, idx), icon: React.createElement(Icon, { type: "icon-ants-remove-slim", overlayStyle: { fontSize: 12 } }), size: "small" })) : null));
|
|
163
148
|
})
|
|
164
149
|
: null),
|
|
165
|
-
showArrow && (React.createElement("div", { className:
|
|
166
|
-
'--disabled': activeTabIdx === arrTabs.length - 1,
|
|
167
|
-
}), onClick: () => onClickArrow('right') },
|
|
150
|
+
showArrow && (React.createElement("div", { className: "navigate-button", onClick: () => onClickArrow('right') },
|
|
168
151
|
React.createElement(Icon, { type: "icon-ants-angle-right" }))),
|
|
169
|
-
showComposeNewQuery
|
|
152
|
+
showComposeNewQuery || newTabText ? (React.createElement(Button, { onClick: handleAddNew, className: "new-query-button" },
|
|
170
153
|
React.createElement(Icon, { type: "icon-ants-add-square" }),
|
|
171
|
-
|
|
154
|
+
newTabText || 'New query')) : null));
|
|
172
155
|
};
|
|
@@ -115,6 +115,13 @@ export const EditorTabStyled = styled.div `
|
|
|
115
115
|
border: none;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
&:has(.left-block > div:last-child.active) .navigate-button:last-child,
|
|
119
|
+
&:has(.left-block > div:first-child.active) .navigate-button:first-child {
|
|
120
|
+
cursor: not-allowed;
|
|
121
|
+
pointer-events: none;
|
|
122
|
+
opacity: 0.5;
|
|
123
|
+
}
|
|
124
|
+
|
|
118
125
|
.navigate-button {
|
|
119
126
|
/* Structure Block */
|
|
120
127
|
flex-shrink: 0;
|
|
@@ -130,14 +137,14 @@ export const EditorTabStyled = styled.div `
|
|
|
130
137
|
|
|
131
138
|
cursor: pointer;
|
|
132
139
|
|
|
133
|
-
|
|
140
|
+
&:last-child {
|
|
134
141
|
border-right: 1px solid #e0e0e0;
|
|
135
142
|
}
|
|
136
143
|
|
|
137
|
-
&.--disabled {
|
|
144
|
+
/* &.--disabled {
|
|
138
145
|
cursor: not-allowed;
|
|
139
146
|
pointer-events: none;
|
|
140
147
|
opacity: 0.7;
|
|
141
|
-
}
|
|
148
|
+
} */
|
|
142
149
|
}
|
|
143
150
|
`;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type AccountChipProps = {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
|
+
user: any;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
isViewMode?: boolean;
|
|
8
|
+
isError?: boolean;
|
|
9
|
+
errorMsg?: string;
|
|
10
|
+
onRemove?: (item: any) => void;
|
|
11
|
+
};
|
|
12
|
+
declare const AccountChip: React.FC<AccountChipProps>;
|
|
13
|
+
export default AccountChip;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
|
+
// Context
|
|
4
|
+
import { SelectAccountContext } from './context';
|
|
5
|
+
// Components
|
|
6
|
+
import { AccountChipWrapper } from './styled';
|
|
7
|
+
import Icon from '@antscorp/icons';
|
|
8
|
+
import { Tooltip } from '../../atoms';
|
|
9
|
+
const AccountChip = props => {
|
|
10
|
+
const { user, label, value, disabled, isViewMode, isError, errorMsg, onRemove } = props;
|
|
11
|
+
const { state } = useContext(SelectAccountContext);
|
|
12
|
+
const { disabledAccount, userIdKey } = state;
|
|
13
|
+
const handleRemove = () => {
|
|
14
|
+
if (typeof onRemove === 'function') {
|
|
15
|
+
onRemove({ value, user });
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const isDisabled = disabled || (state === null || state === void 0 ? void 0 : state.disabled) || (disabledAccount === null || disabledAccount === void 0 ? void 0 : disabledAccount.includes(user === null || user === void 0 ? void 0 : user[userIdKey]));
|
|
19
|
+
return (React.createElement(Tooltip, { open: isError ? undefined : false, title: errorMsg },
|
|
20
|
+
React.createElement(AccountChipWrapper, { disabled: isDisabled, isError: isError },
|
|
21
|
+
React.createElement("div", { className: "name" }, label),
|
|
22
|
+
!isViewMode && !(state === null || state === void 0 ? void 0 : state.isViewMode) && !isDisabled && (React.createElement("div", { className: "icon-remove", onClick: handleRemove },
|
|
23
|
+
React.createElement(Icon, { type: "icon-ants-remove-slim" }))))));
|
|
24
|
+
};
|
|
25
|
+
AccountChip.defaultProps = {
|
|
26
|
+
disabled: false,
|
|
27
|
+
isViewMode: false,
|
|
28
|
+
isError: false,
|
|
29
|
+
errorMsg: '',
|
|
30
|
+
};
|
|
31
|
+
export default AccountChip;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { useContext, useState } from 'react';
|
|
2
|
+
import { AccountListBody, AccountListContent, AccountListFooter, AccountListTitleGroup, AccountListWrapper, CheckboxStyled, } from './styled';
|
|
3
|
+
import { Button, Icon, Input } from '../../atoms';
|
|
4
|
+
import { Dropdown } from '../Dropdown';
|
|
5
|
+
import { SelectAccountContext } from './context/SelectAccountContext';
|
|
6
|
+
const AccountList = () => {
|
|
7
|
+
const { state, dispatch } = useContext(SelectAccountContext);
|
|
8
|
+
const { usersDisplay, disabledAccount, draftUsersSelected, nameKey, userIdKey, searchText, listAccountGroupDisplay, } = state;
|
|
9
|
+
const [openGroup, setOpenGroup] = useState(true);
|
|
10
|
+
const [openAccount, setOpenAccount] = useState(true);
|
|
11
|
+
const handleCheckbox = userId => {
|
|
12
|
+
dispatch({ type: 'UPDATE_DRAFT_USERS_SELECTED', payload: { userId } });
|
|
13
|
+
};
|
|
14
|
+
const handleCancel = () => {
|
|
15
|
+
dispatch({ type: 'CLOSE_ACCOUNT_LIST' });
|
|
16
|
+
};
|
|
17
|
+
const handleApply = () => {
|
|
18
|
+
dispatch({ type: 'APPLY' });
|
|
19
|
+
};
|
|
20
|
+
const handleSearch = text => {
|
|
21
|
+
dispatch({ type: 'UPDATE_SEARCH_TEXT', payload: text });
|
|
22
|
+
};
|
|
23
|
+
return (React.createElement(AccountListWrapper, null,
|
|
24
|
+
React.createElement(AccountListBody, null,
|
|
25
|
+
React.createElement(Input, { value: searchText, placeholder: "Search", suffix: React.createElement(Icon, { type: "icon-ants-search-2" }), onAfterChange: value => handleSearch(value), debounce: 500 }),
|
|
26
|
+
(state === null || state === void 0 ? void 0 : state.type) === 'group' ? (React.createElement(React.Fragment, null,
|
|
27
|
+
React.createElement(Dropdown, { open: openGroup, getPopupContainer: () => document.getElementById('account-group-list') || document.body, overlayStyle: { position: 'initial' }, trigger: ['click'], dropdownRender: () => (React.createElement(AccountListContent, null, listAccountGroupDisplay === null || listAccountGroupDisplay === void 0 ? void 0 : listAccountGroupDisplay.map((item, idx) => (React.createElement(CheckboxStyled, { key: item === null || item === void 0 ? void 0 : item[state === null || state === void 0 ? void 0 : state.groupIdKey], disabled: disabledAccount === null || disabledAccount === void 0 ? void 0 : disabledAccount.includes(item === null || item === void 0 ? void 0 : item[state === null || state === void 0 ? void 0 : state.groupIdKey]), defaultChecked: draftUsersSelected.includes(item === null || item === void 0 ? void 0 : item[state === null || state === void 0 ? void 0 : state.groupIdKey]), onChange: () => handleCheckbox(item === null || item === void 0 ? void 0 : item[state === null || state === void 0 ? void 0 : state.groupIdKey]) }, item === null || item === void 0 ? void 0 : item[state === null || state === void 0 ? void 0 : state.groupNameKey]))))) },
|
|
28
|
+
React.createElement(AccountListTitleGroup, { onClick: () => setOpenGroup(!openGroup) },
|
|
29
|
+
React.createElement("div", null, "Account Group"),
|
|
30
|
+
React.createElement(Icon, { type: "icon-ants-expand-more", size: 20, style: {
|
|
31
|
+
transform: openGroup ? 'rotate(180deg)' : 'rotate(0deg)',
|
|
32
|
+
transition: '0.3s',
|
|
33
|
+
} }))),
|
|
34
|
+
React.createElement("div", { id: "account-group-list" }),
|
|
35
|
+
React.createElement(Dropdown, { open: openAccount, getPopupContainer: () => document.getElementById('account-list') || document.body, overlayStyle: { position: 'initial' }, trigger: ['click'], dropdownRender: () => (React.createElement(AccountListContent, null, usersDisplay === null || usersDisplay === void 0 ? void 0 : usersDisplay.map(item => (React.createElement(CheckboxStyled, { key: item === null || item === void 0 ? void 0 : item[userIdKey], disabled: disabledAccount === null || disabledAccount === void 0 ? void 0 : disabledAccount.includes(item === null || item === void 0 ? void 0 : item[userIdKey]), defaultChecked: draftUsersSelected.includes(item === null || item === void 0 ? void 0 : item[userIdKey]), onChange: () => handleCheckbox(item === null || item === void 0 ? void 0 : item[userIdKey]) }, item === null || item === void 0 ? void 0 : item[nameKey]))))) },
|
|
36
|
+
React.createElement(AccountListTitleGroup, { onClick: () => setOpenAccount(!openAccount) },
|
|
37
|
+
React.createElement("div", null, "Account"),
|
|
38
|
+
React.createElement(Icon, { type: "icon-ants-expand-more", size: 20, style: {
|
|
39
|
+
transform: openAccount ? 'rotate(180deg)' : 'rotate(0deg)',
|
|
40
|
+
transition: '0.3s',
|
|
41
|
+
} }))),
|
|
42
|
+
React.createElement("div", { id: "account-list" }))) : (React.createElement(AccountListContent, { style: { marginTop: 15 } }, usersDisplay === null || usersDisplay === void 0 ? void 0 : usersDisplay.map(item => (React.createElement(CheckboxStyled, { key: item === null || item === void 0 ? void 0 : item[userIdKey], disabled: disabledAccount === null || disabledAccount === void 0 ? void 0 : disabledAccount.includes(item === null || item === void 0 ? void 0 : item[userIdKey]), defaultChecked: draftUsersSelected.includes(item === null || item === void 0 ? void 0 : item[userIdKey]), onChange: () => handleCheckbox(item === null || item === void 0 ? void 0 : item[userIdKey]) }, item === null || item === void 0 ? void 0 : item[nameKey])))))),
|
|
43
|
+
React.createElement(AccountListFooter, null,
|
|
44
|
+
React.createElement(Button, { onClick: () => handleCancel() }, "Cancel"),
|
|
45
|
+
React.createElement(Button, { type: "primary", onClick: () => handleApply() }, "Apply"))));
|
|
46
|
+
};
|
|
47
|
+
export default AccountList;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
|
+
// Context
|
|
4
|
+
import { SelectAccountContext } from './context';
|
|
5
|
+
// Components
|
|
6
|
+
import { ButtonAddStyled } from './styled';
|
|
7
|
+
import { Icon, Popover } from '../../atoms';
|
|
8
|
+
import AccountList from './AccountList';
|
|
9
|
+
const ButtonAdd = () => {
|
|
10
|
+
const { state, dispatch } = useContext(SelectAccountContext);
|
|
11
|
+
const handleClose = visible => {
|
|
12
|
+
if (!visible) {
|
|
13
|
+
dispatch({ type: 'CLOSE_ACCOUNT_LIST' });
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const handleAfterClose = visible => {
|
|
17
|
+
if (!visible) {
|
|
18
|
+
dispatch({ type: 'UPDATE_SEARCH_TEXT', payload: '' });
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
return (React.createElement(Popover, { open: state.openAccountList, content: React.createElement(AccountList, null), trigger: "click", arrow: false, overlayInnerStyle: { padding: 0 }, destroyTooltipOnHide: true, onOpenChange: handleClose, afterOpenChange: handleAfterClose },
|
|
22
|
+
React.createElement(ButtonAddStyled, { loading: !state.isInitDone, onClick: () => state.openAccountList
|
|
23
|
+
? dispatch({ type: 'CLOSE_ACCOUNT_LIST' })
|
|
24
|
+
: dispatch({ type: 'OPEN_ACCOUNT_LIST' }) },
|
|
25
|
+
React.createElement("div", { className: "icon" },
|
|
26
|
+
React.createElement(Icon, { type: "icon-ants-add", size: 10 })),
|
|
27
|
+
React.createElement("div", { className: "name" }, "Add account"))));
|
|
28
|
+
};
|
|
29
|
+
export default ButtonAdd;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
|
+
// Context
|
|
4
|
+
import { SelectAccountContext } from './context';
|
|
5
|
+
// Components
|
|
6
|
+
import { ButtonViewAllStyled, ViewAllWrapper } from './styled';
|
|
7
|
+
import { Popover } from '../../atoms';
|
|
8
|
+
import AccountChip from './AccountChip';
|
|
9
|
+
const ButtonViewAll = () => {
|
|
10
|
+
const { state, dispatch } = useContext(SelectAccountContext);
|
|
11
|
+
const { usersSelected, nameKey, userIdKey, users } = state;
|
|
12
|
+
const handleRemove = ({ userId, index }) => {
|
|
13
|
+
dispatch({ type: 'REMOVE_USER', payload: { userId, index } });
|
|
14
|
+
};
|
|
15
|
+
const contentViewAll = () => (React.createElement(ViewAllWrapper, null, state.type === 'group'
|
|
16
|
+
? usersSelected === null || usersSelected === void 0 ? void 0 : usersSelected.map((id, index) => {
|
|
17
|
+
if (index < (state === null || state === void 0 ? void 0 : state.limitShow))
|
|
18
|
+
return null;
|
|
19
|
+
const group = state.listAccountGroup.find(u => (u === null || u === void 0 ? void 0 : u[state === null || state === void 0 ? void 0 : state.groupIdKey]) === id);
|
|
20
|
+
if (!group) {
|
|
21
|
+
const user = users.find(u => (u === null || u === void 0 ? void 0 : u[userIdKey]) === id);
|
|
22
|
+
if (!user)
|
|
23
|
+
return null;
|
|
24
|
+
return (React.createElement(AccountChip, { key: user === null || user === void 0 ? void 0 : user[userIdKey], user: user, value: user === null || user === void 0 ? void 0 : user[userIdKey], label: user === null || user === void 0 ? void 0 : user[nameKey], onRemove: () => handleRemove({ userId: user === null || user === void 0 ? void 0 : user[userIdKey], index }) }));
|
|
25
|
+
}
|
|
26
|
+
return (React.createElement(AccountChip, { key: group === null || group === void 0 ? void 0 : group[state.groupIdKey], user: group, value: group === null || group === void 0 ? void 0 : group[state.groupIdKey], label: group === null || group === void 0 ? void 0 : group[state === null || state === void 0 ? void 0 : state.groupNameKey], onRemove: () => handleRemove({ userId: group === null || group === void 0 ? void 0 : group[state.groupIdKey], index }) }));
|
|
27
|
+
})
|
|
28
|
+
: usersSelected === null || usersSelected === void 0 ? void 0 : usersSelected.map((id, index) => {
|
|
29
|
+
if (index < (state === null || state === void 0 ? void 0 : state.limitShow))
|
|
30
|
+
return null;
|
|
31
|
+
const user = users.find(u => (u === null || u === void 0 ? void 0 : u[userIdKey]) === id);
|
|
32
|
+
return (React.createElement(AccountChip, { key: user === null || user === void 0 ? void 0 : user[userIdKey], user: user, value: user === null || user === void 0 ? void 0 : user[userIdKey], label: user === null || user === void 0 ? void 0 : user[nameKey], onRemove: () => handleRemove({ userId: user === null || user === void 0 ? void 0 : user[userIdKey], index }) }));
|
|
33
|
+
})));
|
|
34
|
+
return (React.createElement(Popover, { content: () => contentViewAll(), trigger: "click", arrow: false, overlayInnerStyle: { padding: 0 }, destroyTooltipOnHide: true },
|
|
35
|
+
React.createElement(ButtonViewAllStyled, { type: "text" }, "View all")));
|
|
36
|
+
};
|
|
37
|
+
export default ButtonViewAll;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
|
+
// Context
|
|
4
|
+
import { SelectAccountContext } from './context';
|
|
5
|
+
// Components
|
|
6
|
+
import { Wrapper } from './styled';
|
|
7
|
+
import AccountChip from './AccountChip';
|
|
8
|
+
import ButtonAdd from './ButtonAdd';
|
|
9
|
+
import ButtonViewAll from './ButtonViewAll';
|
|
10
|
+
export const Content = () => {
|
|
11
|
+
var _a;
|
|
12
|
+
const { state, dispatch } = useContext(SelectAccountContext);
|
|
13
|
+
const { usersSelected, nameKey, userIdKey, users, disabled } = state;
|
|
14
|
+
const handleRemove = ({ userId, index }) => {
|
|
15
|
+
dispatch({ type: 'REMOVE_USER', payload: { userId, index } });
|
|
16
|
+
};
|
|
17
|
+
return (React.createElement(Wrapper, { disabled: !!disabled },
|
|
18
|
+
state.type === 'group'
|
|
19
|
+
? usersSelected === null || usersSelected === void 0 ? void 0 : usersSelected.map((id, index) => {
|
|
20
|
+
var _a;
|
|
21
|
+
if (index >= (state === null || state === void 0 ? void 0 : state.limitShow))
|
|
22
|
+
return null;
|
|
23
|
+
const group = (_a = state === null || state === void 0 ? void 0 : state.listAccountGroup) === null || _a === void 0 ? void 0 : _a.find(u => (u === null || u === void 0 ? void 0 : u[state === null || state === void 0 ? void 0 : state.groupIdKey]) === id);
|
|
24
|
+
if (!group) {
|
|
25
|
+
const user = users.find(u => (u === null || u === void 0 ? void 0 : u[userIdKey]) === id);
|
|
26
|
+
if (!user)
|
|
27
|
+
return null;
|
|
28
|
+
return (React.createElement(AccountChip, { key: user === null || user === void 0 ? void 0 : user[userIdKey], user: user, value: user === null || user === void 0 ? void 0 : user[userIdKey], label: user === null || user === void 0 ? void 0 : user[nameKey], onRemove: () => handleRemove({ userId: user === null || user === void 0 ? void 0 : user[userIdKey], index }) }));
|
|
29
|
+
}
|
|
30
|
+
return (React.createElement(AccountChip, { key: group === null || group === void 0 ? void 0 : group[state.groupIdKey], user: group, value: group === null || group === void 0 ? void 0 : group[state.groupIdKey], label: group === null || group === void 0 ? void 0 : group[state === null || state === void 0 ? void 0 : state.groupNameKey], onRemove: () => handleRemove({ userId: group === null || group === void 0 ? void 0 : group[state.groupIdKey], index }) }));
|
|
31
|
+
})
|
|
32
|
+
: usersSelected === null || usersSelected === void 0 ? void 0 : usersSelected.map((id, index) => {
|
|
33
|
+
if (index >= (state === null || state === void 0 ? void 0 : state.limitShow))
|
|
34
|
+
return null;
|
|
35
|
+
const user = users.find(u => (u === null || u === void 0 ? void 0 : u[userIdKey]) === id);
|
|
36
|
+
return (React.createElement(AccountChip, { key: user === null || user === void 0 ? void 0 : user[userIdKey], user: user, value: user === null || user === void 0 ? void 0 : user[userIdKey], label: user === null || user === void 0 ? void 0 : user[nameKey], onRemove: () => handleRemove({ userId: user === null || user === void 0 ? void 0 : user[userIdKey], index }) }));
|
|
37
|
+
}),
|
|
38
|
+
((_a = state === null || state === void 0 ? void 0 : state.usersSelected) === null || _a === void 0 ? void 0 : _a.length) > (state === null || state === void 0 ? void 0 : state.limitShow) && React.createElement(ButtonViewAll, null),
|
|
39
|
+
!(state === null || state === void 0 ? void 0 : state.isViewMode) && React.createElement(ButtonAdd, null)));
|
|
40
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
// Libraries
|
|
13
|
+
import React, { createContext, useEffect, useMemo, useReducer } from 'react';
|
|
14
|
+
import { uniq } from 'lodash';
|
|
15
|
+
// Reducer
|
|
16
|
+
import { initialState, reducer } from './reducer';
|
|
17
|
+
// Hooks
|
|
18
|
+
import { useGetAbstractUsers } from '../hook';
|
|
19
|
+
const initialContext = {
|
|
20
|
+
state: initialState,
|
|
21
|
+
dispatch: () => { },
|
|
22
|
+
};
|
|
23
|
+
export const SelectAccountContext = createContext(initialContext);
|
|
24
|
+
export const SelectAccountProvider = props => {
|
|
25
|
+
const { children, initData } = props, rest = __rest(props, ["children", "initData"]);
|
|
26
|
+
const [state, dispatch] = useReducer(reducer, Object.assign(Object.assign(Object.assign({}, initialState), rest), { usersSelected: [...(uniq(initData) || [])] }));
|
|
27
|
+
const contextValue = useMemo(() => ({ state, dispatch }), [state, dispatch]);
|
|
28
|
+
const { usersSelected, isInitDone, onChange } = state;
|
|
29
|
+
// Fetch users
|
|
30
|
+
const { isLoading, data } = useGetAbstractUsers({
|
|
31
|
+
queryFn: state.serviceAccounts,
|
|
32
|
+
params: state.paramsFetchUsers,
|
|
33
|
+
search: state.searchType === 'server' ? state.searchText : '',
|
|
34
|
+
});
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
dispatch({ type: 'INIT' });
|
|
37
|
+
}, []);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (!isLoading) {
|
|
40
|
+
dispatch({ type: 'UPDATE_USERS', payload: (data === null || data === void 0 ? void 0 : data[state === null || state === void 0 ? void 0 : state.dataAccountsKey]) || [] });
|
|
41
|
+
dispatch({ type: 'UPDATE_USERS_DISPLAY', payload: (data === null || data === void 0 ? void 0 : data[state === null || state === void 0 ? void 0 : state.dataAccountsKey]) || [] });
|
|
42
|
+
}
|
|
43
|
+
}, [data]);
|
|
44
|
+
// Callback OnChange
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (isInitDone && typeof onChange === 'function') {
|
|
47
|
+
onChange(usersSelected);
|
|
48
|
+
}
|
|
49
|
+
}, [usersSelected]);
|
|
50
|
+
return (React.createElement(SelectAccountContext.Provider, { value: contextValue }, children));
|
|
51
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SelectAccountContext';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SelectAccountContext';
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import produce from 'immer';
|
|
2
|
+
export const initialState = {
|
|
3
|
+
isInitDone: false,
|
|
4
|
+
searchText: '',
|
|
5
|
+
openAccountList: false,
|
|
6
|
+
limitShow: 10,
|
|
7
|
+
users: [],
|
|
8
|
+
usersDisplay: [],
|
|
9
|
+
listAccountGroupDisplay: [],
|
|
10
|
+
paramsFetchUsers: {},
|
|
11
|
+
usersSelected: [],
|
|
12
|
+
draftUsersSelected: [],
|
|
13
|
+
type: 'default',
|
|
14
|
+
};
|
|
15
|
+
export const reducer = (state, action) => produce(state, draft => {
|
|
16
|
+
var _a, _b, _c, _d, _e;
|
|
17
|
+
// console.log(action.type, { payload: action?.payload || undefined, state });
|
|
18
|
+
switch (action.type) {
|
|
19
|
+
case 'INIT': {
|
|
20
|
+
if (draft.type === 'group') {
|
|
21
|
+
draft.listAccountGroupDisplay = draft.listAccountGroup;
|
|
22
|
+
}
|
|
23
|
+
draft.paramsFetchUsers = draft.paramsAccounts || {};
|
|
24
|
+
draft.isInitDone = true;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
case 'OPEN_ACCOUNT_LIST':
|
|
28
|
+
draft.openAccountList = true;
|
|
29
|
+
draft.draftUsersSelected = draft.usersSelected;
|
|
30
|
+
break;
|
|
31
|
+
case 'CLOSE_ACCOUNT_LIST':
|
|
32
|
+
draft.openAccountList = false;
|
|
33
|
+
draft.draftUsersSelected = [];
|
|
34
|
+
break;
|
|
35
|
+
case 'APPLY':
|
|
36
|
+
draft.usersSelected = draft.draftUsersSelected;
|
|
37
|
+
draft.draftUsersSelected = [];
|
|
38
|
+
draft.openAccountList = false;
|
|
39
|
+
break;
|
|
40
|
+
case 'UPDATE_USERS':
|
|
41
|
+
draft.users = action.payload;
|
|
42
|
+
break;
|
|
43
|
+
case 'UPDATE_USERS_DISPLAY':
|
|
44
|
+
draft.usersDisplay = action.payload;
|
|
45
|
+
break;
|
|
46
|
+
case 'UPDATE_USERS_SELECTED':
|
|
47
|
+
draft.usersSelected = action.payload;
|
|
48
|
+
break;
|
|
49
|
+
case 'UPDATE_DRAFT_USERS_SELECTED': {
|
|
50
|
+
const { userId } = action.payload;
|
|
51
|
+
const indexExist = (_a = draft === null || draft === void 0 ? void 0 : draft.draftUsersSelected) === null || _a === void 0 ? void 0 : _a.indexOf(userId);
|
|
52
|
+
if (indexExist >= 0) {
|
|
53
|
+
draft.draftUsersSelected = [
|
|
54
|
+
...(_b = draft === null || draft === void 0 ? void 0 : draft.draftUsersSelected) === null || _b === void 0 ? void 0 : _b.slice(0, indexExist),
|
|
55
|
+
...(_c = draft === null || draft === void 0 ? void 0 : draft.draftUsersSelected) === null || _c === void 0 ? void 0 : _c.slice(indexExist + 1),
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
draft.draftUsersSelected = [...draft === null || draft === void 0 ? void 0 : draft.draftUsersSelected, userId];
|
|
60
|
+
}
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
case 'UPDATE_SEARCH_TEXT':
|
|
64
|
+
draft.searchText = action.payload;
|
|
65
|
+
if (draft.searchType === 'client') {
|
|
66
|
+
const userFilters = (_d = draft.users) === null || _d === void 0 ? void 0 : _d.filter(user => {
|
|
67
|
+
var _a, _b, _c;
|
|
68
|
+
return ((_b = (_a = user === null || user === void 0 ? void 0 : user[draft === null || draft === void 0 ? void 0 : draft.nameKey]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.indexOf((_c = action.payload) === null || _c === void 0 ? void 0 : _c.toLowerCase().trim())) !== -1;
|
|
69
|
+
});
|
|
70
|
+
draft.usersDisplay = userFilters;
|
|
71
|
+
}
|
|
72
|
+
else if (draft.searchType === 'server') {
|
|
73
|
+
draft.paramsFetchUsers = {
|
|
74
|
+
search: action.payload,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if (draft.type === 'group') {
|
|
78
|
+
const groupFilters = (_e = draft.listAccountGroup) === null || _e === void 0 ? void 0 : _e.filter(group => {
|
|
79
|
+
var _a, _b, _c;
|
|
80
|
+
return ((_b = (_a = group === null || group === void 0 ? void 0 : group[draft === null || draft === void 0 ? void 0 : draft.groupNameKey]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.indexOf((_c = action.payload) === null || _c === void 0 ? void 0 : _c.toLowerCase().trim())) !== -1;
|
|
81
|
+
});
|
|
82
|
+
draft.listAccountGroupDisplay = groupFilters;
|
|
83
|
+
}
|
|
84
|
+
break;
|
|
85
|
+
case 'REMOVE_USER':
|
|
86
|
+
{
|
|
87
|
+
const { index } = action.payload;
|
|
88
|
+
const clone = [...draft.usersSelected];
|
|
89
|
+
draft.usersSelected = [...clone.slice(0, index), ...clone.slice(index + 1)];
|
|
90
|
+
}
|
|
91
|
+
break;
|
|
92
|
+
default:
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useGetAbstractUsers';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useGetAbstractUsers';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UseQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
type Props = {
|
|
3
|
+
queryOptions?: UseQueryOptions;
|
|
4
|
+
params?: Record<string, any>;
|
|
5
|
+
search?: string;
|
|
6
|
+
queryFn?: Function;
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
defaultDataSource?: any;
|
|
9
|
+
};
|
|
10
|
+
export declare const useGetAbstractUsers: ({ queryOptions, params, search, queryFn, enabled, }: Props) => import("@tanstack/react-query").UseQueryResult<unknown, unknown>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import { useQuery } from '@tanstack/react-query';
|
|
3
|
+
// Service
|
|
4
|
+
import AbstractService from '@antscorp/antsomi-ui/es/services/Abstract';
|
|
5
|
+
// Constant
|
|
6
|
+
import { QUERY_KEYS } from '@antscorp/antsomi-ui/es/constants';
|
|
7
|
+
export const useGetAbstractUsers = ({ queryOptions = {}, params = {}, search = '', queryFn = AbstractService.lookupInfo.callApi.c_user_id, enabled = true, }) => useQuery(Object.assign({ queryKey: [QUERY_KEYS.GET_ABSTRACT_USERS, JSON.stringify({ params, search })],
|
|
8
|
+
// initialData: defaultDataSource,
|
|
9
|
+
queryFn: () => queryFn({ params, search }) }, queryOptions));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { queryClientAntsomiUI, QueryClientProviderAntsomiUI, } from '@antscorp/antsomi-ui/es/queries/configs';
|
|
4
|
+
// Context
|
|
5
|
+
import { SelectAccountProvider } from './context/SelectAccountContext';
|
|
6
|
+
// Components
|
|
7
|
+
import { Content } from './Content';
|
|
8
|
+
// Provider
|
|
9
|
+
import { AntdTableConfigProvider } from '../../organism/DataTable/providers';
|
|
10
|
+
export const SelectAccount = props => (React.createElement(QueryClientProviderAntsomiUI, { client: queryClientAntsomiUI },
|
|
11
|
+
React.createElement(AntdTableConfigProvider, null,
|
|
12
|
+
React.createElement(SelectAccountProvider, Object.assign({}, props),
|
|
13
|
+
React.createElement(Content, null)))));
|
|
14
|
+
SelectAccount.defaultProps = {
|
|
15
|
+
initData: [],
|
|
16
|
+
limitShow: 10,
|
|
17
|
+
type: 'default',
|
|
18
|
+
searchType: 'client',
|
|
19
|
+
dataAccountsKey: 'data',
|
|
20
|
+
};
|
|
21
|
+
export default SelectAccount;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const Wrapper: import("styled-components").StyledComponent<"div", any, {
|
|
3
|
+
disabled: boolean;
|
|
4
|
+
}, never>;
|
|
5
|
+
export declare const AccountChipWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
6
|
+
disabled?: boolean | undefined;
|
|
7
|
+
isError?: boolean | undefined;
|
|
8
|
+
}, never>;
|
|
9
|
+
export declare const ButtonAddStyled: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/button/button").ButtonProps & import("react").RefAttributes<HTMLElement>> & {
|
|
10
|
+
Group: import("react").FC<import("antd/es/button").ButtonGroupProps>;
|
|
11
|
+
}, any, {}, never>;
|
|
12
|
+
export declare const ButtonViewAllStyled: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/button/button").ButtonProps & import("react").RefAttributes<HTMLElement>> & {
|
|
13
|
+
Group: import("react").FC<import("antd/es/button").ButtonGroupProps>;
|
|
14
|
+
}, any, {}, never>;
|
|
15
|
+
export declare const AccountListWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
16
|
+
export declare const AccountListBody: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
17
|
+
export declare const AccountListFooter: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
18
|
+
export declare const AccountListTitleGroup: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
19
|
+
export declare const AccountListContent: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
20
|
+
export declare const CheckboxStyled: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd").CheckboxProps & import("react").RefAttributes<import("rc-checkbox").CheckboxRef>> & {
|
|
21
|
+
Group: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<import("antd/es/checkbox").CheckboxGroupProps & import("react").RefAttributes<HTMLDivElement>>>;
|
|
22
|
+
}, any, {}, never>;
|
|
23
|
+
export declare const ViewAllWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { Button, Checkbox } from '../../atoms';
|
|
3
|
+
export const Wrapper = styled.div `
|
|
4
|
+
display: flex;
|
|
5
|
+
gap: 5px;
|
|
6
|
+
flex-wrap: wrap;
|
|
7
|
+
width: 100%;
|
|
8
|
+
pointer-events: ${props => ((props === null || props === void 0 ? void 0 : props.disabled) ? 'none' : 'initial')};
|
|
9
|
+
`;
|
|
10
|
+
export const AccountChipWrapper = styled.div `
|
|
11
|
+
color: #000000;
|
|
12
|
+
font-size: 12px;
|
|
13
|
+
line-height: 14px;
|
|
14
|
+
font-weight: 400;
|
|
15
|
+
|
|
16
|
+
position: relative;
|
|
17
|
+
padding: 5px 10px;
|
|
18
|
+
background-color: ${({ disabled, isError }) => disabled ? '#E5E5E5' : isError ? '#fecaca' : '#CAE5FE'};
|
|
19
|
+
border-radius: 999px;
|
|
20
|
+
|
|
21
|
+
.name {
|
|
22
|
+
margin: 0px;
|
|
23
|
+
padding: 0px;
|
|
24
|
+
|
|
25
|
+
width: 100%;
|
|
26
|
+
text-align: center;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.icon-remove {
|
|
30
|
+
display: none;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
align-items: center;
|
|
33
|
+
|
|
34
|
+
position: absolute;
|
|
35
|
+
top: 4px;
|
|
36
|
+
right: 4px;
|
|
37
|
+
|
|
38
|
+
font-size: 10px;
|
|
39
|
+
color: #005eb8;
|
|
40
|
+
|
|
41
|
+
border-radius: 100%;
|
|
42
|
+
background-color: #ffffff;
|
|
43
|
+
width: 16px;
|
|
44
|
+
height: 16px;
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&:hover .icon-remove {
|
|
49
|
+
display: flex;
|
|
50
|
+
}
|
|
51
|
+
`;
|
|
52
|
+
export const ButtonAddStyled = styled(Button) `
|
|
53
|
+
border: 1px solid #005eb8 !important;
|
|
54
|
+
border-radius: 999px !important;
|
|
55
|
+
background-color: transparent;
|
|
56
|
+
padding: 4px 5px !important;
|
|
57
|
+
height: 24px !important;
|
|
58
|
+
|
|
59
|
+
display: flex;
|
|
60
|
+
color: #005eb8;
|
|
61
|
+
font-size: 12px;
|
|
62
|
+
line-height: 14px;
|
|
63
|
+
font-weight: 700;
|
|
64
|
+
|
|
65
|
+
.icon {
|
|
66
|
+
font-size: 10px;
|
|
67
|
+
padding: 3px;
|
|
68
|
+
display: flex;
|
|
69
|
+
justify-content: center;
|
|
70
|
+
align-items: center;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.name {
|
|
74
|
+
padding: 0 5px 0 0;
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
export const ButtonViewAllStyled = styled(Button) `
|
|
78
|
+
height: 24px !important;
|
|
79
|
+
|
|
80
|
+
display: flex;
|
|
81
|
+
color: #005eb8;
|
|
82
|
+
font-size: 12px;
|
|
83
|
+
line-height: 14px;
|
|
84
|
+
font-weight: 700;
|
|
85
|
+
`;
|
|
86
|
+
// ----- AccountList -----
|
|
87
|
+
export const AccountListWrapper = styled.div `
|
|
88
|
+
border-radius: 2px;
|
|
89
|
+
width: 300px;
|
|
90
|
+
background-color: #ffffff;
|
|
91
|
+
box-shadow: 0px 3px 20px 0px #002e5933;
|
|
92
|
+
transition: 0.3s;
|
|
93
|
+
`;
|
|
94
|
+
export const AccountListBody = styled.div `
|
|
95
|
+
padding: 15px;
|
|
96
|
+
`;
|
|
97
|
+
export const AccountListFooter = styled.div `
|
|
98
|
+
display: flex;
|
|
99
|
+
justify-content: flex-end;
|
|
100
|
+
gap: 10px;
|
|
101
|
+
|
|
102
|
+
border-top: 1px solid #e5e5e5;
|
|
103
|
+
padding: 15px;
|
|
104
|
+
`;
|
|
105
|
+
export const AccountListTitleGroup = styled.div `
|
|
106
|
+
display: flex;
|
|
107
|
+
justify-content: space-between;
|
|
108
|
+
align-items: center;
|
|
109
|
+
margin-top: 10px;
|
|
110
|
+
|
|
111
|
+
font-size: 14px;
|
|
112
|
+
line-height: 16px;
|
|
113
|
+
font-weight: 700;
|
|
114
|
+
cursor: pointer;
|
|
115
|
+
`;
|
|
116
|
+
export const AccountListContent = styled.div `
|
|
117
|
+
display: flex;
|
|
118
|
+
flex-direction: column;
|
|
119
|
+
gap: 5px;
|
|
120
|
+
|
|
121
|
+
max-height: 160px;
|
|
122
|
+
overflow: auto;
|
|
123
|
+
|
|
124
|
+
& label:hover {
|
|
125
|
+
background-color: #f2f9ff;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
&:hover::-webkit-scrollbar-thumb {
|
|
129
|
+
display: initial !important;
|
|
130
|
+
-ms-overflow-style: initial; /* IE and Edge */
|
|
131
|
+
scrollbar-width: initial; /* Firefox */
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
::-webkit-scrollbar {
|
|
135
|
+
border-radius: 15px !important;
|
|
136
|
+
width: 4px !important;
|
|
137
|
+
height: 4px !important;
|
|
138
|
+
background-color: transparent !important;
|
|
139
|
+
}
|
|
140
|
+
::-webkit-scrollbar-track {
|
|
141
|
+
border-radius: 15px !important;
|
|
142
|
+
background-color: transparent !important;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
::-webkit-scrollbar-thumb {
|
|
146
|
+
display: none !important;
|
|
147
|
+
-ms-overflow-style: none; /* IE and Edge */
|
|
148
|
+
scrollbar-width: none; /* Firefox */
|
|
149
|
+
|
|
150
|
+
border-radius: 15px !important;
|
|
151
|
+
background-color: #babac0 !important;
|
|
152
|
+
}
|
|
153
|
+
`;
|
|
154
|
+
export const CheckboxStyled = styled(Checkbox) `
|
|
155
|
+
padding: 5px !important;
|
|
156
|
+
border-radius: 10px !important;
|
|
157
|
+
`;
|
|
158
|
+
export const ViewAllWrapper = styled.div `
|
|
159
|
+
display: flex;
|
|
160
|
+
gap: 10px;
|
|
161
|
+
flex-wrap: wrap;
|
|
162
|
+
max-width: 300px;
|
|
163
|
+
padding: 15px;
|
|
164
|
+
`;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type AccountProps = {
|
|
3
|
+
type: 'default';
|
|
4
|
+
};
|
|
5
|
+
type GroupAccountProps = {
|
|
6
|
+
type: 'group';
|
|
7
|
+
listAccountGroup: any[];
|
|
8
|
+
groupNameKey: string;
|
|
9
|
+
groupIdKey: string;
|
|
10
|
+
};
|
|
11
|
+
export type SelectAccountProps = {
|
|
12
|
+
initData?: Array<string | number>;
|
|
13
|
+
searchType?: 'client' | 'server';
|
|
14
|
+
isViewMode?: boolean;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
disabledAccount?: any[];
|
|
17
|
+
limitShow?: number;
|
|
18
|
+
nameKey: string;
|
|
19
|
+
userIdKey: string;
|
|
20
|
+
dataAccountsKey: string;
|
|
21
|
+
paramsAccounts: {};
|
|
22
|
+
serviceAccounts: ({ params, search }: {
|
|
23
|
+
params: any;
|
|
24
|
+
search: any;
|
|
25
|
+
}) => Promise<any>;
|
|
26
|
+
onChange?: (idSelected: Array<string | number>) => void;
|
|
27
|
+
} & (AccountProps | GroupAccountProps);
|
|
28
|
+
export type TState = SelectAccountProps & {
|
|
29
|
+
isInitDone: boolean;
|
|
30
|
+
searchText: string;
|
|
31
|
+
openAccountList: boolean;
|
|
32
|
+
limitShow: number;
|
|
33
|
+
users: any[];
|
|
34
|
+
usersDisplay: any[];
|
|
35
|
+
listAccountGroupDisplay: any[];
|
|
36
|
+
usersSelected: (string | number)[];
|
|
37
|
+
draftUsersSelected: (string | number)[];
|
|
38
|
+
paramsFetchUsers: {};
|
|
39
|
+
};
|
|
40
|
+
export type TAction = {
|
|
41
|
+
type: 'INIT';
|
|
42
|
+
} | {
|
|
43
|
+
type: 'APPLY';
|
|
44
|
+
} | {
|
|
45
|
+
type: 'OPEN_ACCOUNT_LIST';
|
|
46
|
+
} | {
|
|
47
|
+
type: 'CLOSE_ACCOUNT_LIST';
|
|
48
|
+
} | {
|
|
49
|
+
type: 'UPDATE_USERS';
|
|
50
|
+
payload: any[];
|
|
51
|
+
} | {
|
|
52
|
+
type: 'UPDATE_USERS_DISPLAY';
|
|
53
|
+
payload: any[];
|
|
54
|
+
} | {
|
|
55
|
+
type: 'UPDATE_USERS_SELECTED';
|
|
56
|
+
payload: any[];
|
|
57
|
+
} | {
|
|
58
|
+
type: 'UPDATE_DRAFT_USERS_SELECTED';
|
|
59
|
+
payload: {
|
|
60
|
+
userId: string | number;
|
|
61
|
+
};
|
|
62
|
+
} | {
|
|
63
|
+
type: 'UPDATE_SEARCH_TEXT';
|
|
64
|
+
payload: string;
|
|
65
|
+
} | {
|
|
66
|
+
type: 'UPDATE_USERS';
|
|
67
|
+
payload: any[];
|
|
68
|
+
} | {
|
|
69
|
+
type: 'REMOVE_USER';
|
|
70
|
+
payload: {
|
|
71
|
+
userId: string | number;
|
|
72
|
+
index: number;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
export type TContext = {
|
|
76
|
+
state: TState;
|
|
77
|
+
dispatch: React.Dispatch<TAction>;
|
|
78
|
+
};
|
|
79
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -57,6 +57,7 @@ export * from './ProcessLoading';
|
|
|
57
57
|
export { EditorScript } from './EditorScript';
|
|
58
58
|
export { CalendarSelection, CalendarSelectionConstants } from './CalendarSelection';
|
|
59
59
|
export { EditorTab } from './EditorTab';
|
|
60
|
+
export { SelectAccount } from './SelectAccount';
|
|
60
61
|
export type { AdvancedPickerProps, TAdvancedPickerOption, TAdvancedRangePickerTimeRange, } from './DatePicker';
|
|
61
62
|
export type { ColorPickerProps } from './ColorPicker';
|
|
62
63
|
export type { AlignEditProps, AlignSettingProps } from './AlignSetting';
|
package/es/constants/queries.js
CHANGED
|
@@ -11,7 +11,7 @@ import { fab } from '@fortawesome/free-brands-svg-icons';
|
|
|
11
11
|
library.add(fas, far, fab);
|
|
12
12
|
const { accent6, accent7, gray5, scrollBarSize } = THEME.token || {};
|
|
13
13
|
export const GlobalStyle = () => {
|
|
14
|
-
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, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38;
|
|
14
|
+
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, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39;
|
|
15
15
|
return (React.createElement(Global, { styles: css `
|
|
16
16
|
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400;500;700;900&display=swap');
|
|
17
17
|
|
|
@@ -825,6 +825,20 @@ export const GlobalStyle = () => {
|
|
|
825
825
|
border-radius: 0 0 2px 2px;
|
|
826
826
|
}
|
|
827
827
|
}
|
|
828
|
+
/* Override style for Modal confirm in Editor Tab */
|
|
829
|
+
.editor-tab__modal-confirm .antsomi-modal-content .antsomi-modal-body {
|
|
830
|
+
.antsomi-modal-confirm-body-wrapper {
|
|
831
|
+
padding: 0;
|
|
832
|
+
|
|
833
|
+
.antsomi-modal-confirm-body {
|
|
834
|
+
padding: 20px 20px 0 20px;
|
|
835
|
+
}
|
|
836
|
+
.antsomi-modal-confirm-btns {
|
|
837
|
+
padding: 12px 20px 20px;
|
|
838
|
+
border-top: 1px solid ${(_34 = THEME.token) === null || _34 === void 0 ? void 0 : _34.bw4};
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
}
|
|
828
842
|
|
|
829
843
|
/* Message Notification */
|
|
830
844
|
.ant-message {
|
|
@@ -838,7 +852,7 @@ export const GlobalStyle = () => {
|
|
|
838
852
|
|
|
839
853
|
.antsomi-collapse {
|
|
840
854
|
&.antsomi-collapse-borderless {
|
|
841
|
-
border-bottom: 1px solid ${(
|
|
855
|
+
border-bottom: 1px solid ${(_35 = THEME.token) === null || _35 === void 0 ? void 0 : _35.gray5};
|
|
842
856
|
}
|
|
843
857
|
|
|
844
858
|
> .antsomi-collapse-item > .antsomi-collapse-header .antsomi-collapse-arrow {
|
|
@@ -848,12 +862,12 @@ export const GlobalStyle = () => {
|
|
|
848
862
|
|
|
849
863
|
/* Switch */
|
|
850
864
|
.antsomi-switch {
|
|
851
|
-
border: 2px solid ${(
|
|
865
|
+
border: 2px solid ${(_36 = THEME.token) === null || _36 === void 0 ? void 0 : _36.colorPrimary} !important;
|
|
852
866
|
|
|
853
867
|
&.antsomi-switch-checked {
|
|
854
868
|
> .antsomi-switch-handle {
|
|
855
869
|
&::before {
|
|
856
|
-
background-color: ${(
|
|
870
|
+
background-color: ${(_37 = THEME.token) === null || _37 === void 0 ? void 0 : _37.bw0} !important;
|
|
857
871
|
}
|
|
858
872
|
}
|
|
859
873
|
}
|
|
@@ -870,7 +884,7 @@ export const GlobalStyle = () => {
|
|
|
870
884
|
font-weight: bold;
|
|
871
885
|
|
|
872
886
|
&:not(.antsomi-tabs-tab-active):hover {
|
|
873
|
-
background-color: ${(
|
|
887
|
+
background-color: ${(_38 = THEME.token) === null || _38 === void 0 ? void 0 : _38.blue};
|
|
874
888
|
}
|
|
875
889
|
}
|
|
876
890
|
.antsomi-tabs-tab-active {
|
|
@@ -912,7 +926,7 @@ export const GlobalStyle = () => {
|
|
|
912
926
|
.antsomi-menu {
|
|
913
927
|
.antsomi-menu-submenu.antsomi-menu-submenu-selected {
|
|
914
928
|
.antsomi-menu-item.antsomi-menu-item-selected {
|
|
915
|
-
background-color: ${(
|
|
929
|
+
background-color: ${(_39 = THEME.token) === null || _39 === void 0 ? void 0 : _39.blue};
|
|
916
930
|
}
|
|
917
931
|
}
|
|
918
932
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const AbstractService: {
|
|
2
|
+
lookupInfo: {
|
|
3
|
+
callApi: {
|
|
4
|
+
c_user_id: ({ params, search }: {
|
|
5
|
+
params?: {} | undefined;
|
|
6
|
+
search: any;
|
|
7
|
+
}) => Promise<any[]>;
|
|
8
|
+
list_account: ({ params, search }: {
|
|
9
|
+
params?: {} | undefined;
|
|
10
|
+
search: any;
|
|
11
|
+
}) => Promise<any[]>;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export default AbstractService;
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
import { ENDPOINT } from '../../constants';
|
|
11
|
+
import { callApiWithAuth, getEntriesV2 } from '../../utils';
|
|
12
|
+
const AbstractService = {
|
|
13
|
+
lookupInfo: {
|
|
14
|
+
callApi: {
|
|
15
|
+
c_user_id: (_a) => __awaiter(void 0, [_a], void 0, function* ({ params = {}, search }) {
|
|
16
|
+
const queryParams = Object.assign({ search }, params);
|
|
17
|
+
const query = new URLSearchParams(queryParams).toString();
|
|
18
|
+
return callApiWithAuth(`${ENDPOINT.toolkitV2}/selector/users/listing${query ? `?${query}` : ''}`, 'GET', null, '//sandbox-app.cdp.asia/hub', { api_pid: 33167 }, '5474r2x214z294d4v284y4n5g436p464g47423o4', '1600084823')
|
|
19
|
+
.then(res => {
|
|
20
|
+
const data = getEntriesV2(res, 0);
|
|
21
|
+
return data;
|
|
22
|
+
})
|
|
23
|
+
.catch(err => {
|
|
24
|
+
console.error(err);
|
|
25
|
+
return err;
|
|
26
|
+
});
|
|
27
|
+
}),
|
|
28
|
+
list_account: (_b) => __awaiter(void 0, [_b], void 0, function* ({ params = {}, search }) {
|
|
29
|
+
const queryParams = Object.assign({ search }, params);
|
|
30
|
+
const query = new URLSearchParams(queryParams).toString();
|
|
31
|
+
return callApiWithAuth(`${ENDPOINT.toolkitV2}/portal/get-list-account-network${query ? `?${query}` : ''}`, 'GET', null, '//sandbox-app.cdp.asia/hub', { api_pid: 33167 }, '5474r2x214z294d4v284y4l5j454p4k5s4q2u4l4l5', '1600084823')
|
|
32
|
+
.then(res => {
|
|
33
|
+
const data = getEntriesV2(res, 0);
|
|
34
|
+
// dataBackup[params.objectName] = data;
|
|
35
|
+
return data;
|
|
36
|
+
})
|
|
37
|
+
.catch(err => {
|
|
38
|
+
console.error(err);
|
|
39
|
+
return err;
|
|
40
|
+
});
|
|
41
|
+
}),
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
export default AbstractService;
|