@droppii-org/chat-sdk 0.0.33 → 0.0.34

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 (86) hide show
  1. package/dist/components/conversation/ConversationBySessionItem.d.ts.map +1 -1
  2. package/dist/components/conversation/ConversationBySessionItem.js +3 -68
  3. package/dist/components/conversation/DeskConversationList.d.ts.map +1 -1
  4. package/dist/components/conversation/DeskConversationList.js +44 -22
  5. package/dist/components/mediaCollection/FileCollection.d.ts.map +1 -1
  6. package/dist/components/mediaCollection/FileCollection.js +7 -6
  7. package/dist/components/mediaCollection/ImageCollection.d.ts.map +1 -1
  8. package/dist/components/mediaCollection/ImageCollection.js +7 -6
  9. package/dist/components/mediaCollection/VideoCollection.d.ts.map +1 -1
  10. package/dist/components/mediaCollection/VideoCollection.js +7 -6
  11. package/dist/components/mediaCollection/index.js +5 -5
  12. package/dist/components/message/MessageList.d.ts +1 -0
  13. package/dist/components/message/MessageList.d.ts.map +1 -1
  14. package/dist/components/message/MessageList.js +53 -15
  15. package/dist/components/message/footer/index.d.ts +1 -5
  16. package/dist/components/message/footer/index.d.ts.map +1 -1
  17. package/dist/components/message/footer/index.js +5 -4
  18. package/dist/components/message/item/index.d.ts +4 -3
  19. package/dist/components/message/item/index.d.ts.map +1 -1
  20. package/dist/components/message/item/index.js +24 -30
  21. package/dist/components/searchConversation/SearchAll.d.ts +6 -1
  22. package/dist/components/searchConversation/SearchAll.d.ts.map +1 -1
  23. package/dist/components/searchConversation/SearchAll.js +28 -4
  24. package/dist/components/searchConversation/SearchConversationAsMessages.d.ts +4 -1
  25. package/dist/components/searchConversation/SearchConversationAsMessages.d.ts.map +1 -1
  26. package/dist/components/searchConversation/SearchConversationAsMessages.js +18 -3
  27. package/dist/components/searchConversation/SearchConversationAsUsers.d.ts +4 -1
  28. package/dist/components/searchConversation/SearchConversationAsUsers.d.ts.map +1 -1
  29. package/dist/components/searchConversation/SearchConversationAsUsers.js +14 -3
  30. package/dist/components/searchConversation/index.d.ts +4 -1
  31. package/dist/components/searchConversation/index.d.ts.map +1 -1
  32. package/dist/components/searchConversation/index.js +8 -7
  33. package/dist/components/searchConversation/item/SearchItemAsMessage.d.ts +8 -0
  34. package/dist/components/searchConversation/item/SearchItemAsMessage.d.ts.map +1 -0
  35. package/dist/components/searchConversation/item/SearchItemAsMessage.js +49 -0
  36. package/dist/components/searchConversation/item/SearchItemAsUser.d.ts +8 -0
  37. package/dist/components/searchConversation/item/SearchItemAsUser.d.ts.map +1 -0
  38. package/dist/components/searchConversation/item/SearchItemAsUser.js +13 -0
  39. package/dist/components/session/DeskAssignedSession.js +5 -5
  40. package/dist/constants/index.d.ts +3 -0
  41. package/dist/constants/index.d.ts.map +1 -1
  42. package/dist/constants/index.js +3 -0
  43. package/dist/context/ChatContext.d.ts.map +1 -1
  44. package/dist/context/ChatContext.js +1 -0
  45. package/dist/hooks/message/useMessage.d.ts +8 -5
  46. package/dist/hooks/message/useMessage.d.ts.map +1 -1
  47. package/dist/hooks/message/useMessage.js +117 -51
  48. package/dist/hooks/message/useSendMessage.d.ts +2 -4
  49. package/dist/hooks/message/useSendMessage.d.ts.map +1 -1
  50. package/dist/hooks/message/useSendMessage.js +9 -39
  51. package/dist/hooks/search/useSearchMessage.d.ts +232 -0
  52. package/dist/hooks/search/useSearchMessage.d.ts.map +1 -0
  53. package/dist/hooks/search/useSearchMessage.js +71 -0
  54. package/dist/hooks/session/useGetSession.d.ts +222 -0
  55. package/dist/hooks/session/useGetSession.d.ts.map +1 -0
  56. package/dist/hooks/session/useGetSession.js +83 -0
  57. package/dist/hooks/session/useGetSessionSummary.d.ts.map +1 -1
  58. package/dist/hooks/session/useGetSessionSummary.js +2 -1
  59. package/dist/hooks/user/useAuth.d.ts.map +1 -1
  60. package/dist/hooks/user/useAuth.js +6 -4
  61. package/dist/index.d.ts +2 -2
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +2 -1
  64. package/dist/locales/vi/common.json +4 -1
  65. package/dist/screens/deskMessage/index.d.ts.map +1 -1
  66. package/dist/screens/deskMessage/index.js +2 -1
  67. package/dist/services/query.d.ts +1 -1
  68. package/dist/services/query.js +1 -1
  69. package/dist/services/routes.d.ts +1 -1
  70. package/dist/services/routes.js +1 -1
  71. package/dist/store/auth.d.ts.map +1 -1
  72. package/dist/store/auth.js +12 -2
  73. package/dist/store/conversation.d.ts.map +1 -1
  74. package/dist/store/conversation.js +7 -1
  75. package/dist/styles/global.css +1 -1
  76. package/dist/types/chat.d.ts +7 -8
  77. package/dist/types/chat.d.ts.map +1 -1
  78. package/dist/types/chat.js +4 -0
  79. package/dist/types/dto.d.ts +14 -23
  80. package/dist/types/dto.d.ts.map +1 -1
  81. package/dist/utils/common.d.ts +3 -0
  82. package/dist/utils/common.d.ts.map +1 -1
  83. package/dist/utils/common.js +98 -0
  84. package/dist/utils/events.d.ts +1 -0
  85. package/dist/utils/events.d.ts.map +1 -1
  86. package/package.json +3 -1
@@ -0,0 +1,71 @@
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
+ import { useInfiniteQuery } from "@tanstack/react-query";
13
+ import { QUERY_KEYS } from "../../services/query";
14
+ import { apiInstance } from "../../services/api";
15
+ import { ENDPOINTS } from "../../services/routes";
16
+ import { useMemo } from "react";
17
+ import dayjs from "dayjs";
18
+ import useAuthStore from "../../store/auth";
19
+ import { PAGE_SIZE } from "../../constants";
20
+ export const useSearchMessage = ({ payload, options, }) => {
21
+ const _a = useInfiniteQuery({
22
+ initialPageParam: 1,
23
+ queryKey: [QUERY_KEYS.SEARCH_MESSAGE, payload, options],
24
+ queryFn: async ({ pageParam = 1 }) => {
25
+ const params = Object.assign(Object.assign({ pageSize: (options === null || options === void 0 ? void 0 : options.pageSize) || PAGE_SIZE }, payload), { page: pageParam, applicationType: useAuthStore.getState().applicationType });
26
+ const res = await apiInstance.post(ENDPOINTS.chatService.searchMessage, params);
27
+ return res.data;
28
+ },
29
+ getNextPageParam: (lastPage) => {
30
+ var _a, _b;
31
+ const pageSize = (options === null || options === void 0 ? void 0 : options.pageSize) || PAGE_SIZE;
32
+ const dataLength = ((_a = lastPage === null || lastPage === void 0 ? void 0 : lastPage.data) === null || _a === void 0 ? void 0 : _a.length) || 0;
33
+ const currentPage = ((_b = lastPage === null || lastPage === void 0 ? void 0 : lastPage.pageable) === null || _b === void 0 ? void 0 : _b.pageNumber) || 1;
34
+ return dataLength < pageSize ? undefined : currentPage + 1;
35
+ },
36
+ enabled: hasValidFilter(payload),
37
+ }), { data, fetchNextPage, hasNextPage, isFetchingNextPage, isLoading } = _a, rest = __rest(_a, ["data", "fetchNextPage", "hasNextPage", "isFetchingNextPage", "isLoading"]);
38
+ const { groupedData, dataFlatten } = useMemo(() => {
39
+ if (!data)
40
+ return {
41
+ groupedData: {},
42
+ dataFlatten: [],
43
+ };
44
+ const allItems = data.pages.flatMap((page) => page.data);
45
+ const mGroupeddata = allItems.reduce((acc, item) => {
46
+ const dateKey = dayjs(item.chatLog.sendTime).format("YYYY-MM-DD");
47
+ if (!acc[dateKey])
48
+ acc[dateKey] = [];
49
+ acc[dateKey].push(item);
50
+ return acc;
51
+ }, {});
52
+ return {
53
+ groupedData: mGroupeddata,
54
+ dataFlatten: allItems,
55
+ };
56
+ }, [data]);
57
+ return Object.assign({ data,
58
+ fetchNextPage,
59
+ hasNextPage,
60
+ isFetchingNextPage,
61
+ isLoading,
62
+ groupedData,
63
+ dataFlatten }, rest);
64
+ };
65
+ const hasValidFilter = (filter) => {
66
+ return Object.values(filter).some((v) => {
67
+ if (typeof v === "string")
68
+ return v.trim() !== "";
69
+ return v !== undefined && v !== null;
70
+ });
71
+ };
@@ -0,0 +1,222 @@
1
+ import { BaseResponse } from "../../types/dto";
2
+ import { IFilterSummary, ISessionByStatus } from "../../store/type";
3
+ export declare const useGetSession: (filter: IFilterSummary, options?: {
4
+ pageSize?: number;
5
+ }) => {
6
+ error: Error;
7
+ isError: true;
8
+ isPending: false;
9
+ isLoadingError: false;
10
+ isRefetchError: true;
11
+ isSuccess: false;
12
+ isPlaceholderData: false;
13
+ status: "error";
14
+ fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown>, Error>>;
15
+ hasPreviousPage: boolean;
16
+ isFetchNextPageError: boolean;
17
+ isFetchPreviousPageError: boolean;
18
+ isFetchingPreviousPage: boolean;
19
+ dataUpdatedAt: number;
20
+ errorUpdatedAt: number;
21
+ failureCount: number;
22
+ failureReason: Error | null;
23
+ errorUpdateCount: number;
24
+ isFetched: boolean;
25
+ isFetchedAfterMount: boolean;
26
+ isFetching: boolean;
27
+ isInitialLoading: boolean;
28
+ isPaused: boolean;
29
+ isRefetching: boolean;
30
+ isStale: boolean;
31
+ isEnabled: boolean;
32
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown>, Error>>;
33
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
34
+ promise: Promise<import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown>>;
35
+ data: import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown> | undefined;
36
+ fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown>, Error>>;
37
+ hasNextPage: boolean;
38
+ isFetchingNextPage: boolean;
39
+ isLoading: boolean;
40
+ dataFlatten: ISessionByStatus[];
41
+ } | {
42
+ error: null;
43
+ isError: false;
44
+ isPending: false;
45
+ isLoadingError: false;
46
+ isRefetchError: false;
47
+ isFetchNextPageError: false;
48
+ isFetchPreviousPageError: false;
49
+ isSuccess: true;
50
+ isPlaceholderData: false;
51
+ status: "success";
52
+ fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown>, Error>>;
53
+ hasPreviousPage: boolean;
54
+ isFetchingPreviousPage: boolean;
55
+ dataUpdatedAt: number;
56
+ errorUpdatedAt: number;
57
+ failureCount: number;
58
+ failureReason: Error | null;
59
+ errorUpdateCount: number;
60
+ isFetched: boolean;
61
+ isFetchedAfterMount: boolean;
62
+ isFetching: boolean;
63
+ isInitialLoading: boolean;
64
+ isPaused: boolean;
65
+ isRefetching: boolean;
66
+ isStale: boolean;
67
+ isEnabled: boolean;
68
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown>, Error>>;
69
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
70
+ promise: Promise<import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown>>;
71
+ data: import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown> | undefined;
72
+ fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown>, Error>>;
73
+ hasNextPage: boolean;
74
+ isFetchingNextPage: boolean;
75
+ isLoading: boolean;
76
+ dataFlatten: ISessionByStatus[];
77
+ } | {
78
+ error: Error;
79
+ isError: true;
80
+ isPending: false;
81
+ isLoadingError: true;
82
+ isRefetchError: false;
83
+ isFetchNextPageError: false;
84
+ isFetchPreviousPageError: false;
85
+ isSuccess: false;
86
+ isPlaceholderData: false;
87
+ status: "error";
88
+ fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown>, Error>>;
89
+ hasPreviousPage: boolean;
90
+ isFetchingPreviousPage: boolean;
91
+ dataUpdatedAt: number;
92
+ errorUpdatedAt: number;
93
+ failureCount: number;
94
+ failureReason: Error | null;
95
+ errorUpdateCount: number;
96
+ isFetched: boolean;
97
+ isFetchedAfterMount: boolean;
98
+ isFetching: boolean;
99
+ isInitialLoading: boolean;
100
+ isPaused: boolean;
101
+ isRefetching: boolean;
102
+ isStale: boolean;
103
+ isEnabled: boolean;
104
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown>, Error>>;
105
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
106
+ promise: Promise<import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown>>;
107
+ data: import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown> | undefined;
108
+ fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown>, Error>>;
109
+ hasNextPage: boolean;
110
+ isFetchingNextPage: boolean;
111
+ isLoading: boolean;
112
+ dataFlatten: ISessionByStatus[];
113
+ } | {
114
+ error: null;
115
+ isError: false;
116
+ isPending: true;
117
+ isLoadingError: false;
118
+ isRefetchError: false;
119
+ isFetchNextPageError: false;
120
+ isFetchPreviousPageError: false;
121
+ isSuccess: false;
122
+ isPlaceholderData: false;
123
+ status: "pending";
124
+ fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown>, Error>>;
125
+ hasPreviousPage: boolean;
126
+ isFetchingPreviousPage: boolean;
127
+ dataUpdatedAt: number;
128
+ errorUpdatedAt: number;
129
+ failureCount: number;
130
+ failureReason: Error | null;
131
+ errorUpdateCount: number;
132
+ isFetched: boolean;
133
+ isFetchedAfterMount: boolean;
134
+ isFetching: boolean;
135
+ isInitialLoading: boolean;
136
+ isPaused: boolean;
137
+ isRefetching: boolean;
138
+ isStale: boolean;
139
+ isEnabled: boolean;
140
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown>, Error>>;
141
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
142
+ promise: Promise<import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown>>;
143
+ data: import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown> | undefined;
144
+ fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown>, Error>>;
145
+ hasNextPage: boolean;
146
+ isFetchingNextPage: boolean;
147
+ isLoading: boolean;
148
+ dataFlatten: ISessionByStatus[];
149
+ } | {
150
+ error: null;
151
+ isError: false;
152
+ isPending: true;
153
+ isLoadingError: false;
154
+ isRefetchError: false;
155
+ isFetchNextPageError: false;
156
+ isFetchPreviousPageError: false;
157
+ isSuccess: false;
158
+ isPlaceholderData: false;
159
+ status: "pending";
160
+ fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown>, Error>>;
161
+ hasPreviousPage: boolean;
162
+ isFetchingPreviousPage: boolean;
163
+ dataUpdatedAt: number;
164
+ errorUpdatedAt: number;
165
+ failureCount: number;
166
+ failureReason: Error | null;
167
+ errorUpdateCount: number;
168
+ isFetched: boolean;
169
+ isFetchedAfterMount: boolean;
170
+ isFetching: boolean;
171
+ isInitialLoading: boolean;
172
+ isPaused: boolean;
173
+ isRefetching: boolean;
174
+ isStale: boolean;
175
+ isEnabled: boolean;
176
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown>, Error>>;
177
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
178
+ promise: Promise<import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown>>;
179
+ data: import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown> | undefined;
180
+ fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown>, Error>>;
181
+ hasNextPage: boolean;
182
+ isFetchingNextPage: boolean;
183
+ isLoading: boolean;
184
+ dataFlatten: ISessionByStatus[];
185
+ } | {
186
+ isError: false;
187
+ error: null;
188
+ isPending: false;
189
+ isLoadingError: false;
190
+ isRefetchError: false;
191
+ isSuccess: true;
192
+ isPlaceholderData: true;
193
+ isFetchNextPageError: false;
194
+ isFetchPreviousPageError: false;
195
+ status: "success";
196
+ fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown>, Error>>;
197
+ hasPreviousPage: boolean;
198
+ isFetchingPreviousPage: boolean;
199
+ dataUpdatedAt: number;
200
+ errorUpdatedAt: number;
201
+ failureCount: number;
202
+ failureReason: Error | null;
203
+ errorUpdateCount: number;
204
+ isFetched: boolean;
205
+ isFetchedAfterMount: boolean;
206
+ isFetching: boolean;
207
+ isInitialLoading: boolean;
208
+ isPaused: boolean;
209
+ isRefetching: boolean;
210
+ isStale: boolean;
211
+ isEnabled: boolean;
212
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown>, Error>>;
213
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
214
+ promise: Promise<import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown>>;
215
+ data: import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown> | undefined;
216
+ fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ISessionByStatus[]>, unknown>, Error>>;
217
+ hasNextPage: boolean;
218
+ isFetchingNextPage: boolean;
219
+ isLoading: boolean;
220
+ dataFlatten: ISessionByStatus[];
221
+ };
222
+ //# sourceMappingURL=useGetSession.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGetSession.d.ts","sourceRoot":"","sources":["../../../src/hooks/session/useGetSession.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAA+B,MAAM,iBAAiB,CAAC;AAE5E,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAOpE,eAAO,MAAM,aAAa,GACxB,QAAQ,cAAc,EACtB,UAAU;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4EhC,CAAC"}
@@ -0,0 +1,83 @@
1
+ "use client";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ import { useInfiniteQuery } from "@tanstack/react-query";
14
+ import { apiInstance } from "../../services/api";
15
+ import { ENDPOINTS } from "../../services/routes";
16
+ import { QUERY_KEYS } from "../../services/query";
17
+ import { useMemo } from "react";
18
+ import useConversationStore from "../../store/conversation";
19
+ import { DChatSDK } from "../../constants/sdk";
20
+ import useAuthStore from "../../store/auth";
21
+ import { PAGE_SIZE } from "../../constants";
22
+ export const useGetSession = (filter, options) => {
23
+ const _a = useInfiniteQuery({
24
+ initialPageParam: 1,
25
+ queryKey: [QUERY_KEYS.GET_SESSION_BY_TAG_OR_STATUS, filter, options],
26
+ queryFn: async ({ pageParam = 1 }) => {
27
+ var _a, _b;
28
+ const params = {
29
+ applicationType: useAuthStore.getState().applicationType,
30
+ tag: filter.tag,
31
+ status: filter.status,
32
+ page: pageParam,
33
+ pageSize: (options === null || options === void 0 ? void 0 : options.pageSize) || PAGE_SIZE,
34
+ searchTerm: filter.searchTerm,
35
+ };
36
+ const res = await apiInstance.post(ENDPOINTS.chatService.getSessionsByTagOrStatus, params);
37
+ //FIND NEW CONVERSATIONS
38
+ const conversationList = useConversationStore.getState().conversationList;
39
+ const newConversations = (_b = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.filter((session) => {
40
+ return !conversationList.some((conversation) => conversation.conversationID === session.conversationId);
41
+ });
42
+ if (newConversations === null || newConversations === void 0 ? void 0 : newConversations.length) {
43
+ DChatSDK.getMultipleConversation(newConversations.map((session) => session.conversationId)).then((res) => {
44
+ useConversationStore
45
+ .getState()
46
+ .updateConversationList(res.data, "filter");
47
+ });
48
+ }
49
+ return res.data;
50
+ },
51
+ getNextPageParam: (lastPage) => {
52
+ var _a, _b;
53
+ const pageSize = (options === null || options === void 0 ? void 0 : options.pageSize) || PAGE_SIZE;
54
+ const dataLength = ((_a = lastPage === null || lastPage === void 0 ? void 0 : lastPage.data) === null || _a === void 0 ? void 0 : _a.length) || 0;
55
+ const currentPage = ((_b = lastPage === null || lastPage === void 0 ? void 0 : lastPage.pageable) === null || _b === void 0 ? void 0 : _b.pageNumber) || 1;
56
+ return dataLength < pageSize ? undefined : currentPage + 1;
57
+ },
58
+ enabled: hasValidFilter(filter),
59
+ }), { data, fetchNextPage, hasNextPage, isFetchingNextPage, isLoading } = _a, rest = __rest(_a, ["data", "fetchNextPage", "hasNextPage", "isFetchingNextPage", "isLoading"]);
60
+ const { dataFlatten } = useMemo(() => {
61
+ if (!data)
62
+ return {
63
+ dataFlatten: [],
64
+ };
65
+ const allItems = data.pages.flatMap((page) => page.data);
66
+ return {
67
+ dataFlatten: allItems,
68
+ };
69
+ }, [data]);
70
+ return Object.assign({ data,
71
+ fetchNextPage,
72
+ hasNextPage,
73
+ isFetchingNextPage,
74
+ isLoading,
75
+ dataFlatten }, rest);
76
+ };
77
+ function hasValidFilter(filter) {
78
+ return Object.values(filter).some((v) => {
79
+ if (typeof v === "string")
80
+ return v.trim() !== "";
81
+ return v !== undefined && v !== null;
82
+ });
83
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"useGetSessionSummary.d.ts","sourceRoot":"","sources":["../../../src/hooks/session/useGetSessionSummary.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAExE,eAAO,MAAM,oBAAoB,sFAY7B,CAAC"}
1
+ {"version":3,"file":"useGetSessionSummary.d.ts","sourceRoot":"","sources":["../../../src/hooks/session/useGetSessionSummary.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAGxE,eAAO,MAAM,oBAAoB,sFAY7B,CAAC"}
@@ -2,12 +2,13 @@ import { useQuery } from "@tanstack/react-query";
2
2
  import { QUERY_KEYS } from "../../services/query";
3
3
  import { apiInstance } from "../../services/api";
4
4
  import { ENDPOINTS } from "../../services/routes";
5
+ import useAuthStore from "../../store/auth";
5
6
  export const useGetSessionSummary = () => useQuery({
6
7
  queryKey: [QUERY_KEYS.GET_SESSION_SUMMARY],
7
8
  queryFn: async () => {
8
9
  var _a;
9
10
  const res = await apiInstance.post(ENDPOINTS.chatService.getSessionSummary, {
10
- applicationType: "OBEFE",
11
+ applicationType: useAuthStore.getState().applicationType,
11
12
  });
12
13
  return (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.data;
13
14
  },
@@ -1 +1 @@
1
- {"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../../src/hooks/user/useAuth.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,YAAY;;CAoBxB,CAAC"}
1
+ {"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../../src/hooks/user/useAuth.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,YAAY;;CAwBxB,CAAC"}
@@ -2,20 +2,22 @@ import { Platform } from "@openim/wasm-client-sdk";
2
2
  import { DChatSDK } from "../../constants/sdk";
3
3
  import useAuthStore from "../../store/auth";
4
4
  import useConversationStore from "../../store/conversation";
5
+ import { DChatApplicationType } from "../../types/chat";
5
6
  export const useDChatAuth = () => {
6
7
  const initAuthStore = useAuthStore((state) => state.initAuthStore);
7
8
  const resetConversationStore = useConversationStore((state) => state.resetConversationStore);
8
9
  const logout = async () => {
9
- const res = await DChatSDK.logout();
10
- resetConversationStore();
11
- initAuthStore({
10
+ await Promise.resolve(resetConversationStore());
11
+ await Promise.resolve(initAuthStore({
12
12
  chatToken: "",
13
13
  accessToken: "",
14
14
  apiAddress: "",
15
15
  wsAddress: "",
16
16
  platformID: Platform.Web,
17
17
  userID: "",
18
- });
18
+ applicationType: DChatApplicationType.OBEFE,
19
+ }));
20
+ const res = await DChatSDK.logout();
19
21
  return res;
20
22
  };
21
23
  return { logout };
package/dist/index.d.ts CHANGED
@@ -4,11 +4,11 @@ import DChatBubble from "./screens/chatBubble";
4
4
  import { Platform, LogLevel, SessionType } from "@openim/wasm-client-sdk";
5
5
  import { Icon } from "./components/icon";
6
6
  import useUserStore from "./store/user";
7
- import { DChatInitAndLoginConfig } from "./types/chat";
7
+ import { DChatInitAndLoginConfig, DChatApplicationType } from "./types/chat";
8
8
  export { ChatProvider, useChatContext } from "./context/ChatContext";
9
9
  export { DChatDeskMessage, DChatBubble, Icon };
10
10
  export { useDChatAuth } from "./hooks/user/useAuth";
11
- export { useUserStore };
11
+ export { useUserStore, DChatApplicationType };
12
12
  export { Platform as DChatPlatform, LogLevel as DChatLogLevel, SessionType as DChatSessionType, };
13
13
  export type { DChatInitAndLoginConfig };
14
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AAExB,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AACrD,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,YAAY,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGrE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;AAG/C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAE,CAAC;AAIxB,OAAO,EACL,QAAQ,IAAI,aAAa,EACzB,QAAQ,IAAI,aAAa,EACzB,WAAW,IAAI,gBAAgB,GAChC,CAAC;AAEF,YAAY,EAAE,uBAAuB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AAExB,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AACrD,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,YAAY,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAG7E,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGrE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;AAG/C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,CAAC;AAI9C,OAAO,EACL,QAAQ,IAAI,aAAa,EACzB,QAAQ,IAAI,aAAa,EACzB,WAAW,IAAI,gBAAgB,GAChC,CAAC;AAEF,YAAY,EAAE,uBAAuB,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ import DChatBubble from "./screens/chatBubble";
4
4
  import { Platform, LogLevel, SessionType } from "@openim/wasm-client-sdk";
5
5
  import { Icon } from "./components/icon";
6
6
  import useUserStore from "./store/user";
7
+ import { DChatApplicationType } from "./types/chat";
7
8
  // Main exports for the SDK
8
9
  export { ChatProvider, useChatContext } from "./context/ChatContext";
9
10
  //Components
@@ -11,6 +12,6 @@ export { DChatDeskMessage, DChatBubble, Icon };
11
12
  //Hooks
12
13
  export { useDChatAuth } from "./hooks/user/useAuth";
13
14
  //Store
14
- export { useUserStore };
15
+ export { useUserStore, DChatApplicationType };
15
16
  // export * from "./types/sdk";
16
17
  export { Platform as DChatPlatform, LogLevel as DChatLogLevel, SessionType as DChatSessionType, };
@@ -20,5 +20,8 @@
20
20
  "completed": "Đã đóng",
21
21
  "awaiting_reply": "Chưa trả lời",
22
22
  "slow_processing": "Chậm xử lý",
23
- "temporarily_paused": "Tạm chờ"
23
+ "temporarily_paused": "Tạm chờ",
24
+ "see_more": "Xem thêm",
25
+ "err_get_conversation": "Lỗi khi lấy thông tin cuộc trò chuyện",
26
+ "enter_message": "Nhập tin nhắn"
24
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screens/deskMessage/index.tsx"],"names":[],"mappings":"AAUA,QAAA,MAAM,gBAAgB,+CAuBrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screens/deskMessage/index.tsx"],"names":[],"mappings":"AAUA,QAAA,MAAM,gBAAgB,+CA6BrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -9,7 +9,8 @@ import useConversationStore from "../../store/conversation";
9
9
  import DeskAssignedSession from "../../components/session/DeskAssignedSession";
10
10
  const DChatDeskMessage = () => {
11
11
  const selectedConversationId = useConversationStore((state) => state.selectedConversationId);
12
+ const searchClientMsgID = useConversationStore((state) => state.searchClientMsgID);
12
13
  const { connectStatus, syncStatus } = useChatContext();
13
- return (_jsx(_Fragment, { children: connectStatus === ConnectStatus.Connected ? (_jsx(Spin, { spinning: syncStatus === SyncStatus.Loading, children: _jsxs("div", { className: "flex flex-1 flex-row h-screen bg-gray-50", children: [_jsx(DeskAssignedSession, {}), _jsx(DeskConversationList, {}), _jsx(MessageList, { conversationId: selectedConversationId })] }) })) : (_jsx("div", { className: "flex flex-1 flex-row h-screen bg-gray-50", children: connectStatus === ConnectStatus.Connecting && _jsx(Spin, { fullscreen: true }) })) }));
14
+ return (_jsx(_Fragment, { children: connectStatus === ConnectStatus.Connected ? (_jsx(Spin, { spinning: syncStatus === SyncStatus.Loading, children: _jsxs("div", { className: "flex flex-1 flex-row h-screen bg-gray-50", children: [_jsx(DeskAssignedSession, {}), _jsx(DeskConversationList, {}), _jsx(MessageList, { conversationId: selectedConversationId, searchClientMsgID: searchClientMsgID })] }) })) : (_jsx("div", { className: "flex flex-1 flex-row h-screen bg-gray-50", children: connectStatus === ConnectStatus.Connecting && _jsx(Spin, { fullscreen: true }) })) }));
14
15
  };
15
16
  export default DChatDeskMessage;
@@ -1,7 +1,7 @@
1
1
  export declare const QUERY_KEYS: {
2
2
  REFRESH_CHAT_TOKEN: string;
3
- GET_IMAGE_COLLECTION: string;
4
3
  GET_SESSION_SUMMARY: string;
5
4
  GET_SESSION_BY_TAG_OR_STATUS: string;
5
+ SEARCH_MESSAGE: string;
6
6
  };
7
7
  //# sourceMappingURL=query.d.ts.map
@@ -1,6 +1,6 @@
1
1
  export const QUERY_KEYS = {
2
2
  REFRESH_CHAT_TOKEN: "REFRESH_CHAT_TOKEN",
3
- GET_IMAGE_COLLECTION: "GET_IMAGE_COLLECTION",
4
3
  GET_SESSION_SUMMARY: "GET_SESSION_SUMMARY",
5
4
  GET_SESSION_BY_TAG_OR_STATUS: "GET_SESSION_BY_TAG_OR_STATUS",
5
+ SEARCH_MESSAGE: "SEARCH_MESSAGE",
6
6
  };
@@ -3,7 +3,7 @@ export declare const ENDPOINTS: {
3
3
  getChatToken: string;
4
4
  getSessionSummary: string;
5
5
  getSessionsByTagOrStatus: string;
6
- getMediaCollection: string;
6
+ searchMessage: string;
7
7
  };
8
8
  identityService: {
9
9
  getToken: string;
@@ -3,7 +3,7 @@ export const ENDPOINTS = {
3
3
  getChatToken: "/chat-service/v1/auth/token",
4
4
  getSessionSummary: "chat-service/v1/crm/sessions/assigned/summary",
5
5
  getSessionsByTagOrStatus: "chat-service/v1/crm/sessions/assigned/query",
6
- getMediaCollection: "chat-service/v1/messages/search/media",
6
+ searchMessage: "chat-service/v1/messages/search",
7
7
  },
8
8
  identityService: {
9
9
  getToken: "/identity-service/v1/identity/get-token",
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/store/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGnC,QAAA,MAAM,YAAY,wEAmBf,CAAC;AAEJ,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/store/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAInC,QAAA,MAAM,YAAY,wEA6Bf,CAAC;AAEJ,eAAe,YAAY,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { create } from "zustand";
2
2
  import { Platform } from "@openim/wasm-client-sdk";
3
+ import { DChatApplicationType } from "../types/chat";
3
4
  const useAuthStore = create((set, get) => ({
4
5
  accessToken: "",
5
6
  chatToken: "",
@@ -7,10 +8,19 @@ const useAuthStore = create((set, get) => ({
7
8
  wsAddress: "",
8
9
  platformID: Platform.Web,
9
10
  userID: "",
11
+ applicationType: DChatApplicationType.OBEFE,
10
12
  setAccessToken: (token) => set({ accessToken: token }),
11
13
  setChatToken: (token) => set({ chatToken: token }),
12
- initAuthStore: ({ accessToken, chatToken, apiAddress, wsAddress, platformID, userID, }) => {
13
- set({ accessToken, chatToken, apiAddress, wsAddress, platformID, userID });
14
+ initAuthStore: ({ accessToken, chatToken, apiAddress, wsAddress, platformID, userID, applicationType, }) => {
15
+ set({
16
+ accessToken,
17
+ chatToken,
18
+ apiAddress,
19
+ wsAddress,
20
+ platformID,
21
+ userID,
22
+ applicationType,
23
+ });
14
24
  },
15
25
  }));
16
26
  export default useAuthStore;
@@ -1 +1 @@
1
- {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../src/store/conversation.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAO3C,QAAA,MAAM,oBAAoB,gFAkJvB,CAAC;AAEJ,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../src/store/conversation.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAO3C,QAAA,MAAM,oBAAoB,gFAwJvB,CAAC;AAEJ,eAAe,oBAAoB,CAAC"}
@@ -7,11 +7,12 @@ import { markConversationMessageAsRead } from "../hooks/conversation/useConversa
7
7
  const CONVERSATION_SPLIT_COUNT = 500;
8
8
  const useConversationStore = create((set, get) => ({
9
9
  conversationData: null,
10
- setConversationData: (data) => set({
10
+ setConversationData: (data, dataSearchClientMsgID) => set({
11
11
  conversationData: data,
12
12
  selectedSourceId: (data === null || data === void 0 ? void 0 : data.conversationType) === SessionType.Group
13
13
  ? data === null || data === void 0 ? void 0 : data.groupID
14
14
  : data === null || data === void 0 ? void 0 : data.userID,
15
+ searchClientMsgID: dataSearchClientMsgID,
15
16
  }),
16
17
  selectedConversationId: "",
17
18
  setSelectedConversationId: (threadId) => set({ selectedConversationId: threadId }),
@@ -121,5 +122,10 @@ const useConversationStore = create((set, get) => ({
121
122
  currentMemberInGroup: undefined,
122
123
  });
123
124
  },
125
+ //search
126
+ searchClientMsgID: "",
127
+ setSearchClientMsgID: (clientMsgID) => {
128
+ set({ searchClientMsgID: clientMsgID });
129
+ },
124
130
  }));
125
131
  export default useConversationStore;