@antscorp/antsomi-ui 1.3.6-beta.44 → 1.3.6-beta.45

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.
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import type { PayloadInfo } from '@antscorp/antsomi-ui/es/types';
2
3
  export type TDisplayFormat = 'number' | 'percentage' | 'currency' | 'datetime';
3
4
  type DisplayFormatProps = {
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  // Libraries
3
3
  import { createContext, useEffect, useMemo, useReducer, useRef } from 'react';
4
- import { uniq, get } from 'lodash';
4
+ import { uniq, get, isArray } from 'lodash';
5
5
  // Reducer
6
6
  import { initialState, reducer } from './reducer';
7
7
  // Hooks
@@ -14,7 +14,7 @@ const initialContext = {
14
14
  };
15
15
  export const SelectAccountContext = createContext(initialContext);
16
16
  export const SelectAccountProvider = props => {
17
- const { children, initData, ...rest } = props;
17
+ const { children, initData, users, ...rest } = props;
18
18
  const [state, dispatch] = useReducer(reducer, {
19
19
  ...initialState,
20
20
  ...rest,
@@ -23,7 +23,6 @@ export const SelectAccountProvider = props => {
23
23
  const changedRef = useRef(0);
24
24
  const formListRef = useRef(null);
25
25
  const contextValue = useMemo(() => ({ formListRef, state, dispatch }), [formListRef, state, dispatch]);
26
- const { usersSelected, isInitDone, onChange } = state;
27
26
  // Fetch users
28
27
  const { isLoading, data } = useGetAbstractUsers({
29
28
  queryFn: state.serviceAccounts,
@@ -50,6 +49,15 @@ export const SelectAccountProvider = props => {
50
49
  dispatch({ type: 'UPDATE_USERS_DISPLAY', payload: newData });
51
50
  }
52
51
  }, [data]);
52
+ useDeepCompareEffect(() => {
53
+ if (isArray(users)) {
54
+ dispatch({
55
+ type: 'UPDATE_USERS',
56
+ payload: users,
57
+ });
58
+ dispatch({ type: 'UPDATE_USERS_DISPLAY', payload: users });
59
+ }
60
+ }, [users]);
53
61
  // Callback OnChange
54
62
  // useEffect(() => {
55
63
  // if (isInitDone && typeof onChange === 'function' && changedRef.current <= 0) {
@@ -7,5 +7,5 @@ type Props = {
7
7
  enabled?: boolean;
8
8
  defaultDataSource?: any;
9
9
  };
10
- export declare const useGetAbstractUsers: ({ queryOptions, params, search, queryFn, enabled, }: Props) => import("@tanstack/react-query").UseQueryResult<unknown, unknown>;
10
+ export declare const useGetAbstractUsers: ({ queryOptions, params, search, queryFn, }: Props) => import("@tanstack/react-query").UseQueryResult<unknown, unknown>;
11
11
  export {};
@@ -1,12 +1,15 @@
1
1
  // Libraries
2
2
  import { useQuery } from '@tanstack/react-query';
3
- // Service
4
- import AbstractService from '@antscorp/antsomi-ui/es/services/Abstract';
3
+ import { isFunction } from 'lodash';
5
4
  // Constant
6
5
  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({
6
+ export const useGetAbstractUsers = ({ queryOptions = {}, params = {}, search = '', queryFn, }) => useQuery({
8
7
  queryKey: [QUERY_KEYS.GET_ABSTRACT_USERS, JSON.stringify({ params, search })],
9
8
  // initialData: defaultDataSource,
10
- queryFn: () => queryFn({ params, search }),
9
+ queryFn: () => {
10
+ if (isFunction(queryFn)) {
11
+ return queryFn({ params, search });
12
+ }
13
+ },
11
14
  ...queryOptions,
12
15
  });
@@ -42,6 +42,7 @@ export type SelectAccountProps = {
42
42
  };
43
43
  nameKey: string;
44
44
  userIdKey: string;
45
+ users?: Record<string, any>[];
45
46
  addText?: string;
46
47
  applyText?: string;
47
48
  cancelText?: string;
@@ -1,4 +1,4 @@
1
- declare 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, }: {
1
+ declare const Content: ({ apiKey, domain, portalId, token, action, ticketId, listUsers, domainTicket, config, ticketDetails, listComment, userId, refetchComments, isLoadingComment, isLoadingDetails, isLoadingDataSouce, accountManage, timeZone, isLoadingSelectedAccount, accountEdit, initOwnerId, isAllAccount, dataSelectInput, setDataSelectInput, }: {
2
2
  apiKey: any;
3
3
  domain: any;
4
4
  portalId: any;
@@ -11,7 +11,7 @@ declare const Content: ({ apiKey, domain, portalId, token, action, ticketId, lis
11
11
  ticketDetails: any;
12
12
  listComment: any;
13
13
  userId: any;
14
- fetchgetTicketComments: any;
14
+ refetchComments: any;
15
15
  isLoadingComment: any;
16
16
  isLoadingDetails: any;
17
17
  isLoadingDataSouce: any;
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /* eslint-disable react/no-unescaped-entities */
2
3
  /* eslint-disable jsx-a11y/label-has-associated-control */
3
4
  /* eslint-disable no-multi-str */
4
5
  import { useMemo, useEffect, useRef, useState } from 'react';
@@ -24,7 +25,7 @@ const initValueInput = {
24
25
  isChanged: false,
25
26
  referenceUrl: window.location.href,
26
27
  };
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 Content = ({ apiKey, domain, portalId, token, action, ticketId, listUsers, domainTicket, config, ticketDetails, listComment, userId, refetchComments, isLoadingComment, isLoadingDetails, isLoadingDataSouce, accountManage, timeZone, isLoadingSelectedAccount, accountEdit, initOwnerId, isAllAccount, dataSelectInput, setDataSelectInput, }) => {
28
29
  const [isOpenToast, setIsOpenToast] = useState({
29
30
  isOpen: false,
30
31
  status: 'error',
@@ -104,7 +105,7 @@ const Content = ({ apiKey, domain, portalId, token, action, ticketId, listUsers,
104
105
  .updateComment(params, domainTicket, token, config, userId, 'create-ticket-comment', ticketId)
105
106
  .then(res => {
106
107
  if (res.code === 200) {
107
- fetchgetTicketComments(ticketId);
108
+ refetchComments();
108
109
  updateValueInput({ message: '', files: [] });
109
110
  setTextValue('');
110
111
  // handleCloseDrawer();
@@ -173,14 +174,16 @@ const Content = ({ apiKey, domain, portalId, token, action, ticketId, listUsers,
173
174
  followers: [],
174
175
  submitterId: null,
175
176
  ownerId: null,
176
- attachments: [],
177
177
  message: '',
178
+ properties: {
179
+ attachments: [],
180
+ },
178
181
  };
179
182
  if (valueInput?.followers?.length) {
180
183
  params.followers = formatAccountId(valueInput?.followers);
181
184
  }
182
185
  if (valueInput?.files?.length > 0) {
183
- params.attachments = valueInput?.files?.map((file) => file.token);
186
+ params.properties.attachments = valueInput?.files?.map((file) => file.token);
184
187
  }
185
188
  params.submitterId = userId;
186
189
  params.ownerId = Number(valueInput?.ownerId[0]?.userId);
@@ -267,7 +270,8 @@ const Content = ({ apiKey, domain, portalId, token, action, ticketId, listUsers,
267
270
  alignleft aligncenter alignright alignjustify outdent indent |\
268
271
  numlist bullist checklist undo redo',
269
272
  tinydrive_token_provider: `//${domain}/hub/thirdparty-services/v2.0/tinymce?portalId=${portalId}&token=${token}`,
270
- skin: 'snow',
273
+ // tinydrive_token_provider: `https://sandbox-app.cdp.asia/hub/thirdparty-services/v2.0/tinymce?portalId=${portalId}&token=${token}`,
274
+ // skin: 'snow',
271
275
  toolbar_mode: 'sliding',
272
276
  content_css: false,
273
277
  branding: false,
@@ -31,7 +31,7 @@ export const TicketEditorV2 = props => {
31
31
  config: propsConfig,
32
32
  userId,
33
33
  });
34
- const { listComments, isFetchingComments } = useGetListComments({
34
+ const { listComments, isFetchingComments, refetchComments } = useGetListComments({
35
35
  domainTicket,
36
36
  token,
37
37
  config: propsConfig,
@@ -84,17 +84,6 @@ export const TicketEditorV2 = props => {
84
84
  })
85
85
  .catch(_err => { });
86
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
87
  useEffect(() => {
99
88
  fetchAccountManage();
100
89
  fetchAccountPermission();
@@ -102,7 +91,7 @@ export const TicketEditorV2 = props => {
102
91
  const handleConfirmModal = () => {
103
92
  setIsOpenModal(false);
104
93
  };
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: {
94
+ 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, refetchComments: refetchComments, 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
95
  height: '28px',
107
96
  background: '#1f5fac',
108
97
  color: '#fff',
@@ -9,5 +9,6 @@ type Props = {
9
9
  export declare const useGetListComments: ({ domainTicket, token, config, userId, ticketId, enabled, }: Props) => {
10
10
  listComments: any;
11
11
  isFetchingComments: boolean;
12
+ refetchComments: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<any, unknown>>;
12
13
  };
13
14
  export {};
@@ -6,7 +6,7 @@ const getListCommentServices = async (params, domain, token, config, userId, typ
6
6
  return res.data;
7
7
  };
8
8
  export const useGetListComments = ({ domainTicket, token, config, userId, ticketId, enabled, }) => {
9
- const { data, isFetching } = useQuery({
9
+ const { data, isFetching, refetch } = useQuery({
10
10
  queryKey: [QUERY_KEYS.GET_TICKET_COMMENT, domainTicket, token, config, userId, ticketId],
11
11
  enabled: !!ticketId || enabled,
12
12
  queryFn: () => getListCommentServices({}, domainTicket, token, config, userId, 'get-ticket-comments', ticketId),
@@ -14,5 +14,6 @@ export const useGetListComments = ({ domainTicket, token, config, userId, ticket
14
14
  return {
15
15
  listComments: data || [],
16
16
  isFetchingComments: isFetching,
17
+ refetchComments: refetch,
17
18
  };
18
19
  };
@@ -14,11 +14,11 @@ export const WrapperContent = styled.div `
14
14
  display: flex;
15
15
  gap: 20px;
16
16
  padding: 15px;
17
+ flex-wrap: wrap;
17
18
  `;
18
19
  export const WrapperLeftContent = styled.div `
19
- width: 38%;
20
+ flex: 1;
20
21
  // border-right: 1px solid #e5e5e5;
21
- overflow: auto;
22
22
  ::-webkit-scrollbar {
23
23
  width: 8px;
24
24
  height: 8px;
@@ -32,8 +32,7 @@ export const WrapperLeftContent = styled.div `
32
32
  }
33
33
  `;
34
34
  export const WrapperRightContent = styled.div `
35
- flex: 1;
36
- overflow: auto;
35
+ flex: 2;
37
36
  ::-webkit-scrollbar {
38
37
  width: 8px;
39
38
  height: 8px;
@@ -549,8 +548,8 @@ export const WrapperContentAvatar = styled.div `
549
548
 
550
549
  .comment-header {
551
550
  display: flex;
552
- alignitems: flex-start;
553
- justifycontent: space-between;
551
+ align-items: flex-start;
552
+ justify-content: space-between;
554
553
  position: relative;
555
554
  }
556
555
  .comment-time {
@@ -559,10 +558,10 @@ export const WrapperContentAvatar = styled.div `
559
558
  left: 50%;
560
559
  transform: translateX(-50%);
561
560
  width: fit-content;
562
- fontsize: 12px;
561
+ font-size: 12px;
563
562
  color: #7f7f7f;
564
- marginright: 5px;
565
- whitespace: nowrap;
563
+ margin-right: 5px;
564
+ white-space: nowrap;
566
565
  }
567
566
  .comment-content {
568
567
  font-size: 12px;
@@ -78,7 +78,7 @@ export function callApiWithAuth(endpoint, method = 'GET', body, domain = '', con
78
78
  // .catch(err => serviceUnavailbale);
79
79
  }
80
80
  if (Object.prototype.hasOwnProperty.call(others, '_owner_id')) {
81
- ownerId = safeParse(others['_owner_id'], '');
81
+ ownerId = safeParse(others._owner_id, '');
82
82
  }
83
83
  const isJourney = window.location.href.includes('marketing-hub/journeys');
84
84
  if (ownerId === 'all' && !isJourney) {
@@ -3,4 +3,5 @@
3
3
  * Asynchronously loads the component for TemplateListing
4
4
  *
5
5
  */
6
+ /// <reference types="react" />
6
7
  export declare const TemplateListing: (props: import("./types").TemplateListingProps<{}>) => JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.6-beta.44",
3
+ "version": "1.3.6-beta.45",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",