@esvndev/es-react-template-chat 0.0.29 → 0.0.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.
package/dist/index.js CHANGED
@@ -26253,51 +26253,6 @@ const getToken = () => {
26253
26253
  return accessToken;
26254
26254
  };
26255
26255
 
26256
- // import requester from '../requester'
26257
- const { URL_API } = CHAT;
26258
- const chatApi = {
26259
- getHistory: async (params) => {
26260
- const queryString = new URLSearchParams(params).toString();
26261
- const response = await fetch(`${URL_API.GET_HISTORY_API}?${queryString}`, {
26262
- headers: {
26263
- 'Authorization': `Bearer ${getToken()}`,
26264
- 'Content-Type': 'application/json'
26265
- }
26266
- });
26267
- if (!response.ok)
26268
- throw new Error(`Error: ${response.status}`);
26269
- return response.json();
26270
- }
26271
- //getHistoryActive: (params: any) => requester.get(URL_API.GET_HISTORY_API, params, config),
26272
- //getHistory: (params: any) => requester.get(URL_API.GET_HISTORY_API, params, config)
26273
- // getHistory: (params: any) => {
26274
- // console.log('getHistory params', params)
26275
- // return params
26276
- // }
26277
- // getMessageByGroupCursor: (id:string, params: any) => requester.get(`${URL_API.GET_MESSAGE_BY_GROUP_CURSOR_API}/${id}`, params, config),
26278
- // getInfo: (params: any) => requester.get(URL_API.GET_INFO_API, params, config),
26279
- // groups: (params: any) => requester.post(URL_API.GROUP_API, params, config),
26280
- // addMemberGroup: (params: any) => requester.post(`${URL_API.ADD_MEMBER_GROUP}`, params, config),
26281
- // senMessage: (id: string, params: any, tickerDto?: any) => requester.post(`${URL_API.SEN_MESSAGE_API}/${id}`, { ...params, tickerDto }, config),
26282
- // deleteMessage: (id: string, chatRoomId: string) => requester.delete(`${URL_API.MESSAGE_API}/${chatRoomId}/delete-message/${id}`, {}, config),
26283
- // recallMessage: (id: string, chatRoomId: string) => requester.put(`${URL_API.MESSAGE_API}/${chatRoomId}/recall-message/${id}`, {}, config),
26284
- // updateGroupAvatar: (params: any) => requester.put(URL_API.UPDATE_GROUP_AVATAR_API, params, config),
26285
- // getMessageByGroup: (params: any, paging: any) => requester.get(`${URL_API.GET_MESSAGE_BY_GROUP_API}/${params}`, paging, config),
26286
- // getMessageByContact: (params: any, paging: any) => requester.get(`${URL_API.GET_MESSAGE_BY_CONTACT_API}/${params}`, paging, config),
26287
- // contactAdd: (params: any) => requester.post(URL_API.CONTACT_ADD_API, params, config),
26288
- // getProfile: () => requester.get(URL_API.GET_PROFILE, {}, config),
26289
- // getUsers: (params: any) => requester.get(URL_API.GET_USERS, params, config),
26290
- // getContact: (params: any) => requester.get(URL_API.GET_CONTACT_API, params, config),
26291
- // updateChatRoomMember: (params: any) => requester.put(`${URL_API.CHAT_ROOM_MEMBER_API}/${params}`, {}, config),
26292
- // getPagingEmployeeApi: (params: any) => requester.get(URL_API.GET_PAGING_EMPLOYEE_API, params, config),
26293
- // connectChatRoomMemberApi: (params: any) => requester.post(URL_API.CONNECT_CHAT_ROOM_MEMBER_API, params, config),
26294
- // pinMessageChatRoomApi: (params: any) => requester.post(`${URL_API.PIN_MESSAGE_CHAT_ROOM_API}/${params.id}`, params, config),
26295
- // getPinMessagesByRoomApi: (chatRoomId: string) => requester.get(`${URL_API.GET_PIN_MESSAGE_CHAT_ROOM_API}/${chatRoomId}`, {}, config),
26296
- // deletePinMessageApi: (pinId: string) => requester.delete(`${URL_API.PIN_MESSAGE_CHAT_ROOM_API}/${pinId}`, {}, config),
26297
- // updateGroupTagApi: (params: any) => requester.put(URL_API.UPDATE_GROUP_TAG_API, params, config),
26298
- // createReminderApi: (params: any) => requester.post(URL_API.CREATE_REMINDER_API, params, config)
26299
- };
26300
-
26301
26256
  // ** Redux Imports
26302
26257
  // Convert 1 bản ghi PinMessage từ backend thành object message dùng cho UI ghim
26303
26258
  const mapPinRecordToMessage = (record) => {
@@ -26342,10 +26297,22 @@ const initialState = {
26342
26297
  };
26343
26298
  const get_history = toolkit.createAsyncThunk(CHAT.ACTION_TYPES.GET_HISTORY, async (params, thunkAPI) => {
26344
26299
  try {
26345
- return await chatApi.getHistory(params);
26300
+ const queryString = new URLSearchParams(params).toString();
26301
+ const response = await fetch(`${CHAT.URL_API.GET_HISTORY_API}?${queryString}`, {
26302
+ method: 'GET',
26303
+ headers: {
26304
+ 'Authorization': `Bearer ${getToken()}`,
26305
+ 'Content-Type': 'application/json'
26306
+ }
26307
+ });
26308
+ if (!response.ok) {
26309
+ throw new Error(`HTTP error! status: ${response.status}`);
26310
+ }
26311
+ const data = await response.json();
26312
+ return data;
26346
26313
  }
26347
26314
  catch (error) {
26348
- return thunkAPI.rejectWithValue({ error: error.response.data });
26315
+ return thunkAPI.rejectWithValue({ error: error.message });
26349
26316
  }
26350
26317
  });
26351
26318
  // export const get_history = createAsyncThunk<any, any>(CHAT.ACTION_TYPES.GET_HISTORY, async (params, thunkAPI) => {