@antscorp/antsomi-ui 1.3.6-beta.3 → 1.3.6-beta.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/es/components/atoms/Input/Input.d.ts +11 -17
  2. package/es/components/atoms/Input/Input.js +7 -11
  3. package/es/components/atoms/Switch/Switch.js +2 -1
  4. package/es/components/icons/LazyIcon/LazyIcon.d.ts +2 -0
  5. package/es/components/icons/LazyIcon/LazyIcon.js +2 -0
  6. package/es/components/icons/TaskAltIcon.d.ts +3 -0
  7. package/es/components/icons/TaskAltIcon.js +7 -0
  8. package/es/components/icons/UnsubscribeIcon.d.ts +3 -0
  9. package/es/components/icons/UnsubscribeIcon.js +7 -0
  10. package/es/components/icons/index.d.ts +2 -0
  11. package/es/components/icons/index.js +2 -0
  12. package/es/components/molecules/AddDynamicContent/components/DisplayFormat/DisplayFormat.d.ts +1 -0
  13. package/es/components/molecules/CodeStructure/CodeStructure.d.ts +23 -2
  14. package/es/components/molecules/CodeStructure/CodeStructure.js +136 -26
  15. package/es/components/molecules/CodeStructure/constants.js +2 -2
  16. package/es/components/molecules/CodeStructure/styled.d.ts +3 -0
  17. package/es/components/molecules/CodeStructure/styled.js +6 -0
  18. package/es/components/molecules/CodeStructure/type.d.ts +2 -2
  19. package/es/components/molecules/CodeStructure/type.js +2 -2
  20. package/es/components/molecules/CodeStructure/utils.d.ts +12 -2
  21. package/es/components/molecules/CodeStructure/utils.js +5 -3
  22. package/es/components/molecules/DrawerDetail/DrawerDetail.js +10 -5
  23. package/es/components/molecules/DrawerDetail/types.d.ts +1 -0
  24. package/es/components/molecules/Dropdown/style.scss +6 -4
  25. package/es/components/molecules/EditingListV2/EditingList.d.ts +2 -0
  26. package/es/components/molecules/EditingListV2/EditingList.js +17 -0
  27. package/es/components/molecules/EditingListV2/components/List/List.d.ts +9 -0
  28. package/es/components/molecules/EditingListV2/components/List/List.js +42 -0
  29. package/es/components/molecules/EditingListV2/components/List/index.d.ts +1 -0
  30. package/es/components/molecules/EditingListV2/components/List/index.js +1 -0
  31. package/es/components/molecules/EditingListV2/components/Loadable.d.ts +8 -0
  32. package/es/components/molecules/EditingListV2/components/Loadable.js +2 -0
  33. package/es/components/molecules/EditingListV2/components/Popover/Popover.d.ts +11 -0
  34. package/es/components/molecules/EditingListV2/components/Popover/Popover.js +10 -0
  35. package/es/components/molecules/EditingListV2/components/Popover/index.d.ts +1 -0
  36. package/es/components/molecules/EditingListV2/components/Popover/index.js +1 -0
  37. package/es/components/molecules/EditingListV2/components/index.d.ts +3 -0
  38. package/es/components/molecules/EditingListV2/components/index.js +3 -0
  39. package/es/components/molecules/EditingListV2/index.d.ts +2 -0
  40. package/es/components/molecules/EditingListV2/index.js +1 -0
  41. package/es/components/molecules/EditingListV2/types.d.ts +19 -0
  42. package/es/components/molecules/EditingListV2/types.js +1 -0
  43. package/es/components/molecules/EditingListV2/utils.d.ts +27 -0
  44. package/es/components/molecules/EditingListV2/utils.js +28 -0
  45. package/es/components/molecules/InputSelectAttribute/index.js +5 -2
  46. package/es/components/molecules/SearchPopover/components/PopoverAddField/PopoverAddField.js +2 -2
  47. package/es/components/molecules/SearchPopover/components/PopoverSelect/PopoverSelect.js +4 -4
  48. package/es/components/molecules/SearchPopover/types.d.ts +1 -0
  49. package/es/components/molecules/TagifyInput/TagifyInput.js +5 -3
  50. package/es/components/molecules/index.d.ts +1 -0
  51. package/es/components/molecules/index.js +1 -0
  52. package/es/components/organism/TicketEditorV2/Content.d.ts +27 -0
  53. package/es/components/organism/TicketEditorV2/Content.js +296 -0
  54. package/es/components/organism/TicketEditorV2/Service.d.ts +49 -0
  55. package/es/components/organism/TicketEditorV2/Service.js +58 -0
  56. package/es/components/organism/TicketEditorV2/TicketEditorV2.d.ts +20 -0
  57. package/es/components/organism/TicketEditorV2/TicketEditorV2.js +124 -0
  58. package/es/components/organism/TicketEditorV2/components/DropdownComponent.d.ts +9 -0
  59. package/es/components/organism/TicketEditorV2/components/DropdownComponent.js +45 -0
  60. package/es/components/organism/TicketEditorV2/components/Message.d.ts +2 -0
  61. package/es/components/organism/TicketEditorV2/components/Message.js +31 -0
  62. package/es/components/organism/TicketEditorV2/components/MessageComponent.d.ts +10 -0
  63. package/es/components/organism/TicketEditorV2/components/MessageComponent.js +64 -0
  64. package/es/components/organism/TicketEditorV2/components/icons/AddTicketIcon.d.ts +2 -0
  65. package/es/components/organism/TicketEditorV2/components/icons/AddTicketIcon.js +5 -0
  66. package/es/components/organism/TicketEditorV2/components/icons/TicketIcon.d.ts +2 -0
  67. package/es/components/organism/TicketEditorV2/components/icons/TicketIcon.js +5 -0
  68. package/es/components/organism/TicketEditorV2/constant.d.ts +17 -0
  69. package/es/components/organism/TicketEditorV2/constant.js +17 -0
  70. package/es/components/organism/TicketEditorV2/constants/index.d.ts +1 -0
  71. package/es/components/organism/TicketEditorV2/constants/index.js +1 -0
  72. package/es/components/organism/TicketEditorV2/constants/queryKeys.d.ts +5 -0
  73. package/es/components/organism/TicketEditorV2/constants/queryKeys.js +5 -0
  74. package/es/components/organism/TicketEditorV2/index.d.ts +1 -0
  75. package/es/components/organism/TicketEditorV2/index.js +1 -0
  76. package/es/components/organism/TicketEditorV2/queries/index.d.ts +3 -0
  77. package/es/components/organism/TicketEditorV2/queries/index.js +3 -0
  78. package/es/components/organism/TicketEditorV2/queries/useGetDetailTicket.d.ts +12 -0
  79. package/es/components/organism/TicketEditorV2/queries/useGetDetailTicket.js +14 -0
  80. package/es/components/organism/TicketEditorV2/queries/useGetListComments.d.ts +13 -0
  81. package/es/components/organism/TicketEditorV2/queries/useGetListComments.js +18 -0
  82. package/es/components/organism/TicketEditorV2/queries/useGetListUser.d.ts +11 -0
  83. package/es/components/organism/TicketEditorV2/queries/useGetListUser.js +14 -0
  84. package/es/components/organism/TicketEditorV2/styled.d.ts +54 -0
  85. package/es/components/organism/TicketEditorV2/styled.js +871 -0
  86. package/es/components/organism/TicketEditorV2/util.d.ts +46 -0
  87. package/es/components/organism/TicketEditorV2/util.js +408 -0
  88. package/es/components/organism/index.d.ts +1 -0
  89. package/es/components/organism/index.js +1 -0
  90. package/es/components/template/TemplateListing/Loadable.d.ts +1 -0
  91. package/package.json +2 -2
@@ -0,0 +1,296 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /* eslint-disable jsx-a11y/label-has-associated-control */
3
+ /* eslint-disable no-multi-str */
4
+ import { useMemo, useEffect, useRef, useState } from 'react';
5
+ import { Editor } from '@tinymce/tinymce-react';
6
+ import { Helmet } from 'react-helmet';
7
+ import DropdownComponent from './components/DropdownComponent';
8
+ import MessageComponent from './components/MessageComponent';
9
+ import { Spin, Tooltip, Icon, Button, SelectAccount } from '@antscorp/antsomi-ui/es/components';
10
+ import Service from './Service';
11
+ import { WrapperContent, WrapperContentInput, WrapperEditor, WrapperIconEditor, WrapperInputFile, WrapperLable, WrapperLeftContent, WrapperLinkItemFiles, WrapperMessageContent, WrapperRightContent, WrapperTextEdit, WrapperTextInput, } from './styled';
12
+ import { formatAccountId, formatDatarender, handleValidateContent } from './util';
13
+ const initValueInput = {
14
+ originTitle: 'Create new ticket',
15
+ title: '',
16
+ feature: {},
17
+ ticketType: {},
18
+ priority: {},
19
+ category: {},
20
+ ownerId: [],
21
+ followers: [],
22
+ message: '',
23
+ files: [],
24
+ isChanged: false,
25
+ referenceUrl: window.location.href,
26
+ };
27
+ const Content = ({ apiKey, domain, portalId, token, action, ticketId, listUsers, domainTicket, config, ticketDetails, listComment, userId, fetchgetTicketComments, isLoadingComment, isLoadingDetails, isLoadingDataSouce, accountManage, timeZone, isLoadingSelectedAccount, accountEdit, initOwnerId, isAllAccount, dataSelectInput, setDataSelectInput, }) => {
28
+ const [isOpenToast, setIsOpenToast] = useState({
29
+ isOpen: false,
30
+ status: 'error',
31
+ messages: '',
32
+ });
33
+ const [textValue, setTextValue] = useState('');
34
+ const [isEmptyField, setIsEmptyField] = useState(false);
35
+ const [dataSelects, setDataSelect] = useState(dataSelectInput);
36
+ const [isLoading, setIsLoading] = useState(false);
37
+ const [isLoadingUpload, setIsLoadingUpload] = useState(false);
38
+ const [isLoadingFollower, setIsLoadingFollower] = useState(false);
39
+ const [valueInput, setValueInput] = useState(initValueInput);
40
+ const [errFile, setErrFile] = useState({
41
+ isError: false,
42
+ message: '',
43
+ });
44
+ const isUpdate = action === 'edit' && ticketId;
45
+ const valueInputRef = useRef(valueInput);
46
+ valueInputRef.current = valueInput;
47
+ const updateValueInput = value => {
48
+ setValueInput(prev => ({
49
+ ...prev,
50
+ ...value,
51
+ isChanged: true,
52
+ }));
53
+ };
54
+ const handleOnchangeInput = e => {
55
+ const { name, value } = e.target;
56
+ updateValueInput({
57
+ [name]: value,
58
+ });
59
+ };
60
+ useEffect(() => {
61
+ if (!isUpdate) {
62
+ const newFollowers = [];
63
+ let newOwnerIds = [];
64
+ if (accountManage?.length > 0 && listUsers) {
65
+ accountManage?.forEach(acc => {
66
+ listUsers.forEach(user => {
67
+ if (acc === user.userId) {
68
+ newFollowers.push(user);
69
+ }
70
+ });
71
+ });
72
+ }
73
+ if ((!isAllAccount || accountEdit !== 4) &&
74
+ listUsers?.length > 0 &&
75
+ (initOwnerId || userId)) {
76
+ newOwnerIds = listUsers?.filter(user => user.userId === Number(initOwnerId || userId));
77
+ }
78
+ updateValueInput({ ownerId: newOwnerIds, followers: newFollowers });
79
+ }
80
+ }, [isUpdate, accountManage, listUsers, accountEdit]);
81
+ const browserTitle = useMemo(() => {
82
+ if (valueInput.title && valueInput.title.trim()) {
83
+ return valueInput.title;
84
+ }
85
+ return valueInput.originTitle;
86
+ }, [valueInput.title, valueInput.originTitle]);
87
+ const getCustomFields = () => {
88
+ if (dataSelects && dataSelects.length)
89
+ return;
90
+ Service.tickets.callApi
91
+ .getCustomFields({}, domainTicket, token, config, userId, 'get-custom-fields')
92
+ .then(res => {
93
+ if (res.code === 200) {
94
+ setDataSelect(res?.data?.fields);
95
+ setDataSelectInput(res?.data?.fields);
96
+ }
97
+ })
98
+ .catch(err => {
99
+ // console.log('err ===>', err)
100
+ });
101
+ };
102
+ const fetchUpdateComment = params => {
103
+ Service.tickets.callApi
104
+ .updateComment(params, domainTicket, token, config, userId, 'create-ticket-comment', ticketId)
105
+ .then(res => {
106
+ if (res.code === 200) {
107
+ fetchgetTicketComments(ticketId);
108
+ updateValueInput({ message: '', files: [] });
109
+ setTextValue('');
110
+ // handleCloseDrawer();
111
+ }
112
+ })
113
+ .finally(() => {
114
+ setIsLoading(false);
115
+ });
116
+ };
117
+ const fetchUpdateFollwers = params => {
118
+ setIsLoadingFollower(true);
119
+ Service.tickets.callApi
120
+ .updateFollowers(params, domainTicket, token, config, userId, ticketId)
121
+ .then(res => {
122
+ setIsLoadingFollower(false);
123
+ })
124
+ .catch(err => {
125
+ setIsLoadingFollower(false);
126
+ });
127
+ };
128
+ useEffect(() => {
129
+ if (Object.keys(ticketDetails)?.length &&
130
+ isUpdate &&
131
+ listUsers?.length &&
132
+ dataSelects?.length) {
133
+ const { category, feature, followers, ownerId, priority, ticketType, title, referenceUrl, ...rests } = formatDatarender(ticketDetails, dataSelects, listUsers);
134
+ if (ownerId?.length > 0) {
135
+ updateValueInput({
136
+ category,
137
+ feature,
138
+ followers,
139
+ ownerId,
140
+ priority,
141
+ ticketType,
142
+ title,
143
+ referenceUrl,
144
+ originTitle: title,
145
+ });
146
+ }
147
+ }
148
+ }, [ticketDetails, dataSelects, listUsers]);
149
+ useEffect(() => {
150
+ setIsLoading(true);
151
+ getCustomFields();
152
+ setTimeout(() => {
153
+ setIsLoading(false);
154
+ }, 1000);
155
+ }, []);
156
+ const handleEditorChange = content => {
157
+ setTextValue(content);
158
+ updateValueInput({ message: content });
159
+ setIsLoadingUpload(content.includes('<img src="data:image/png;base64'));
160
+ };
161
+ const handleUpdateFollowers = arrFolowers => {
162
+ const params = {
163
+ followers: [],
164
+ };
165
+ if (arrFolowers?.length) {
166
+ params.followers = arrFolowers;
167
+ }
168
+ fetchUpdateFollwers(params);
169
+ };
170
+ const handleUpdateComment = () => {
171
+ setIsLoading(true);
172
+ const params = {
173
+ followers: [],
174
+ submitterId: null,
175
+ ownerId: null,
176
+ attachments: [],
177
+ message: '',
178
+ };
179
+ if (valueInput?.followers?.length) {
180
+ params.followers = formatAccountId(valueInput?.followers);
181
+ }
182
+ if (valueInput?.files?.length > 0) {
183
+ params.attachments = valueInput?.files?.map((file) => file.token);
184
+ }
185
+ params.submitterId = userId;
186
+ params.ownerId = Number(valueInput?.ownerId[0]?.userId);
187
+ params.message = valueInput?.message;
188
+ fetchUpdateComment(params);
189
+ handleUpdateFollowers(valueInput?.followers?.map((fol) => fol.userId));
190
+ };
191
+ const handleUploadFile = params => {
192
+ setIsLoading(true);
193
+ Service.tickets.callApi
194
+ .upload(params, domainTicket, token, config, userId, 'ticket')
195
+ .then(res => {
196
+ if (res.code === 200) {
197
+ updateValueInput({
198
+ files: [...valueInput.files, res.data],
199
+ });
200
+ }
201
+ })
202
+ .finally(() => {
203
+ setIsLoading(false);
204
+ });
205
+ };
206
+ useEffect(() => {
207
+ const timeOut = setTimeout(() => {
208
+ if (isOpenToast.isOpen) {
209
+ setIsOpenToast({ ...isOpenToast, isOpen: false });
210
+ }
211
+ }, 1000);
212
+ return () => {
213
+ clearTimeout(timeOut);
214
+ };
215
+ }, [isOpenToast]);
216
+ const handleOnchangeFile = e => {
217
+ const limitSize = 50 * 1024 * 1024;
218
+ const sizeFile = e.target?.files[0]?.size;
219
+ if (sizeFile >= limitSize) {
220
+ setErrFile({
221
+ isError: true,
222
+ message: '*Maximum upload file size: 50MB',
223
+ });
224
+ }
225
+ else {
226
+ const formData = new FormData();
227
+ formData.append('file', e.target.files[0]);
228
+ const params = {
229
+ data: formData,
230
+ };
231
+ setErrFile({
232
+ isError: false,
233
+ message: '',
234
+ });
235
+ handleUploadFile(params);
236
+ }
237
+ };
238
+ const handleRemoveFile = token => {
239
+ let newListFile = valueInput.files;
240
+ newListFile = newListFile.filter((list) => list?.token !== token);
241
+ updateValueInput({ files: newListFile });
242
+ };
243
+ return (_jsxs("div", { style: { height: '100%' }, children: [_jsxs(Helmet, { children: [_jsx("meta", { charSet: "utf-8" }), _jsx("title", { children: browserTitle })] }), _jsx(Spin, { style: { height: '100vh' }, spinning: isLoading ||
244
+ isLoadingDetails ||
245
+ isLoadingDataSouce ||
246
+ isLoadingFollower ||
247
+ isLoadingSelectedAccount, children: _jsxs(WrapperContent, { style: { height: '100%' }, children: [_jsxs(WrapperLeftContent, { children: [_jsxs(WrapperContentInput, { style: { alignItems: 'flex-start' }, children: [_jsxs(WrapperLable, { children: ["Owner", _jsx("span", { style: { color: '#ff0000' }, children: "*" })] }), _jsxs("div", { children: [_jsx(SelectAccount, { type: "default", initData: (valueInput?.ownerId || []).map((item) => item.userId), nameKey: "userName", userIdKey: "userId", users: listUsers, isViewMode: isUpdate || !isAllAccount || accountEdit !== 4, onChange: (_, users) => updateValueInput({ ownerId: users }), onlyOne: true }), isEmptyField && !valueInput?.ownerId?.length && (_jsx("div", { className: "error-message", children: "*This field can't be empty" }))] })] }), _jsxs(WrapperContentInput, { style: { marginTop: '15px', alignItems: 'flex-start' }, children: [_jsx(WrapperLable, { children: "Follower(s)" }), _jsx(SelectAccount, { type: "default", initData: [
248
+ ...accountManage,
249
+ ...(valueInput?.followers || []).map((item) => item.userId),
250
+ ], nameKey: "userName", userIdKey: "userId", users: listUsers, disabledAccount: accountManage, onChange: (_, followers) => updateValueInput({ followers }) })] }), dataSelects?.map((data) => (_jsxs(WrapperContentInput, { style: { marginTop: '15px' }, children: [_jsx(WrapperLable, { children: data.title }), _jsx("div", { style: { flex: 1 }, children: isUpdate ? (_jsx(WrapperTextEdit, { children: !valueInput[data?.value]?.name?.length
251
+ ? '--'
252
+ : valueInput[data?.value]?.name })) : (_jsx(DropdownComponent, { data: data.field_options, setValueInput: updateValueInput, valueInput: valueInput, type: data.value, isUpdate: isUpdate, title: data.title })) })] }, data.id))), _jsxs(WrapperContentInput, { style: { marginTop: '15px' }, children: [_jsx(WrapperLable, { htmlFor: "referenceUrl", children: "Reference URL" }), isUpdate ? (valueInput.referenceUrl ? (_jsx(Tooltip, { title: valueInput.referenceUrl, placement: "top", children: _jsx(WrapperTextEdit, { color: "#005fb8", href: valueInput.referenceUrl, target: "_blank", children: valueInput.referenceUrl }) })) : (_jsx(WrapperTextEdit, { color: "#005fb8", href: valueInput.referenceUrl, target: "_blank", children: valueInput.referenceUrl }))) : (_jsx(WrapperTextInput, { placeholder: "Reference URL", id: "referenceUrl",
253
+ // width="300px"
254
+ onChange: handleOnchangeInput, name: "referenceUrl", value: valueInput.referenceUrl }))] })] }), _jsxs(WrapperRightContent, { children: [_jsxs(WrapperEditor, { children: [_jsxs("div", { children: [_jsx(Editor, { apiKey: apiKey, value: textValue, init: {
255
+ height: 238,
256
+ width: '100%',
257
+ max_height: 800,
258
+ max_width: 800,
259
+ menubar: false,
260
+ plugins: [
261
+ 'advlist autolink lists link tinydrive image emoticons charmap print preview anchor',
262
+ 'searchreplace visualblocks code fullscreen',
263
+ 'insertdatetime media paste code help wordcount ', //
264
+ ],
265
+ toolbar: 'formatselect | bold italic underline strikethrough code | image emoticons | \
266
+ forecolor backcolor preview link |\
267
+ alignleft aligncenter alignright alignjustify outdent indent |\
268
+ numlist bullist checklist undo redo',
269
+ tinydrive_token_provider: `//${domain}/hub/thirdparty-services/v2.0/tinymce?portalId=${portalId}&token=${token}`,
270
+ skin: 'snow',
271
+ toolbar_mode: 'sliding',
272
+ content_css: false,
273
+ branding: false,
274
+ resize: false,
275
+ statusbar: false,
276
+ setup(editor) {
277
+ editor.on('init', e => {
278
+ editor.getBody().style.fontSize = '12px';
279
+ });
280
+ },
281
+ placeholder: 'Enter your comment...',
282
+ entity_encoding: 'raw',
283
+ paste_data_images: true,
284
+ },
285
+ // disabled={!!props.disabled}
286
+ // outputFormat='text'
287
+ onEditorChange: handleEditorChange }), _jsxs("div", { children: [valueInput.files?.length > 0 && (_jsx(WrapperLinkItemFiles, { children: valueInput.files?.map((file) => (_jsxs("div", { className: "file-item", children: [_jsxs("div", { className: "file-name-group", children: [_jsx(Icon, { className: "file-icon", type: "icon-ants-attachment" }), _jsx(Tooltip, { title: file?.file_name, children: _jsx("span", { className: "file-name", children: file?.file_name }) })] }), _jsx(Icon, { onClick: () => handleRemoveFile(file?.token), className: "remove-btn", type: "icon-ants-remove-slim" })] }, file?.token))) })), _jsxs(WrapperIconEditor, { borderTop: !!valueInput.files?.length, children: [_jsxs(WrapperInputFile, { children: [_jsx("label", { htmlFor: "fileImage", className: "upload-wrapper-label", children: _jsx(Icon, { type: "icon-ants-attachment", className: "upload-icon" }) }), _jsx("input", { type: "file", style: { position: 'absolute', top: 0, right: 0, display: 'none' }, name: "fileImage", id: "fileImage", onChange: handleOnchangeFile })] }), isUpdate && (_jsx(Button, { type: "primary", disabled: !handleValidateContent(textValue) || isLoadingUpload, className: "reply-btn", style: {
288
+ background: `${!handleValidateContent(textValue) || isLoadingUpload
289
+ ? '#ccc'
290
+ : '#1f5fac'}`,
291
+ }, onClick: handleUpdateComment, loading: isLoadingUpload, children: "Reply" }))] })] })] }), errFile.isError ? (_jsx("div", { className: "error-message", children: errFile.message })) : (isEmptyField &&
292
+ !valueInput?.message && (_jsx("div", { className: "error-message", children: "* This field can't be empty" })))] }), isUpdate && (_jsx(Spin, { spinning: isLoadingComment, children: _jsx(WrapperMessageContent, { children: listComment?.map(comment => (_jsx(MessageComponent, { toUser: comment?.toUser, fromUser: comment?.fromUser, followers: comment?.followers,
293
+ // mailFollower={comment?.mailFollower}
294
+ message: comment?.message, date: comment?.createdDate, attachments: comment?.attachments, timeZone: timeZone }, comment?.id))) }) }))] })] }) })] }));
295
+ };
296
+ export default Content;
@@ -0,0 +1,49 @@
1
+ declare const API: {
2
+ lookupInfo: {
3
+ callApi: {
4
+ c_user_id: (params: any, domain: any, token: any, config: any, userId: any) => Promise<{
5
+ code: number;
6
+ codeMessage: any;
7
+ messageAPI: any;
8
+ data: any;
9
+ } | {
10
+ code: number;
11
+ codeMessage: string;
12
+ data: any;
13
+ messageAPI?: undefined;
14
+ }>;
15
+ };
16
+ };
17
+ tickets: {
18
+ callApi: {
19
+ createTicket: (params: any, domain: any, token: any, config: any, userId: any) => Promise<{
20
+ code: number;
21
+ codeMessage: any;
22
+ messageAPI: any;
23
+ data: any;
24
+ } | {
25
+ code: number;
26
+ codeMessage: string;
27
+ data: any;
28
+ messageAPI?: undefined;
29
+ }>;
30
+ getCustomFields: (params: any, domain: any, token: any, config: any, userId: any, type: any) => Promise<any>;
31
+ getDetailsTicket: (params: any, domain: any, token: any, config: any, userId: any, ticketId: any, type?: string) => Promise<any>;
32
+ getListComment: (params: any, domain: any, token: any, config: any, userId: any, type: any, ticketId: any) => Promise<any>;
33
+ updateComment: (params: any, domain: any, token: any, config: any, userId: any, type: any, ticketId: any) => Promise<any>;
34
+ updateFollowers: (params: any, domain: any, token: any, config: any, userId: any, ticketId: any) => Promise<any>;
35
+ upload: (params: any, domain: any, token: any, config: any, userId: any, type: any) => Promise<any>;
36
+ };
37
+ };
38
+ accounts: {
39
+ callApi: {
40
+ getAccountManage: (params: any, domain: any, token: any, config: any, userId: any, type: any) => Promise<any>;
41
+ };
42
+ };
43
+ permission: {
44
+ callApi: {
45
+ getList: (params: any, domain: any, token: any, config: any, userId: any, type: any, ownerId: any) => Promise<any>;
46
+ };
47
+ };
48
+ };
49
+ export default API;
@@ -0,0 +1,58 @@
1
+ import { callApiWithAuth, getEntriesV2 } from './util';
2
+ const API = {
3
+ lookupInfo: {
4
+ callApi: {
5
+ c_user_id: (params, domain, token, config, userId) => callApiWithAuth(`hub/toolkit/v2.0/selector/users/listing`, 'GET', null, domain, config, token, userId).then(res => {
6
+ const data = getEntriesV2(res, 0);
7
+ // dataBackup[params.objectName] = data;
8
+ return data;
9
+ }),
10
+ },
11
+ },
12
+ tickets: {
13
+ callApi: {
14
+ createTicket: (params, domain, token, config, userId) => callApiWithAuth(`api/ticket/index`, 'POST', { ...params }, domain, config, token, userId, true).then(res => {
15
+ const data = getEntriesV2(res, 0);
16
+ // dataBackup[params.objectName] = data;
17
+ return data;
18
+ }),
19
+ getCustomFields: (params, domain, token, config, userId, type) => callApiWithAuth(`api/ticket/index`, 'get', { ...params }, domain, config, token, userId, true, type).then(res =>
20
+ // const data = getEntriesV2(res, 0);
21
+ // dataBackup[params.objectName] = data;
22
+ res.data),
23
+ getDetailsTicket: (params, domain, token, config, userId, ticketId, type = '') => callApiWithAuth(`api/ticket/index/${ticketId}`, 'get', { ...params }, domain, config, token, userId, true, type).then(res =>
24
+ // const data = getEntriesV2(res, 0);
25
+ // dataBackup[params.objectName] = data;
26
+ res.data),
27
+ getListComment: (params, domain, token, config, userId, type, ticketId) => callApiWithAuth(`api/ticket/index/${ticketId}`, 'get', { ...params }, domain, config, token, userId, true, type).then(res =>
28
+ // const data = getEntriesV2(res, 0);
29
+ // dataBackup[params.objectName] = data;
30
+ res.data),
31
+ updateComment: (params, domain, token, config, userId, type, ticketId) => callApiWithAuth(`api/ticket/index/${ticketId}`, 'put', { ...params }, domain, config, token, userId, true, type).then(res =>
32
+ // const data = getEntriesV2(res, 0);
33
+ // dataBackup[params.objectName] = data;
34
+ res.data),
35
+ updateFollowers: (params, domain, token, config, userId, ticketId) => callApiWithAuth(`api/ticket/index/${ticketId}`, 'put', { ...params }, domain, config, token, userId, true).then(res =>
36
+ // const data = getEntriesV2(res, 0);
37
+ // dataBackup[params.objectName] = data;
38
+ res.data),
39
+ upload: (params, domain, token, config, userId, type) => callApiWithAuth(`api/upload/index`, 'post', params.data, domain, config, token, userId, true, type).then(res =>
40
+ // const data = getEntriesV2(res, 0);
41
+ // dataBackup[params.objectName] = data;
42
+ res.data),
43
+ },
44
+ },
45
+ accounts: {
46
+ callApi: {
47
+ getAccountManage: (params, domain, token, config, userId, type) => callApiWithAuth(`api/network/index/${config.api_pid}`, 'GET', { ...params }, domain, config, token, userId, false, type, true).then(res => res.data),
48
+ },
49
+ },
50
+ permission: {
51
+ callApi: {
52
+ getList: (params, domain, token, config, userId, type, ownerId) =>
53
+ // console.log({params, domain, token, config,userId, type})
54
+ callApiWithAuth(`api/privilege/index`, 'GET', { ...params, ownerId }, domain, config, token, userId, false, type, false, true).then(res => res.data),
55
+ },
56
+ },
57
+ };
58
+ export default API;
@@ -0,0 +1,20 @@
1
+ export declare const TicketEditorV2: {
2
+ (props: any): import("react/jsx-runtime").JSX.Element;
3
+ defaultProps: {
4
+ apiKey: string;
5
+ portalId: string;
6
+ token: string;
7
+ domain: string;
8
+ action: string;
9
+ config: {};
10
+ userId: string;
11
+ ownerId: string;
12
+ domainTicket: string;
13
+ ticketId: string;
14
+ domainAccount: string;
15
+ domainPermission: string;
16
+ appCode: string;
17
+ menuCode: string;
18
+ fullParent: boolean;
19
+ };
20
+ };
@@ -0,0 +1,124 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
3
+ import Content from './Content';
4
+ import Service from './Service';
5
+ import { Button, Modal } from '@antscorp/antsomi-ui/es/components/';
6
+ import { WrapperModalHeader, TicketEditorWrapper } from './styled';
7
+ import { useGetDetailTicket, useGetListComments, useGetListUser } from './queries';
8
+ const defaultProps = {
9
+ apiKey: '',
10
+ portalId: '',
11
+ token: '',
12
+ domain: '',
13
+ action: '',
14
+ config: {},
15
+ userId: '',
16
+ ownerId: '',
17
+ domainTicket: '',
18
+ ticketId: '',
19
+ domainAccount: '',
20
+ domainPermission: '',
21
+ appCode: 'TICKET_MANAGEMENT',
22
+ menuCode: 'TICKET',
23
+ fullParent: false,
24
+ };
25
+ export const TicketEditorV2 = props => {
26
+ const { apiKey, portalId, token, domain, action, config: propsConfig, userId, ownerId, domainTicket, ticketId, domainAccount, domainPermission, appCode, menuCode, fullParent, } = props;
27
+ const { ticketDetails, isFetching: isFetchingDetails } = useGetDetailTicket({
28
+ ticketId,
29
+ domainTicket,
30
+ token,
31
+ config: propsConfig,
32
+ userId,
33
+ });
34
+ const { listComments, isFetchingComments } = useGetListComments({
35
+ domainTicket,
36
+ token,
37
+ config: propsConfig,
38
+ userId,
39
+ ticketId,
40
+ enabled: !!ticketId || action !== 'create',
41
+ });
42
+ const { listUsers, isFetchingUsers } = useGetListUser({
43
+ domainAccount: domain,
44
+ token,
45
+ config: propsConfig,
46
+ userId,
47
+ });
48
+ const [isOpenModal, setIsOpenModal] = useState(false);
49
+ const [isLoadingSelectedAccount, setIsLoadingSelectedAccount] = useState(false);
50
+ const [accountEdit, setAccountEdit] = useState(null);
51
+ const [accountManage, setAccountManage] = useState([]);
52
+ const [timeZone, setTimeZone] = useState('');
53
+ const [dataSelectInput, setDataSelectInput] = useState([]);
54
+ const config = typeof propsConfig === 'string' ? JSON.parse(atob(propsConfig)) : propsConfig;
55
+ const isAllAccount = !ownerId;
56
+ const fetchAccountPermission = () => {
57
+ setIsLoadingSelectedAccount(true);
58
+ const params = {
59
+ appCode,
60
+ menuCode,
61
+ fullParent,
62
+ };
63
+ Service.permission.callApi
64
+ .getList(params, domainPermission, token, config, userId, 'list-menu', ownerId)
65
+ .then(res => {
66
+ setIsLoadingSelectedAccount(false);
67
+ if (res.code === 200) {
68
+ setAccountEdit(res?.data[0]?.selected_edit);
69
+ }
70
+ })
71
+ .catch(err => {
72
+ setIsLoadingSelectedAccount(false);
73
+ });
74
+ };
75
+ const fetchAccountManage = () => {
76
+ Service.accounts.callApi
77
+ .getAccountManage({}, domainAccount, token, config, userId, 'account')
78
+ .then(res => {
79
+ if (res.code === 200) {
80
+ const listIds = res?.data?.infoNetwork?.accountManager?.map(item => item.user_id);
81
+ setAccountManage(listIds);
82
+ setTimeZone(res?.data?.infoNetwork?.timezone);
83
+ }
84
+ })
85
+ .catch(_err => { });
86
+ };
87
+ const fetchgetTicketComments = ticketId => {
88
+ Service.tickets.callApi
89
+ .getListComment({}, domainTicket, token, config, userId, 'get-ticket-comments', ticketId)
90
+ .then(res => {
91
+ if (res.code === 200) {
92
+ }
93
+ else {
94
+ }
95
+ })
96
+ .finally(() => { });
97
+ };
98
+ useEffect(() => {
99
+ fetchAccountManage();
100
+ fetchAccountPermission();
101
+ }, []);
102
+ const handleConfirmModal = () => {
103
+ setIsOpenModal(false);
104
+ };
105
+ return (_jsxs(TicketEditorWrapper, { children: [_jsx(Content, { apiKey: apiKey, portalId: portalId, token: token, domain: domain, action: action, listUsers: listUsers, domainTicket: domainTicket, config: config, ticketDetails: ticketDetails, listComment: listComments, ticketId: ticketId, userId: userId, fetchgetTicketComments: fetchgetTicketComments, isLoadingComment: isFetchingComments, isLoadingDetails: isFetchingDetails, isLoadingDataSouce: isFetchingUsers, accountManage: accountManage, timeZone: timeZone, isLoadingSelectedAccount: isLoadingSelectedAccount, accountEdit: accountEdit, initOwnerId: ownerId, isAllAccount: isAllAccount, dataSelectInput: dataSelectInput, setDataSelectInput: setDataSelectInput }), _jsx(Modal, { open: isOpenModal, onCancel: () => setIsOpenModal(false), className: "modal", children: _jsxs("div", { className: "wrapperBody", children: [_jsx(WrapperModalHeader, { children: "Confirm deletion of this ticket" }), _jsx("div", { className: "modalBody", children: _jsx("span", { style: { fontSize: '12px', color: '#000' }, children: "Once you confirm cancel, this ticket will NOT be saved." }) }), _jsxs("div", { className: "modalFooter", children: [_jsx(Button, { style: {
106
+ height: '28px',
107
+ background: '#1f5fac',
108
+ color: '#fff',
109
+ fontSize: '12px',
110
+ borderRadius: '3px',
111
+ fontWeight: 'bold',
112
+ textTransform: 'capitalize',
113
+ }, onClick: handleConfirmModal, children: "Confirm" }), _jsx(Button, { style: {
114
+ height: '28px',
115
+ background: '#fff',
116
+ color: '#005fb8',
117
+ fontSize: '12px',
118
+ borderRadius: '3px',
119
+ fontWeight: 'bold',
120
+ textTransform: 'capitalize',
121
+ border: '1px solid #edeef7',
122
+ }, onClick: () => setIsOpenModal(false), children: "Cancel" })] })] }) })] }));
123
+ };
124
+ TicketEditorV2.defaultProps = defaultProps;
@@ -0,0 +1,9 @@
1
+ declare const DropdownComponent: ({ data, setValueInput, valueInput, type, isUpdate, title }: {
2
+ data: any;
3
+ setValueInput: any;
4
+ valueInput: any;
5
+ type: any;
6
+ isUpdate: any;
7
+ title: any;
8
+ }) => import("react/jsx-runtime").JSX.Element;
9
+ export default DropdownComponent;
@@ -0,0 +1,45 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useRef, useState } from 'react';
3
+ import { Select } from '@antscorp/antsomi-ui/es/components';
4
+ import { getObjectPropSafely } from '../util';
5
+ const EMPTY_VALUE = '____';
6
+ const DropdownComponent = ({ data, setValueInput, valueInput, type, isUpdate, title }) => {
7
+ const [dropDownOpen, setDropdownOpen] = useState(false);
8
+ const [labelSelected, setLabelSelected] = useState('-');
9
+ const dropDonwRef = useRef();
10
+ const handleOnchangeSelect = (item, type) => {
11
+ setLabelSelected(item.name);
12
+ setDropdownOpen(false);
13
+ setValueInput({
14
+ ...valueInput,
15
+ [type]: {
16
+ ...item,
17
+ value: item.value === EMPTY_VALUE ? '' : item.value,
18
+ },
19
+ });
20
+ };
21
+ const renderData = useMemo(() => (!isUpdate ? [{ name: '-', value: EMPTY_VALUE }, ...data] : data), [data, isUpdate]);
22
+ const handleHideDropdown = event => {
23
+ if (event.key === 'Escape') {
24
+ setDropdownOpen(false);
25
+ }
26
+ };
27
+ const handleClickOutside = event => {
28
+ if (dropDonwRef.current && !dropDonwRef.current.contains(event.target)) {
29
+ setDropdownOpen(false);
30
+ }
31
+ };
32
+ useEffect(() => {
33
+ document.addEventListener('keydown', handleHideDropdown, true);
34
+ document.addEventListener('click', handleClickOutside, true);
35
+ return () => {
36
+ document.removeEventListener('keydown', handleHideDropdown, true);
37
+ document.removeEventListener('click', handleClickOutside, true);
38
+ };
39
+ });
40
+ return (_jsx(Select, { value: getObjectPropSafely(() => valueInput[type].value) || EMPTY_VALUE, options: renderData?.map(item => ({
41
+ ...item,
42
+ label: item.name,
43
+ })) || [], onChange: (_, item) => handleOnchangeSelect(item, type) }));
44
+ };
45
+ export default DropdownComponent;
@@ -0,0 +1,2 @@
1
+ declare const Message: (props: any) => false | import("react/jsx-runtime").JSX.Element;
2
+ export default Message;
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
3
+ import { WrapperMessage } from '../styled';
4
+ import { Icon } from '@antscorp/antsomi-ui/es/components';
5
+ const Message = props => {
6
+ const { isOpen = false, deplay = 1000, message = 'Success', subtitle = 'Created', type = 'success', } = props;
7
+ const [isOpenState, setIsOpenState] = useState(true);
8
+ useEffect(() => {
9
+ if (isOpen !== isOpenState) {
10
+ setIsOpenState(isOpen);
11
+ }
12
+ if (isOpen) {
13
+ const timeOut = setTimeout(() => {
14
+ setIsOpenState(false);
15
+ }, deplay);
16
+ return () => {
17
+ clearTimeout(timeOut);
18
+ };
19
+ }
20
+ }, [isOpen]);
21
+ return (isOpenState && (_jsx(WrapperMessage, { className: "container-content", children: _jsxs("div", { className: "floating", style: { color: '#008634' }, children: [_jsx("span", { style: {
22
+ background: `${type === 'success' ? '#008634' : 'red'}`,
23
+ borderRadius: '50%',
24
+ height: '18px',
25
+ width: '18px',
26
+ textAlign: 'center',
27
+ marginRight: '16px',
28
+ lineHeight: '22px',
29
+ }, children: _jsx("span", { className: "icon-check", children: _jsx(Icon, { className: "check-icon", type: "icon-ants-check" }) }) }), _jsxs("div", { children: [_jsx("span", { className: "alert__title", children: message }), _jsx("span", { className: "secondary__title", children: subtitle })] }), _jsx("div", { style: { marginLeft: 'auto', cursor: 'pointer' }, onClick: () => setIsOpenState(false), children: _jsx(Icon, { type: "icon-ants-close" }) })] }) })));
30
+ };
31
+ export default Message;
@@ -0,0 +1,10 @@
1
+ declare const MessageComponent: ({ toUser, fromUser, followers, attachments, message, date, timeZone, }: {
2
+ toUser: any;
3
+ fromUser: any;
4
+ followers: any;
5
+ attachments: any;
6
+ message: any;
7
+ date: any;
8
+ timeZone: any;
9
+ }) => import("react/jsx-runtime").JSX.Element;
10
+ export default MessageComponent;