@pubuduth-aplicy/chat-ui 2.1.91 → 2.1.92
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
|
@@ -51,31 +51,31 @@ interface MessageProps {
|
|
|
51
51
|
|
|
52
52
|
const Message = ({ message }: MessageProps) => {
|
|
53
53
|
const { userId } = useChatContext();
|
|
54
|
-
const { apiUrl,cdnUrl
|
|
54
|
+
const { apiUrl, cdnUrl, role: role1 } = getChatConfig();
|
|
55
55
|
|
|
56
56
|
if (message.type === "system") {
|
|
57
57
|
const booking = message.meta?.bookingDetails;
|
|
58
58
|
const status = booking?.status || "Pending"; // Default to Pending
|
|
59
59
|
const role = role1; // "provider" or "customer"
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
const handleConfirm = () => {
|
|
62
62
|
console.log("Booking confirmed!");
|
|
63
63
|
window.location.href = `/booking/all`;
|
|
64
64
|
// Update booking status to Confirmed
|
|
65
65
|
};
|
|
66
|
-
|
|
66
|
+
|
|
67
67
|
const handleInProgress = () => {
|
|
68
68
|
console.log("Booking started (In Progress)");
|
|
69
69
|
window.location.href = `/booking/all`;
|
|
70
70
|
// Update booking status to InProgress
|
|
71
71
|
};
|
|
72
|
-
|
|
72
|
+
|
|
73
73
|
const handleComplete = () => {
|
|
74
74
|
console.log("Booking completed!");
|
|
75
75
|
window.location.href = `/booking/all`;
|
|
76
76
|
// Update booking status to Completed
|
|
77
77
|
};
|
|
78
|
-
|
|
78
|
+
|
|
79
79
|
const handleReview = () => {
|
|
80
80
|
if (role === "customer") {
|
|
81
81
|
console.log("Navigate to review page for customer → provider");
|
|
@@ -85,35 +85,35 @@ const Message = ({ message }: MessageProps) => {
|
|
|
85
85
|
window.location.href = `/booking/all`;
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
|
-
|
|
88
|
+
|
|
89
89
|
return (
|
|
90
90
|
<div className="system-message booking-details">
|
|
91
91
|
<h4>{status}</h4>
|
|
92
92
|
<div className="details">
|
|
93
93
|
<p>Service: {booking?.serviceId}</p>
|
|
94
|
-
<p>Date: {booking?.date.split(
|
|
94
|
+
<p>Date: {booking?.date.split("T")[0]}</p>
|
|
95
95
|
<p>Time: {booking?.time}</p>
|
|
96
96
|
</div>
|
|
97
|
-
|
|
97
|
+
|
|
98
98
|
{/* Actions based on role + status */}
|
|
99
99
|
{role === "provider" && status === "Pending" && (
|
|
100
100
|
<button className="confirm-button" onClick={handleConfirm}>
|
|
101
101
|
Confirm Booking ✅
|
|
102
102
|
</button>
|
|
103
103
|
)}
|
|
104
|
-
|
|
104
|
+
|
|
105
105
|
{role === "provider" && status === "Confirmed" && (
|
|
106
106
|
<button className="confirm-button" onClick={handleInProgress}>
|
|
107
107
|
Start Service ▶️
|
|
108
108
|
</button>
|
|
109
109
|
)}
|
|
110
|
-
|
|
110
|
+
|
|
111
111
|
{role === "provider" && status === "InProgress" && (
|
|
112
112
|
<button className="confirm-button" onClick={handleComplete}>
|
|
113
113
|
Mark as Completed ✔️
|
|
114
114
|
</button>
|
|
115
115
|
)}
|
|
116
|
-
|
|
116
|
+
|
|
117
117
|
{status === "Completed" && (
|
|
118
118
|
<button className="confirm-button" onClick={handleReview}>
|
|
119
119
|
Leave a Review ✍️
|
|
@@ -253,7 +253,6 @@ const Message = ({ message }: MessageProps) => {
|
|
|
253
253
|
}
|
|
254
254
|
};
|
|
255
255
|
|
|
256
|
-
|
|
257
256
|
const handleDownload = async (url: string, name: string, index: number) => {
|
|
258
257
|
setDownloadingIndex(index);
|
|
259
258
|
setDownloadProgress(0);
|
|
@@ -405,16 +404,37 @@ const Message = ({ message }: MessageProps) => {
|
|
|
405
404
|
src={`${cdnUrl}${media.url}`}
|
|
406
405
|
alt={media.name}
|
|
407
406
|
className="media-content"
|
|
408
|
-
onClick={() =>
|
|
407
|
+
onClick={() =>
|
|
408
|
+
window.open(`${cdnUrl}${media.url}`, "_blank")
|
|
409
|
+
}
|
|
409
410
|
/>
|
|
410
411
|
) : media.type === "video" ? (
|
|
411
|
-
|
|
412
|
-
<
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
412
|
+
<>
|
|
413
|
+
<div
|
|
414
|
+
className="video-file-preview"
|
|
415
|
+
onClick={() =>
|
|
416
|
+
window.open(`${cdnUrl}${media.url}`, "_blank")
|
|
417
|
+
}
|
|
418
|
+
>
|
|
419
|
+
<div className="file-icon video-icon">🎥</div>
|
|
420
|
+
|
|
421
|
+
<div className="file-info">
|
|
422
|
+
<span className="file-name">{media.name}</span>
|
|
423
|
+
<span className="file-size">
|
|
424
|
+
{(media.size / 1024 / 1024).toFixed(1)} MB
|
|
425
|
+
</span>
|
|
426
|
+
</div>
|
|
427
|
+
|
|
428
|
+
<div className="play-overlay">▶</div>
|
|
429
|
+
</div>
|
|
430
|
+
</>
|
|
417
431
|
) : (
|
|
432
|
+
// <video controls className="media-content" preload="metadata">
|
|
433
|
+
// <source
|
|
434
|
+
// src={`${cdnUrl}${media.url}`}
|
|
435
|
+
// type={`video/${`${cdnUrl}${media.url}`.split(".").pop()?.toLocaleLowerCase()}`}
|
|
436
|
+
// />
|
|
437
|
+
// </video>
|
|
418
438
|
<div className="document-preview">
|
|
419
439
|
<div className="file-icon">
|
|
420
440
|
{media.type === "document" && "📄"}
|
|
@@ -434,7 +454,11 @@ const Message = ({ message }: MessageProps) => {
|
|
|
434
454
|
if (downloadingIndex === index) {
|
|
435
455
|
cancelDownload();
|
|
436
456
|
} else {
|
|
437
|
-
handleDownload(
|
|
457
|
+
handleDownload(
|
|
458
|
+
`${cdnUrl}${media.url}`,
|
|
459
|
+
media.name,
|
|
460
|
+
index
|
|
461
|
+
);
|
|
438
462
|
}
|
|
439
463
|
}}
|
|
440
464
|
title={downloadingIndex === index ? "Cancel" : "Download"}
|
|
@@ -491,12 +515,14 @@ const Message = ({ message }: MessageProps) => {
|
|
|
491
515
|
);
|
|
492
516
|
} else {
|
|
493
517
|
setIsEditingMode(false);
|
|
518
|
+
setShowOptions(false);
|
|
494
519
|
}
|
|
495
520
|
};
|
|
496
521
|
|
|
497
522
|
const handleCancelEdit = () => {
|
|
498
523
|
setEditedMessage(message.message);
|
|
499
524
|
setIsEditingMode(false);
|
|
525
|
+
setShowOptions(false);
|
|
500
526
|
};
|
|
501
527
|
|
|
502
528
|
const handleKeyDown = (e: React.KeyboardEvent) => {
|
|
@@ -534,7 +560,7 @@ const Message = ({ message }: MessageProps) => {
|
|
|
534
560
|
return now.getTime() - messageDate.getTime() > oneDayInMs;
|
|
535
561
|
};
|
|
536
562
|
|
|
537
|
-
|
|
563
|
+
const hasMedia = message.media && message.media.length > 0;
|
|
538
564
|
|
|
539
565
|
return (
|
|
540
566
|
<div className="chat-container">
|
|
@@ -548,7 +574,9 @@ const Message = ({ message }: MessageProps) => {
|
|
|
548
574
|
>
|
|
549
575
|
{message.status === "deleted" ? (
|
|
550
576
|
<div className="chat-bubble compact-bubble deleted-message">
|
|
551
|
-
<div className="message-text text-gray-900 dark:text-gray-100">
|
|
577
|
+
<div className="message-text text-gray-900 dark:text-gray-100">
|
|
578
|
+
This message was deleted
|
|
579
|
+
</div>
|
|
552
580
|
</div>
|
|
553
581
|
) : (
|
|
554
582
|
(message.message ||
|
|
@@ -579,7 +607,9 @@ const Message = ({ message }: MessageProps) => {
|
|
|
579
607
|
</div>
|
|
580
608
|
) : (
|
|
581
609
|
message.message && (
|
|
582
|
-
<div className="message-text text-gray-900 dark:text-gray-100">
|
|
610
|
+
<div className="message-text text-gray-900 dark:text-gray-100">
|
|
611
|
+
{message.message}
|
|
612
|
+
</div>
|
|
583
613
|
)
|
|
584
614
|
)}
|
|
585
615
|
|