@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.mjs CHANGED
@@ -26230,51 +26230,6 @@ const getToken = () => {
26230
26230
  return accessToken;
26231
26231
  };
26232
26232
 
26233
- // import requester from '../requester'
26234
- const { URL_API } = CHAT;
26235
- const chatApi = {
26236
- getHistory: async (params) => {
26237
- const queryString = new URLSearchParams(params).toString();
26238
- const response = await fetch(`${URL_API.GET_HISTORY_API}?${queryString}`, {
26239
- headers: {
26240
- 'Authorization': `Bearer ${getToken()}`,
26241
- 'Content-Type': 'application/json'
26242
- }
26243
- });
26244
- if (!response.ok)
26245
- throw new Error(`Error: ${response.status}`);
26246
- return response.json();
26247
- }
26248
- //getHistoryActive: (params: any) => requester.get(URL_API.GET_HISTORY_API, params, config),
26249
- //getHistory: (params: any) => requester.get(URL_API.GET_HISTORY_API, params, config)
26250
- // getHistory: (params: any) => {
26251
- // console.log('getHistory params', params)
26252
- // return params
26253
- // }
26254
- // getMessageByGroupCursor: (id:string, params: any) => requester.get(`${URL_API.GET_MESSAGE_BY_GROUP_CURSOR_API}/${id}`, params, config),
26255
- // getInfo: (params: any) => requester.get(URL_API.GET_INFO_API, params, config),
26256
- // groups: (params: any) => requester.post(URL_API.GROUP_API, params, config),
26257
- // addMemberGroup: (params: any) => requester.post(`${URL_API.ADD_MEMBER_GROUP}`, params, config),
26258
- // senMessage: (id: string, params: any, tickerDto?: any) => requester.post(`${URL_API.SEN_MESSAGE_API}/${id}`, { ...params, tickerDto }, config),
26259
- // deleteMessage: (id: string, chatRoomId: string) => requester.delete(`${URL_API.MESSAGE_API}/${chatRoomId}/delete-message/${id}`, {}, config),
26260
- // recallMessage: (id: string, chatRoomId: string) => requester.put(`${URL_API.MESSAGE_API}/${chatRoomId}/recall-message/${id}`, {}, config),
26261
- // updateGroupAvatar: (params: any) => requester.put(URL_API.UPDATE_GROUP_AVATAR_API, params, config),
26262
- // getMessageByGroup: (params: any, paging: any) => requester.get(`${URL_API.GET_MESSAGE_BY_GROUP_API}/${params}`, paging, config),
26263
- // getMessageByContact: (params: any, paging: any) => requester.get(`${URL_API.GET_MESSAGE_BY_CONTACT_API}/${params}`, paging, config),
26264
- // contactAdd: (params: any) => requester.post(URL_API.CONTACT_ADD_API, params, config),
26265
- // getProfile: () => requester.get(URL_API.GET_PROFILE, {}, config),
26266
- // getUsers: (params: any) => requester.get(URL_API.GET_USERS, params, config),
26267
- // getContact: (params: any) => requester.get(URL_API.GET_CONTACT_API, params, config),
26268
- // updateChatRoomMember: (params: any) => requester.put(`${URL_API.CHAT_ROOM_MEMBER_API}/${params}`, {}, config),
26269
- // getPagingEmployeeApi: (params: any) => requester.get(URL_API.GET_PAGING_EMPLOYEE_API, params, config),
26270
- // connectChatRoomMemberApi: (params: any) => requester.post(URL_API.CONNECT_CHAT_ROOM_MEMBER_API, params, config),
26271
- // pinMessageChatRoomApi: (params: any) => requester.post(`${URL_API.PIN_MESSAGE_CHAT_ROOM_API}/${params.id}`, params, config),
26272
- // getPinMessagesByRoomApi: (chatRoomId: string) => requester.get(`${URL_API.GET_PIN_MESSAGE_CHAT_ROOM_API}/${chatRoomId}`, {}, config),
26273
- // deletePinMessageApi: (pinId: string) => requester.delete(`${URL_API.PIN_MESSAGE_CHAT_ROOM_API}/${pinId}`, {}, config),
26274
- // updateGroupTagApi: (params: any) => requester.put(URL_API.UPDATE_GROUP_TAG_API, params, config),
26275
- // createReminderApi: (params: any) => requester.post(URL_API.CREATE_REMINDER_API, params, config)
26276
- };
26277
-
26278
26233
  // ** Redux Imports
26279
26234
  // Convert 1 bản ghi PinMessage từ backend thành object message dùng cho UI ghim
26280
26235
  const mapPinRecordToMessage = (record) => {
@@ -26319,10 +26274,22 @@ const initialState = {
26319
26274
  };
26320
26275
  const get_history = createAsyncThunk(CHAT.ACTION_TYPES.GET_HISTORY, async (params, thunkAPI) => {
26321
26276
  try {
26322
- return await chatApi.getHistory(params);
26277
+ const queryString = new URLSearchParams(params).toString();
26278
+ const response = await fetch(`${CHAT.URL_API.GET_HISTORY_API}?${queryString}`, {
26279
+ method: 'GET',
26280
+ headers: {
26281
+ 'Authorization': `Bearer ${getToken()}`,
26282
+ 'Content-Type': 'application/json'
26283
+ }
26284
+ });
26285
+ if (!response.ok) {
26286
+ throw new Error(`HTTP error! status: ${response.status}`);
26287
+ }
26288
+ const data = await response.json();
26289
+ return data;
26323
26290
  }
26324
26291
  catch (error) {
26325
- return thunkAPI.rejectWithValue({ error: error.response.data });
26292
+ return thunkAPI.rejectWithValue({ error: error.message });
26326
26293
  }
26327
26294
  });
26328
26295
  // export const get_history = createAsyncThunk<any, any>(CHAT.ACTION_TYPES.GET_HISTORY, async (params, thunkAPI) => {