@antscorp/antsomi-ui 2.0.73 → 2.0.75

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.
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
3
3
  /* eslint-disable jsx-a11y/label-has-associated-control */
4
4
  /* eslint-disable no-multi-str */
5
5
  // Libraries
6
- import { isEmpty } from 'lodash';
6
+ import { isEmpty, keyBy } from 'lodash';
7
7
  import { useEffect, useMemo, useRef, useState } from 'react';
8
8
  import { createPortal } from 'react-dom';
9
9
  // Assets
@@ -29,6 +29,7 @@ import { ATTACH_CAPTURE_TYPES, ATTACH_KEYS, DEFAULT_POSITIONS, MENU_KEYS, MESSAG
29
29
  import { BugIcon, CameraIcon, OpenUrlIcon, RequestIcon, ScreenshotMonitorIcon, } from '@antscorp/antsomi-ui/es/components/icons';
30
30
  import { base64ToFile, convertBlobToFile, generateUniqueId, mergeAudioStreams, } from '@antscorp/antsomi-ui/es/components/molecules/CaptureScreen/utils';
31
31
  import { expendDefault, formatParams, postCustomEvent } from './utils';
32
+ import { useGetListUser } from './queries';
32
33
  const antIcon = _jsx(LoadingOutlined, { style: { fontSize: 40 }, spin: true });
33
34
  const Loading = ({ isLoading, height, width }) => isLoading && (_jsx(WrapperLoading, { className: "loader-container", height: height, width: width, children: _jsx(Spin, { indicator: antIcon }) }));
34
35
  const Help = props => {
@@ -53,6 +54,12 @@ const Help = props => {
53
54
  files: [],
54
55
  referenceUrl: '',
55
56
  });
57
+ const { listUsers, isFetchingUsers } = useGetListUser({
58
+ domain,
59
+ config,
60
+ userId,
61
+ token,
62
+ });
56
63
  const [errFile, setErrFile] = useState({
57
64
  isError: false,
58
65
  message: '',
@@ -616,12 +623,17 @@ const Help = props => {
616
623
  }
617
624
  if (!errFile.isError) {
618
625
  const params = formatParams({ ...valueInput, feature: appTargeting });
626
+ const mapUserById = keyBy(listUsers, 'userId');
627
+ const ownerEmail = mapUserById[params.ownerId || '']?.email;
628
+ const referenceUrl = window.location.href;
619
629
  handleCreateTicket({
620
630
  ...params,
621
631
  type,
622
632
  imageDrew,
623
633
  dataRecorded,
624
634
  submitterId: Number(userId),
635
+ submitterEmail: ownerEmail,
636
+ referenceUrl,
625
637
  });
626
638
  }
627
639
  };
@@ -831,7 +843,7 @@ const Help = props => {
831
843
  }
832
844
  }
833
845
  };
834
- const renderPopupLayout = (type) => (_jsxs(_Fragment, { children: [_jsx(Loading, { isLoading: isMainLoading, width: "100%", height: "100%" }), _jsx(WrapperHeader, { className: "cursor", children: _jsx(Header, { children: title }) }), _jsx(WrapperBody, { className: "popup-content", style: {
846
+ const renderPopupLayout = (type) => (_jsxs(_Fragment, { children: [_jsx(Loading, { isLoading: isMainLoading || isFetchingUsers, width: "100%", height: "100%" }), _jsx(WrapperHeader, { className: "cursor", children: _jsx(Header, { children: title }) }), _jsx(WrapperBody, { className: "popup-content", style: {
835
847
  padding: type === REPORT_TYPES.CHAT ||
836
848
  type === REPORT_TYPES.HELP ||
837
849
  type === REPORT_TYPES.HELP_V1
@@ -0,0 +1 @@
1
+ export * from './useGetListUser';
@@ -0,0 +1 @@
1
+ export * from './useGetListUser';
@@ -0,0 +1,11 @@
1
+ type Props = {
2
+ domain: string;
3
+ config: any;
4
+ userId: string;
5
+ token: string;
6
+ };
7
+ export declare const useGetListUser: ({ domain, config, userId, token }: Props) => {
8
+ listUsers: any;
9
+ isFetchingUsers: boolean;
10
+ };
11
+ export {};
@@ -0,0 +1,14 @@
1
+ import { useQuery } from '@tanstack/react-query';
2
+ import TicketService from '@antscorp/antsomi-ui/es/services/Ticket';
3
+ const QUERY_KEY = 'GET_LIST_USER';
4
+ const getListUserServices = async (params = {}, domain, token, config, userId) => {
5
+ const res = await TicketService.lookupInfo.callApi.c_user_id(params, domain, token, config, userId);
6
+ return res.data;
7
+ };
8
+ export const useGetListUser = ({ domain, config, userId, token }) => {
9
+ const { data, isFetching } = useQuery([QUERY_KEY, domain, token, config, userId], () => getListUserServices({}, domain, token, config, userId));
10
+ return {
11
+ listUsers: data || [],
12
+ isFetchingUsers: isFetching,
13
+ };
14
+ };
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- declare const _default: import("react").MemoExoticComponent<({ apiKey, domain, portalId, token, action, ticketId, listUsers, domainTicket, config, ticketDetails, listComment, userId, refetchComments, isLoadingComment, isLoadingDetails, isLoadingDataSouce, accountManage, timeZone, initOwnerId, isAllAccount, dataSelectInput, setDataSelectInput, email, domainUpload, }: {
2
+ declare const _default: import("react").MemoExoticComponent<({ apiKey, domain, portalId, token, action, ticketId, listUsers, domainTicket, config, ticketDetails, listComment, userId, refetchComments, refetchTicket, isLoadingComment, isLoadingDetails, isLoadingDataSouce, accountManage, timeZone, initOwnerId, isAllAccount, dataSelectInput, setDataSelectInput, email, domainUpload, }: {
3
3
  apiKey: any;
4
4
  domain: any;
5
5
  portalId: any;
@@ -13,6 +13,7 @@ declare const _default: import("react").MemoExoticComponent<({ apiKey, domain, p
13
13
  listComment: any;
14
14
  userId: any;
15
15
  refetchComments: any;
16
+ refetchTicket: any;
16
17
  isLoadingComment: any;
17
18
  isLoadingDetails: any;
18
19
  isLoadingDataSouce: any;
@@ -24,7 +24,7 @@ const initValueInput = {
24
24
  isChanged: false,
25
25
  referenceUrl: window.location.href,
26
26
  };
27
- const Content = ({ apiKey, domain, portalId, token, action, ticketId, listUsers, domainTicket, config, ticketDetails, listComment, userId, refetchComments, isLoadingComment, isLoadingDetails, isLoadingDataSouce, accountManage, timeZone, initOwnerId, isAllAccount, dataSelectInput, setDataSelectInput, email, domainUpload, }) => {
27
+ const Content = ({ apiKey, domain, portalId, token, action, ticketId, listUsers, domainTicket, config, ticketDetails, listComment, userId, refetchComments, refetchTicket, isLoadingComment, isLoadingDetails, isLoadingDataSouce, accountManage, timeZone, initOwnerId, isAllAccount, dataSelectInput, setDataSelectInput, email, domainUpload, }) => {
28
28
  const [isOpenToast, setIsOpenToast] = useState({
29
29
  isOpen: false,
30
30
  status: 'error',
@@ -118,8 +118,10 @@ const Content = ({ apiKey, domain, portalId, token, action, ticketId, listUsers,
118
118
  .updateFollowers(params, domainTicket, token, config, userId, ticketId, portalId)
119
119
  .then(res => {
120
120
  setIsLoadingFollower(false);
121
+ refetchTicket();
121
122
  })
122
123
  .catch(err => {
124
+ refetchTicket();
123
125
  setIsLoadingFollower(false);
124
126
  });
125
127
  };
@@ -142,6 +144,7 @@ const Content = ({ apiKey, domain, portalId, token, action, ticketId, listUsers,
142
144
  });
143
145
  }
144
146
  }, [ticketDetails, listUsers, dataSelects]);
147
+ console.log('🚀 ~ listUsers:', listUsers);
145
148
  useEffect(() => {
146
149
  setIsLoading(true);
147
150
  getCustomFields();
@@ -19,7 +19,7 @@ const defaultProps = {
19
19
  };
20
20
  export const TicketEditorV2 = props => {
21
21
  const { apiKey, portalId, token, domain, action, config: propsConfig, userId, ownerId, domainTicket, ticketId, domainAccount, email, domainUpload, } = props;
22
- const { ticketDetails, isFetching: isFetchingDetails } = useGetDetailTicket({
22
+ const { ticketDetails, isFetching: isFetchingDetails, refetchTicket, } = useGetDetailTicket({
23
23
  ticketId,
24
24
  domainTicket,
25
25
  config: propsConfig,
@@ -51,7 +51,7 @@ export const TicketEditorV2 = props => {
51
51
  const handleConfirmModal = () => {
52
52
  setIsOpenModal(false);
53
53
  };
54
- return (_jsxs(TicketEditorWrapper, { children: [_jsx(Content, { apiKey: apiKey, portalId: portalId, token: token, domain: domain, domainUpload: domainUpload, action: action, listUsers: listUsers, domainTicket: domainTicket, config: config, ticketDetails: ticketDetails, listComment: listComments, ticketId: ticketId, userId: userId, refetchComments: refetchComments, isLoadingComment: isFetchingComments, isLoadingDetails: isFetchingDetails, isLoadingDataSouce: isFetchingUsers, accountManage: accountManage, timeZone: timeZone, initOwnerId: ownerId, isAllAccount: isAllAccount, dataSelectInput: dataSelectInput, setDataSelectInput: setDataSelectInput, email: email }), _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: {
54
+ return (_jsxs(TicketEditorWrapper, { children: [_jsx(Content, { apiKey: apiKey, portalId: portalId, token: token, domain: domain, domainUpload: domainUpload, action: action, listUsers: listUsers, domainTicket: domainTicket, config: config, ticketDetails: ticketDetails, listComment: listComments, ticketId: ticketId, userId: userId, refetchComments: refetchComments, refetchTicket: refetchTicket, isLoadingComment: isFetchingComments, isLoadingDetails: isFetchingDetails, isLoadingDataSouce: isFetchingUsers, accountManage: accountManage, timeZone: timeZone, initOwnerId: ownerId, isAllAccount: isAllAccount, dataSelectInput: dataSelectInput, setDataSelectInput: setDataSelectInput, email: email }), _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: {
55
55
  height: '28px',
56
56
  background: '#1f5fac',
57
57
  color: '#fff',
@@ -8,5 +8,6 @@ type Props = {
8
8
  export declare const useGetDetailTicket: ({ domainTicket, config, userId, ticketId, networkId, }: Props) => {
9
9
  ticketDetails: any;
10
10
  isFetching: boolean;
11
+ refetchTicket: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<any, unknown>>;
11
12
  };
12
13
  export {};
@@ -2,7 +2,7 @@ import { useQuery } from '@tanstack/react-query';
2
2
  import { QUERY_KEYS } from '../constants/queryKeys';
3
3
  import Service from '../Service';
4
4
  export const useGetDetailTicket = ({ domainTicket, config, userId, ticketId, networkId, }) => {
5
- const { data, isFetching } = useQuery({
5
+ const { data, isFetching, refetch } = useQuery({
6
6
  queryKey: [QUERY_KEYS.GET_TICKET_DETAIL, domainTicket, config, userId, ticketId, networkId],
7
7
  enabled: !!ticketId,
8
8
  queryFn: () => Service.tickets.callApi.getDetailsTicket({}, domainTicket, undefined, config, userId, ticketId, '', networkId),
@@ -10,5 +10,6 @@ export const useGetDetailTicket = ({ domainTicket, config, userId, ticketId, net
10
10
  return {
11
11
  ticketDetails: data?.data?.ticket || [],
12
12
  isFetching,
13
+ refetchTicket: refetch,
13
14
  };
14
15
  };
@@ -1,3 +1,4 @@
1
+ import dayjs from 'dayjs';
1
2
  export declare function getObjectPropSafely(fn: any, defaultValue?: string): any;
2
3
  export declare function isNumeric(num: any): boolean;
3
4
  export declare function getUserLocaleLanguage(config: any): any;
@@ -42,6 +43,6 @@ export declare const formatParams: (data: any) => {
42
43
  export declare const formatDatarender: (data: any, listSelect: any, listAccount: any) => any;
43
44
  export declare const handleValidateContent: (stringHTML: any) => string | undefined;
44
45
  export declare const compareArrays: (a: any, b: any) => boolean;
45
- export declare const convertDateToTimestamp: (time: any, timeZone: any) => string;
46
+ export declare const convertDateToTimestamp: (time: string | number | Date | dayjs.Dayjs, timeZone: string) => string;
46
47
  export declare const postCustomEvent: (type: any, data: any) => void;
47
48
  export declare const generateAvatar: (text: any, foregroundColor?: string, backgroundColor?: string) => string;
@@ -347,7 +347,28 @@ export const handleValidateContent = stringHTML => {
347
347
  }
348
348
  };
349
349
  export const compareArrays = (a, b) => JSON.stringify(a) === JSON.stringify(b);
350
- export const convertDateToTimestamp = (time, timeZone) => dayjs(time).tz(timeZone).format('MMM DD YYYY hh:mm');
350
+ const isValidTimezone = (timeZone) => {
351
+ try {
352
+ dayjs().tz(timeZone).format();
353
+ return true;
354
+ }
355
+ catch (e) {
356
+ return false;
357
+ }
358
+ };
359
+ export const convertDateToTimestamp = (time, timeZone) => {
360
+ try {
361
+ // Validate timezone first
362
+ if (!timeZone || !isValidTimezone(timeZone)) {
363
+ return dayjs(time).utc().format('MMM DD YYYY hh:mm');
364
+ }
365
+ return dayjs(time).tz(timeZone).format('MMM DD YYYY hh:mm');
366
+ }
367
+ catch (error) {
368
+ // Fallback to UTC in case of error
369
+ return dayjs(time).utc().format('MMM DD YYYY hh:mm');
370
+ }
371
+ };
351
372
  export const postCustomEvent = (type, data) => {
352
373
  if (!type) {
353
374
  return;
@@ -164,7 +164,6 @@ export const Layout = memo(props => {
164
164
  helpConfig: {
165
165
  ...headerProps?.helpConfig,
166
166
  configs: {
167
- ...headerProps?.helpConfig?.configs,
168
167
  appCode: 'SANDBOX_MARKETING',
169
168
  avatar: '//c0-platform.ants.tech/avatar/2021/09/17/0xgbkurioo.png',
170
169
  config: {
@@ -174,6 +173,7 @@ export const Layout = memo(props => {
174
173
  embeddedData: {},
175
174
  INSIGHT_U_OGS: 'uogs',
176
175
  },
176
+ ...headerProps?.helpConfig?.configs,
177
177
  },
178
178
  },
179
179
  accountSharingConfig: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "2.0.73",
3
+ "version": "2.0.75",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",