@pubuduth-aplicy/chat-ui 2.0.9 → 2.1.0
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 +1 -1
- package/src/service/sidebarApi.ts +22 -16
- package/src/types/type.ts +28 -4
package/package.json
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import { apiClient } from "../lib/api/apiClient";
|
|
3
3
|
import { Path } from "../lib/api/endpoint";
|
|
4
|
-
import { ApiResponse
|
|
4
|
+
import { ApiResponse } from "../types/type";
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
export const getAllConversationData = async (userid: string) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
8
|
+
try {
|
|
9
|
+
const res = await apiClient.get<ApiResponse>(`${Path.getconversation}/${userid}`);
|
|
10
|
+
|
|
11
|
+
// Access conversations with participant details from the API response
|
|
12
|
+
const { conversationsWithParticipantDetails } = res.data.serviceInfo;
|
|
13
|
+
|
|
14
|
+
// If needed, you can map the conversations in the specific structure
|
|
15
|
+
const formattedConversations = conversationsWithParticipantDetails.map((conversation) => ({
|
|
16
|
+
_id: conversation._id,
|
|
17
|
+
participantDetails: conversation.participantDetails,
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
// Return the formatted conversations
|
|
21
|
+
return formattedConversations;
|
|
22
|
+
} catch (error: any) {
|
|
23
|
+
console.error("ERROR: ", error);
|
|
24
|
+
// Optionally log the error to an external logger
|
|
25
|
+
// logger.error(error);
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
};
|
package/src/types/type.ts
CHANGED
|
@@ -3,11 +3,35 @@ export interface ChatWindowProps {
|
|
|
3
3
|
userId: string;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
+
export interface ParticipantDetails {
|
|
7
|
+
_id: string;
|
|
8
|
+
username: string;
|
|
9
|
+
password: string;
|
|
10
|
+
acctype: string;
|
|
11
|
+
contactno: string;
|
|
12
|
+
country: string;
|
|
13
|
+
email: string;
|
|
14
|
+
verified: string;
|
|
15
|
+
profilePic: string;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
updatedAt: string;
|
|
18
|
+
__v: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
6
21
|
export interface Conversation {
|
|
7
22
|
_id: string;
|
|
8
|
-
|
|
23
|
+
createdAt: string;
|
|
24
|
+
updatedAt: string;
|
|
25
|
+
__v: number;
|
|
26
|
+
participantDetails: ParticipantDetails;
|
|
9
27
|
}
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
|
|
28
|
+
|
|
29
|
+
export interface ServiceInfo {
|
|
30
|
+
conversationsWithParticipantDetails: Conversation[];
|
|
13
31
|
}
|
|
32
|
+
|
|
33
|
+
export interface ApiResponse {
|
|
34
|
+
success: boolean;
|
|
35
|
+
message: string;
|
|
36
|
+
serviceInfo: ServiceInfo;
|
|
37
|
+
}
|