@pubuduth-aplicy/chat-ui 2.1.80 → 2.1.82

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.1.80",
3
+ "version": "2.1.82",
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": "",
@@ -13,7 +13,10 @@ import { useEffect, useRef, useState } from "react";
13
13
  interface MessageProps {
14
14
  message: {
15
15
  _id?: string;
16
- senderId: string;
16
+ sender: {
17
+ senderId: string;
18
+ role: string;
19
+ };
17
20
  message: string;
18
21
  status: MessageStatus;
19
22
  createdAt: any;
@@ -48,30 +51,74 @@ interface MessageProps {
48
51
 
49
52
  const Message = ({ message }: MessageProps) => {
50
53
  const { userId } = useChatContext();
51
- const { apiUrl,cdnUrl } = getChatConfig();
54
+ const { apiUrl,cdnUrl ,role: role1} = getChatConfig();
52
55
 
53
56
  if (message.type === "system") {
57
+ const booking = message.meta?.bookingDetails;
58
+ const status = booking?.status || "Pending"; // Default to Pending
59
+ const role = role1; // "provider" or "customer"
60
+
61
+ const handleConfirm = () => {
62
+ console.log("Booking confirmed!");
63
+ window.location.href = `/booking/all`;
64
+ // Update booking status to Confirmed
65
+ };
66
+
67
+ const handleInProgress = () => {
68
+ console.log("Booking started (In Progress)");
69
+ window.location.href = `/booking/all`;
70
+ // Update booking status to InProgress
71
+ };
72
+
73
+ const handleComplete = () => {
74
+ console.log("Booking completed!");
75
+ window.location.href = `/booking/all`;
76
+ // Update booking status to Completed
77
+ };
78
+
79
+ const handleReview = () => {
80
+ if (role === "customer") {
81
+ console.log("Navigate to review page for customer → provider");
82
+ window.location.href = `/customer/customer-reviews`;
83
+ } else if (role === "provider") {
84
+ console.log("Navigate to review page for provider → customer");
85
+ window.location.href = `/booking/all`;
86
+ }
87
+ };
88
+
54
89
  return (
55
90
  <div className="system-message booking-details">
56
- <h4>{message.meta?.bookingDetails?.status || 'Unknown'}</h4>
91
+ <h4>{status}</h4>
57
92
  <div className="details">
58
- <p>Service: {message.meta?.bookingDetails?.serviceId}</p>
59
- <p>Date: {message.meta?.bookingDetails?.date}</p>
60
- <p>Time: {message.meta?.bookingDetails?.time}</p>
61
- <p>Price: ${message.meta?.bookingDetails?.price}</p>
93
+ <p>Service: {booking?.serviceId}</p>
94
+ <p>Date: {booking?.date}</p>
95
+ <p>Time: {booking?.time}</p>
62
96
  </div>
63
- <button
64
- className="confirm-button"
65
- onClick={() => {
66
- // Add your confirmation logic here
67
- console.log('Booking confirmed!');
68
- }}
69
- >
70
- Confirm Booking
71
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
72
- <path d="M12.736 3.97a.733.733 0 0 1 1.047 0c.286.289.29.756.01 1.05L7.88 12.01a.733.733 0 0 1-1.065.02L3.217 8.384a.757.757 0 0 1 0-1.06.733.733 0 0 1 1.047 0l3.052 3.093 5.4-6.425a.247.247 0 0 1 .02-.022Z" />
73
- </svg>
74
- </button>
97
+
98
+ {/* Actions based on role + status */}
99
+ {role === "provider" && status === "Pending" && (
100
+ <button className="confirm-button" onClick={handleConfirm}>
101
+ Confirm Booking
102
+ </button>
103
+ )}
104
+
105
+ {role === "provider" && status === "Confirmed" && (
106
+ <button className="confirm-button" onClick={handleInProgress}>
107
+ Start Service ▶️
108
+ </button>
109
+ )}
110
+
111
+ {role === "provider" && status === "InProgress" && (
112
+ <button className="confirm-button" onClick={handleComplete}>
113
+ Mark as Completed ✔️
114
+ </button>
115
+ )}
116
+
117
+ {status === "Completed" && (
118
+ <button className="confirm-button" onClick={handleReview}>
119
+ Leave a Review ✍️
120
+ </button>
121
+ )}
75
122
  </div>
76
123
  );
77
124
  }
@@ -92,7 +139,7 @@ const Message = ({ message }: MessageProps) => {
92
139
  );
93
140
  }
94
141
 
95
- const fromMe = message.senderId === userId;
142
+ const fromMe = message.sender?.senderId === userId;
96
143
  const timestamp = fromMe ? "timestamp_outgoing" : "timestamp_incomeing";
97
144
  const alignItems = fromMe ? "outgoing" : "incoming";
98
145
  const [localStatus, setLocalStatus] = useState(message.status);
@@ -258,7 +258,10 @@ const MessageInput = () => {
258
258
  _id: tempId,
259
259
  text: message1,
260
260
  message: message1,
261
- senderId: userId,
261
+ sender: {
262
+ senderId: userId,
263
+ role: role,
264
+ },
262
265
  status: "pending" as MessageStatus,
263
266
  createdAt: new Date().toISOString(),
264
267
  media: attachmentsRef.current.map((att) => ({
@@ -61,7 +61,7 @@ const Messages = () => {
61
61
  (msg) =>
62
62
  msg._id === newMessage._id ||
63
63
  (msg.isOptimistic &&
64
- msg.senderId === userId &&
64
+ msg.sender.senderId === userId &&
65
65
  msg.message === newMessage.message)
66
66
  );
67
67
 
@@ -265,14 +265,14 @@ const Conversations = () => {
265
265
  <button
266
266
  className={`flex-1 py-3 px-4 text-sm font-medium text-center border-b-2 transition-colors ${
267
267
  activeTab === "personal"
268
- ? "border-[#317490] message-text bg-blue-50"
268
+ ? "border-primary message-text bg-primary/20"
269
269
  : "border-transparent text-gray-500 hover:text-gray-700 hover:bg-gray-50"
270
270
  }`}
271
271
  onClick={() => setActiveTab("personal")}
272
272
  >
273
273
  Personal
274
274
  {personalUnreadCount > 0 && (
275
- <span className="ml-2 bg-blue-500 text-white text-xs rounded-full px-2 py-1 min-w-5 inline-flex justify-center">
275
+ <span className="ml-2 bg-blue-primary text-white text-xs rounded-full px-2 py-1 min-w-5 inline-flex justify-center">
276
276
  {personalUnreadCount}
277
277
  </span>
278
278
  )}
@@ -280,14 +280,14 @@ const Conversations = () => {
280
280
  <button
281
281
  className={`flex-1 py-3 px-4 text-sm font-medium text-center border-b-2 transition-colors ${
282
282
  activeTab === "service"
283
- ? "border-blue-500 text-blue-600 bg-blue-50"
283
+ ? "border-primary message-text bg-primary/20"
284
284
  : "border-transparent text-gray-500 hover:text-gray-700 hover:bg-gray-50"
285
285
  }`}
286
286
  onClick={() => setActiveTab("service")}
287
287
  >
288
288
  Service
289
289
  {serviceUnreadCount > 0 && (
290
- <span className="ml-2 bg-blue-500 text-white text-xs rounded-full px-2 py-1 min-w-5 inline-flex justify-center">
290
+ <span className="ml-2 bg-primary text-white text-xs rounded-full px-2 py-1 min-w-5 inline-flex justify-center">
291
291
  {serviceUnreadCount}
292
292
  </span>
293
293
  )}
@@ -26,7 +26,10 @@ interface ChatUIState {
26
26
  messages: {
27
27
  _id: string;
28
28
  text: string;
29
- senderId: string;
29
+ sender: {
30
+ senderId: string;
31
+ role: string;
32
+ };
30
33
  status: string;
31
34
  isOptimistic: boolean;
32
35
  message: string;