@pubuduth-aplicy/chat-ui 2.2.15 → 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.15",
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>
@@ -159,6 +160,26 @@ const Message = ({ message }: MessageProps) => {
159
160
  setLocalStatus(message.status);
160
161
  }, [message.status]);
161
162
 
163
+ useEffect(() => {
164
+ const handleClickOutside = (e: MouseEvent) => {
165
+ if (
166
+ optionsRef.current &&
167
+ !optionsRef.current.contains(e.target as Node)
168
+ ) {
169
+ setShowOptions(false);
170
+ setShowDeleteOption(false);
171
+ }
172
+ };
173
+
174
+ if (showOptions || showDeleteOption) {
175
+ document.addEventListener("mousedown", handleClickOutside);
176
+ }
177
+
178
+ return () => {
179
+ document.removeEventListener("mousedown", handleClickOutside);
180
+ };
181
+ }, [showOptions, showDeleteOption]);
182
+
162
183
  // const handleDownload = (url: string, name: string) => {
163
184
  // saveAs(url, name);
164
185
  // };
@@ -597,6 +618,7 @@ const Message = ({ message }: MessageProps) => {
597
618
  <div className={`message-row ${alignItems}`}>
598
619
  <div
599
620
  className="bubble-container"
621
+ ref={optionsRef}
600
622
  onMouseEnter={() => fromMe && !hasMedia && setShowOptions(true)}
601
623
  onMouseLeave={() =>
602
624
  fromMe && !showDeleteOption && setShowOptions(false)
@@ -658,7 +680,7 @@ const Message = ({ message }: MessageProps) => {
658
680
  >
659
681
  <Pencil size={16} />
660
682
  </button>
661
- <div className="more-options-container" ref={optionsRef}>
683
+ <div className="more-options-container">
662
684
  <button
663
685
  className="message-option-btn more-btn"
664
686
  onClick={() => setShowDeleteOption(!showDeleteOption)}
@@ -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
 
@@ -359,7 +359,7 @@ const MessageInput = () => {
359
359
  const handleSubmit = useCallback(
360
360
  async (e: React.FormEvent) => {
361
361
  e.preventDefault();
362
- if ((!message && attachmentsRef.current.length === 0) || isSending)
362
+ if ((!message.trim() && attachmentsRef.current.length === 0) || isSending)
363
363
  return;
364
364
  setIsSending(true);
365
365
  setAttachments([]);
@@ -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}`
@@ -939,6 +939,7 @@
939
939
  padding: 10px;
940
940
  position: sticky;
941
941
  bottom: 0;
942
+ z-index: 2;
942
943
  background: #fff;
943
944
  border-top: 1px solid #eaeaea;
944
945
  }
@@ -1190,6 +1191,7 @@
1190
1191
  }
1191
1192
 
1192
1193
  .attachment-options {
1194
+ width: 150px;
1193
1195
  position: absolute;
1194
1196
  bottom: 100%;
1195
1197
  left: 0;
@@ -1492,7 +1494,7 @@
1492
1494
  border-radius: 18px;
1493
1495
  padding: 4px;
1494
1496
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
1495
- z-index: 10;
1497
+ z-index: 1;
1496
1498
  transition: opacity 0.2s ease;
1497
1499
  }
1498
1500