@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
|
@@ -13,7 +13,10 @@ import { useEffect, useRef, useState } from "react";
|
|
|
13
13
|
interface MessageProps {
|
|
14
14
|
message: {
|
|
15
15
|
_id?: string;
|
|
16
|
-
|
|
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>{
|
|
91
|
+
<h4>{status}</h4>
|
|
57
92
|
<div className="details">
|
|
58
|
-
<p>Service: {
|
|
59
|
-
<p>Date: {
|
|
60
|
-
<p>Time: {
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
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) => ({
|
|
@@ -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-
|
|
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-
|
|
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-
|
|
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-
|
|
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
|
)}
|