@antscorp/antsomi-ui 2.0.70 → 2.0.71
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.
|
@@ -213,19 +213,17 @@ const Content = ({ portalId, token, action, ticketId, listUsers, domainTicket, d
|
|
|
213
213
|
listUsers?.length &&
|
|
214
214
|
dataSelects?.length) {
|
|
215
215
|
const { category, feature, followers, ownerId, priority, ticketType, title, referenceUrl, ...rests } = formatDatarender(ticketDetails, dataSelects, listUsers);
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
});
|
|
228
|
-
}
|
|
216
|
+
updateValueInput({
|
|
217
|
+
category,
|
|
218
|
+
feature,
|
|
219
|
+
followers,
|
|
220
|
+
ownerId,
|
|
221
|
+
priority,
|
|
222
|
+
ticketType,
|
|
223
|
+
title,
|
|
224
|
+
referenceUrl,
|
|
225
|
+
originTitle: title,
|
|
226
|
+
});
|
|
229
227
|
}
|
|
230
228
|
}, [ticketDetails, dataSelects, listUsers]);
|
|
231
229
|
useEffect(() => {
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
/* eslint-disable react/no-unescaped-entities */
|
|
3
3
|
/* eslint-disable jsx-a11y/label-has-associated-control */
|
|
4
4
|
/* eslint-disable no-multi-str */
|
|
5
5
|
import { useMemo, useEffect, useRef, useState, memo } from 'react';
|
|
6
6
|
import { Helmet } from 'react-helmet';
|
|
7
|
-
import DropdownComponent from './components/DropdownComponent';
|
|
8
7
|
import MessageComponent from './components/MessageComponent';
|
|
9
8
|
import { Spin, Tooltip, Icon, Button, SelectAccount, QuillEditor, } from '@antscorp/antsomi-ui/es/components';
|
|
10
9
|
import Service from './Service';
|
|
11
10
|
import { WrapperContent, WrapperContentInput, WrapperEditor, WrapperIconEditor, WrapperInputFile, WrapperLable, WrapperLeftContent, WrapperLinkItemFiles, WrapperMessageContent, WrapperRightContent, WrapperTextEdit, WrapperTextInput, } from './styled';
|
|
12
|
-
import {
|
|
11
|
+
import { formatDatarender, handleValidateContent } from './util';
|
|
13
12
|
import { get, keyBy } from 'lodash';
|
|
14
13
|
const initValueInput = {
|
|
15
14
|
originTitle: 'Create new ticket',
|
|
@@ -58,25 +57,25 @@ const Content = ({ apiKey, domain, portalId, token, action, ticketId, listUsers,
|
|
|
58
57
|
[name]: value,
|
|
59
58
|
});
|
|
60
59
|
};
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}, [isUpdate, accountManage, listUsers]);
|
|
60
|
+
// useEffect(() => {
|
|
61
|
+
// if (!isUpdate) {
|
|
62
|
+
// const newFollowers: any[] = [];
|
|
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 && listUsers?.length > 0 && (initOwnerId || userId)) {
|
|
74
|
+
// newOwnerIds = listUsers?.filter(user => user.userId === Number(initOwnerId || userId));
|
|
75
|
+
// }
|
|
76
|
+
// updateValueInput({ ownerId: newOwnerIds, followers: newFollowers });
|
|
77
|
+
// }
|
|
78
|
+
// }, [isUpdate, accountManage, listUsers]);
|
|
80
79
|
const browserTitle = useMemo(() => {
|
|
81
80
|
if (valueInput.title && valueInput.title.trim()) {
|
|
82
81
|
return valueInput.title;
|
|
@@ -130,21 +129,19 @@ const Content = ({ apiKey, domain, portalId, token, action, ticketId, listUsers,
|
|
|
130
129
|
listUsers?.length &&
|
|
131
130
|
dataSelects?.length) {
|
|
132
131
|
const { category, feature, followers, ownerId, priority, ticketType, title, referenceUrl, ...rests } = formatDatarender(ticketDetails, dataSelects, listUsers);
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
});
|
|
145
|
-
}
|
|
132
|
+
updateValueInput({
|
|
133
|
+
category,
|
|
134
|
+
feature,
|
|
135
|
+
followers,
|
|
136
|
+
ownerId,
|
|
137
|
+
priority,
|
|
138
|
+
ticketType,
|
|
139
|
+
title,
|
|
140
|
+
referenceUrl,
|
|
141
|
+
originTitle: title,
|
|
142
|
+
});
|
|
146
143
|
}
|
|
147
|
-
}, [ticketDetails,
|
|
144
|
+
}, [ticketDetails, listUsers, dataSelects]);
|
|
148
145
|
useEffect(() => {
|
|
149
146
|
setIsLoading(true);
|
|
150
147
|
getCustomFields();
|
|
@@ -177,7 +174,7 @@ const Content = ({ apiKey, domain, portalId, token, action, ticketId, listUsers,
|
|
|
177
174
|
submitterEmail: '',
|
|
178
175
|
};
|
|
179
176
|
if (valueInput?.followers?.length) {
|
|
180
|
-
params.followers =
|
|
177
|
+
params.followers = valueInput?.followers;
|
|
181
178
|
}
|
|
182
179
|
if (valueInput?.files?.length > 0) {
|
|
183
180
|
params.properties.attachments = valueInput?.files;
|
|
@@ -251,9 +248,14 @@ const Content = ({ apiKey, domain, portalId, token, action, ticketId, listUsers,
|
|
|
251
248
|
}
|
|
252
249
|
return get(ticketDetails, 'submitterEmail', '');
|
|
253
250
|
}, [ticketDetails?.ownerId, listUsers]);
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
251
|
+
const renderOptions = info => {
|
|
252
|
+
const { field_options: fieldOptions } = info;
|
|
253
|
+
const dataSelectOptions = keyBy(fieldOptions, 'value');
|
|
254
|
+
return (_jsxs(WrapperContentInput, { style: { marginTop: '15px' }, children: [_jsx(WrapperLable, { children: info.title }), _jsx("div", { style: { flex: 1 }, children: _jsx(WrapperTextEdit, { children: !ticketDetails[info?.value]
|
|
255
|
+
? '--'
|
|
256
|
+
: dataSelectOptions[ticketDetails[info?.value]]?.name }) })] }, info.id));
|
|
257
|
+
};
|
|
258
|
+
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 || isLoadingDetails || isLoadingDataSouce || isLoadingFollower, 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: [ownerEmail, 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: ticketDetails?.followers || [], nameKey: "userName", userIdKey: "userId", users: listUsers, onChange: (_, followers) => onChangeFollowers(followers) })] }), dataSelects?.map((data) => _jsx(_Fragment, { children: renderOptions(data) })), _jsxs(WrapperContentInput, { style: { marginTop: '15px' }, children: [_jsx(WrapperLable, { htmlFor: "referenceUrl", children: "Reference URL" }), isUpdate ? (ticketDetails.referenceUrl ? (_jsx(Tooltip, { title: ticketDetails.referenceUrl, placement: "top", children: _jsx(WrapperTextEdit, { color: "#005fb8", href: ticketDetails.referenceUrl, target: "_blank", children: ticketDetails.referenceUrl }) })) : (_jsx(WrapperTextEdit, { color: "#005fb8", href: ticketDetails.referenceUrl, target: "_blank", children: ticketDetails.referenceUrl }))) : (_jsx(WrapperTextInput, { placeholder: "Reference URL", id: "referenceUrl",
|
|
257
259
|
// width="300px"
|
|
258
260
|
onChange: handleOnchangeInput, name: "referenceUrl", value: valueInput.referenceUrl }))] })] }), _jsxs(WrapperRightContent, { children: [_jsxs(WrapperEditor, { children: [_jsxs("div", { children: [_jsx(QuillEditor, { value: textValue, uploadService: Service.tickets.callApi.uploadFile({
|
|
259
261
|
domain: domainUpload,
|
|
@@ -333,48 +333,11 @@ export const formatParams = data => {
|
|
|
333
333
|
return params;
|
|
334
334
|
};
|
|
335
335
|
export const formatDatarender = (data, listSelect, listAccount) => {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
if (data?.followers?.length) {
|
|
340
|
-
const newFollowers = [];
|
|
341
|
-
data.followers?.forEach(fol => {
|
|
342
|
-
listAccount.forEach(acc => {
|
|
343
|
-
if (fol === acc.userId) {
|
|
344
|
-
newFollowers.push(acc);
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
});
|
|
348
|
-
data.followers = newFollowers;
|
|
349
|
-
}
|
|
350
|
-
if (data?.priority) {
|
|
351
|
-
const newPriority = listSelect
|
|
352
|
-
?.filter(sel => sel.value === 'priority')[0]
|
|
353
|
-
?.field_options?.filter(opt => opt.value === data.priority);
|
|
354
|
-
[data.priority] = newPriority;
|
|
355
|
-
}
|
|
356
|
-
if (data?.feature) {
|
|
357
|
-
const newFeature = listSelect
|
|
358
|
-
?.filter(sel => sel.value === 'feature')[0]
|
|
359
|
-
?.field_options?.filter(opt => opt.value === data.feature);
|
|
360
|
-
[data.feature] = newFeature;
|
|
361
|
-
}
|
|
362
|
-
if (data?.ticketType) {
|
|
363
|
-
const newTicket = listSelect
|
|
364
|
-
?.filter(sel => sel.value === 'ticketType')[0]
|
|
365
|
-
?.field_options?.filter(opt => opt.value === data.ticketType);
|
|
366
|
-
[data.ticketType] = newTicket;
|
|
367
|
-
}
|
|
368
|
-
if (data?.category) {
|
|
369
|
-
const newCategory = listSelect
|
|
370
|
-
?.filter(sel => sel.value === 'category')[0]
|
|
371
|
-
?.field_options?.filter(opt => opt.value === data.category);
|
|
372
|
-
[data.category] = newCategory;
|
|
373
|
-
}
|
|
374
|
-
// if(data?.files?.length) {
|
|
375
|
-
// params.files = data?.files
|
|
336
|
+
const tmpData = data;
|
|
337
|
+
// if (?.files?.length) {
|
|
338
|
+
// params.files = data?.files;
|
|
376
339
|
// }
|
|
377
|
-
return
|
|
340
|
+
return tmpData;
|
|
378
341
|
};
|
|
379
342
|
export const handleValidateContent = stringHTML => {
|
|
380
343
|
if (stringHTML) {
|