@pubuduth-aplicy/chat-ui 2.2.16 → 2.2.17

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.17",
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>
@@ -36,8 +36,8 @@ interface Attachment {
36
36
  }
37
37
 
38
38
  const MessageInput = () => {
39
- const apiClient = getApiClient();
40
- const { role } = getChatConfig();
39
+ // const apiClient = getApiClient();
40
+ const { role, apiClient } = getChatConfig();
41
41
  const { socket, sendMessage, userId } = useChatContext();
42
42
  const { selectedConversation, setMessages, setLastSentMessage } = useChatUIStore();
43
43
 
@@ -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,7 +27,8 @@ 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} = getChatConfig();
31
32
 
32
33
  const response = await apiClient.post(
33
34
  `${Path.sendmessage}/${receiverId}/${senderId}`,
@@ -48,7 +49,7 @@ 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} = getChatConfig();
52
53
  try {
53
54
  const response = await apiClient.get(`${Path.getmessage}/${chatId}/${userid}`, {
54
55
  params: { pagenum, limit: 20 },
@@ -70,7 +71,7 @@ export const setEditMessage = async ({
70
71
  userId: string;
71
72
  newMessage: string;
72
73
  }) => {
73
- const apiClient = getApiClient();
74
+ const {apiClient} = getChatConfig();
74
75
  try {
75
76
  const response = await apiClient.put(`${Path.editMessage}/${messageId}`, {
76
77
  userId,
@@ -91,7 +92,7 @@ export const deleteMessage = async ({
91
92
  messageId: string;
92
93
  userId: string;
93
94
  }) => {
94
- const apiClient = getApiClient();
95
+ const {apiClient} = getChatConfig();
95
96
  try {
96
97
  const response = await apiClient.delete(
97
98
  `${Path.deleteMessage}/${messageId}`,
@@ -1,14 +1,13 @@
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} = getChatConfig();
10
+ // const apiClient = getApiClient();
12
11
 
13
12
  const endpoint = role === 'admin'
14
13
  ? `${Path.getConversationListByAdmin}`