@pubuduth-aplicy/chat-ui 2.2.16 → 2.2.18

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.2.16",
3
+ "version": "2.2.18",
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,9 +1,12 @@
1
+ import { AxiosInstance } from "axios";
2
+
1
3
  // config.ts
2
4
  export interface ChatConfig {
3
5
  apiUrl: string;
4
6
  role: string;
5
7
  cdnUrl?: string;
6
8
  webSocketUrl: string;
9
+ apiClient:AxiosInstance
7
10
  }
8
11
 
9
12
  let chatConfig: ChatConfig;
@@ -40,6 +40,7 @@ interface MessageProps {
40
40
  bookingId: string;
41
41
  status: string; // e.g., "confirmed", "pending", "cancelled"
42
42
  serviceId: string;
43
+ serviceName: string;
43
44
  date: string;
44
45
  time: string;
45
46
  price: number;
@@ -91,7 +92,7 @@ const Message = ({ message }: MessageProps) => {
91
92
  <div className="system-message booking-details">
92
93
  <h4>{status}</h4>
93
94
  <div className="details">
94
- <p>Service: {booking?.serviceId}</p>
95
+ <p>Service: {booking?.serviceName}</p>
95
96
  <p>Date: {booking?.date.split("T")[0]}</p>
96
97
  <p>Time: {booking?.time}</p>
97
98
  </div>
@@ -115,7 +116,7 @@ const Message = ({ message }: MessageProps) => {
115
116
  </button>
116
117
  )}
117
118
 
118
- {status === "Completed" && (
119
+ {status === "Completed" && role !== "provider" && (
119
120
  <button className="confirm-button" onClick={handleReview}>
120
121
  Leave a Review ✍️
121
122
  </button>
@@ -4,7 +4,6 @@ import { useMessageMutation } from "../../hooks/mutations/useSendMessage";
4
4
  import { useChatContext } from "../../providers/ChatProvider";
5
5
  import useChatUIStore from "../../stores/Zustant";
6
6
  import { FilePreview, FileType } from "../common/FilePreview";
7
- import { getApiClient } from "../../lib/api/apiClient";
8
7
  import { MessageStatus } from "../../types/type";
9
8
  import { Path } from "../../lib/api/endpoint";
10
9
  import { getChatConfig } from "../../Chat.config";
@@ -36,8 +35,8 @@ interface Attachment {
36
35
  }
37
36
 
38
37
  const MessageInput = () => {
39
- const apiClient = getApiClient();
40
- const { role } = getChatConfig();
38
+ // const apiClient = getApiClient();
39
+ const { role, apiClient ,apiUrl} = getChatConfig();
41
40
  const { socket, sendMessage, userId } = useChatContext();
42
41
  const { selectedConversation, setMessages, setLastSentMessage } = useChatUIStore();
43
42
 
@@ -315,7 +314,7 @@ const MessageInput = () => {
315
314
  file: File,
316
315
  onProgress?: (progress: number) => void
317
316
  ): Promise<{ url: string; name: string; size: number; type: FileType }> => {
318
- const response = await apiClient.post(`${Path.preSignUrl}`, {
317
+ const response = await apiClient.post(`${apiUrl}/${Path.preSignUrl}`, {
319
318
  fileName: file.name,
320
319
  fileType: file.type,
321
320
  conversationId: selectedConversation?._id,
@@ -23,6 +23,7 @@ declare module '@pubuduth-aplicy/chat-ui' {
23
23
  role?: string;
24
24
  webSocketUrl: string;
25
25
  cdnUrl?: string;
26
+ apiClient:AxiosInstance
26
27
  }
27
28
 
28
29
  interface ChatProviderProps {
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { getChatConfig } from "../Chat.config";
2
3
  import { FileType } from "../components/common/FilePreview";
3
- import { getApiClient } from "../lib/api/apiClient";
4
4
  import { Path } from "../lib/api/endpoint";
5
5
 
6
6
  export const sendMessage = async (params: {
@@ -27,10 +27,11 @@ export const sendMessage = async (params: {
27
27
  senderRole,
28
28
  receiverRole,
29
29
  } = params;
30
- const apiClient = getApiClient();
30
+ // const apiClient = getApiClient();
31
+ const {apiClient,apiUrl} = getChatConfig();
31
32
 
32
33
  const response = await apiClient.post(
33
- `${Path.sendmessage}/${receiverId}/${senderId}`,
34
+ `${apiUrl}/${Path.sendmessage}/${receiverId}/${senderId}`,
34
35
  {
35
36
  message,
36
37
  attachments,
@@ -48,9 +49,9 @@ export const sendMessage = async (params: {
48
49
 
49
50
 
50
51
  export const fetchMessages = async (chatId: string | undefined, userid: string, pagenum: number) => {
51
- const apiClient = getApiClient();
52
+ const {apiClient,apiUrl} = getChatConfig();
52
53
  try {
53
- const response = await apiClient.get(`${Path.getmessage}/${chatId}/${userid}`, {
54
+ const response = await apiClient.get(`${apiUrl}/${Path.getmessage}/${chatId}/${userid}`, {
54
55
  params: { pagenum, limit: 20 },
55
56
  });
56
57
  // console.log(response);
@@ -70,9 +71,9 @@ export const setEditMessage = async ({
70
71
  userId: string;
71
72
  newMessage: string;
72
73
  }) => {
73
- const apiClient = getApiClient();
74
+ const {apiClient,apiUrl} = getChatConfig();
74
75
  try {
75
- const response = await apiClient.put(`${Path.editMessage}/${messageId}`, {
76
+ const response = await apiClient.put(`${apiUrl}/${Path.editMessage}/${messageId}`, {
76
77
  userId,
77
78
  newMessage
78
79
  });
@@ -91,10 +92,10 @@ export const deleteMessage = async ({
91
92
  messageId: string;
92
93
  userId: string;
93
94
  }) => {
94
- const apiClient = getApiClient();
95
+ const {apiClient,apiUrl} = getChatConfig();
95
96
  try {
96
97
  const response = await apiClient.delete(
97
- `${Path.deleteMessage}/${messageId}`,
98
+ `${apiUrl}/${Path.deleteMessage}/${messageId}`,
98
99
  {
99
100
  data: { userId }
100
101
  }
@@ -1,18 +1,17 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import { getChatConfig } from "../Chat.config";
3
- import { getApiClient } from "../lib/api/apiClient";
4
3
  import { Path } from "../lib/api/endpoint";
5
4
  import { ApiResponse } from "../types/type";
6
5
 
7
6
 
8
7
  export const getAllConversationData = async (userid: string) => {
9
8
  try {
10
- const {role} = getChatConfig();
11
- const apiClient = getApiClient();
9
+ const {role, apiClient,apiUrl} = getChatConfig();
10
+ // const apiClient = getApiClient();
12
11
 
13
12
  const endpoint = role === 'admin'
14
- ? `${Path.getConversationListByAdmin}`
15
- : `${Path.getconversation}/${userid}/${role}`;
13
+ ? `${apiUrl}/${Path.getConversationListByAdmin}`
14
+ : `${apiUrl}/${Path.getconversation}/${userid}/${role}`;
16
15
 
17
16
  const res = await apiClient.get<ApiResponse>(endpoint);
18
17
  if (res.data) {