@pubuduth-aplicy/chat-ui 2.1.47 → 2.1.49
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/package.json
CHANGED
package/src/index.tsx
CHANGED
package/src/lib/api/apiClient.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
// apiClient.ts
|
|
1
2
|
import axios from "axios";
|
|
2
3
|
import { getChatConfig } from "../../Chat.config";
|
|
3
4
|
|
|
4
|
-
const
|
|
5
|
-
|
|
5
|
+
export const getApiClient = () => {
|
|
6
|
+
const { apiUrl } = getChatConfig(); // ✅ safe: runs after init
|
|
7
|
+
return axios.create({
|
|
6
8
|
baseURL: apiUrl,
|
|
7
9
|
timeout: 5000,
|
|
8
|
-
withCredentials:true,
|
|
10
|
+
withCredentials: true,
|
|
9
11
|
headers: {
|
|
10
|
-
|
|
12
|
+
"Content-Type": "application/json",
|
|
11
13
|
},
|
|
12
14
|
});
|
|
13
|
-
|
|
15
|
+
};
|
|
16
|
+
|
|
14
17
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import {
|
|
2
|
+
import { getApiClient } from "../lib/api/apiClient";
|
|
3
3
|
import { Path } from "../lib/api/endpoint";
|
|
4
4
|
|
|
5
5
|
export const sendMessage = async ({ chatId,senderId, message }: { chatId: any; senderId:any; message: string }) => {
|
|
6
|
+
const apiClient = getApiClient();
|
|
6
7
|
const response = await apiClient.post(`${Path.sendmessage}/${chatId}/${senderId}`, {
|
|
7
8
|
message:message
|
|
8
9
|
})
|
|
@@ -11,6 +12,7 @@ export const sendMessage = async ({ chatId,senderId, message }: { chatId: any; s
|
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
export const fetchMessages = async (chatId: string|undefined, userid: string,pagenum:number) => {
|
|
15
|
+
const apiClient = getApiClient();
|
|
14
16
|
try {
|
|
15
17
|
const response = await apiClient.get(`${Path.getmessage}/${chatId}/${userid}`,{
|
|
16
18
|
params: { pagenum, limit: 20 },
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import {
|
|
2
|
+
import { getApiClient } from "../lib/api/apiClient";
|
|
3
3
|
import { Path } from "../lib/api/endpoint";
|
|
4
4
|
import { ApiResponse } from "../types/type";
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
export const getAllConversationData = async (userid: string) => {
|
|
8
8
|
try {
|
|
9
|
+
const apiClient = getApiClient();
|
|
9
10
|
const res = await apiClient.get<ApiResponse>(`${Path.getconversation}/${userid}`);
|
|
10
11
|
if (res.data) {
|
|
11
12
|
console.log("API Response: ", res.data);
|