@pubuduth-aplicy/chat-ui 2.0.8 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pubuduth-aplicy/chat-ui",
3
- "version": "2.0.8",
3
+ "version": "2.1.0",
4
4
  "description": "This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.",
5
5
  "license": "ISC",
6
6
  "author": "",
@@ -1,15 +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 } from "../types/type";
4
5
 
5
6
 
6
7
  export const getAllConversationData = async (userid: string) => {
7
- try {
8
- const res = await apiClient.get(`${Path.getconversation}/${userid}`);
9
- return res.data;
10
- } catch (error: any) {
11
- console.log("ERROR: ", error);
12
- // logger.error(error);
13
- throw error;
14
- }
15
- };
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
@@ -1,3 +1,37 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1
2
  export interface ChatWindowProps {
2
3
  userId: string;
3
- }
4
+ }
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
+
21
+ export interface Conversation {
22
+ _id: string;
23
+ createdAt: string;
24
+ updatedAt: string;
25
+ __v: number;
26
+ participantDetails: ParticipantDetails;
27
+ }
28
+
29
+ export interface ServiceInfo {
30
+ conversationsWithParticipantDetails: Conversation[];
31
+ }
32
+
33
+ export interface ApiResponse {
34
+ success: boolean;
35
+ message: string;
36
+ serviceInfo: ServiceInfo;
37
+ }