@pubuduth-aplicy/chat-ui 2.2.3 → 2.2.5

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.3",
3
+ "version": "2.2.5",
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": "",
@@ -35,8 +35,7 @@ const CollapsibleSection = ({
35
35
  />
36
36
  </div>
37
37
  {isOpen && (
38
- <div className="p-2 text-gray-900 dark:text-gray-200"
39
- style={{height:"400px"}}>{children}</div>
38
+ <div className="p-2 text-gray-900 dark:text-gray-200">{children}</div>
40
39
  )}
41
40
  </div>
42
41
  );
@@ -1,5 +1,6 @@
1
1
  const SystemNotice = () => (
2
- <div style={{
2
+ <div
3
+ style={{
3
4
  padding: "1rem",
4
5
  border: "1px solid #ddd",
5
6
  borderRadius: "8px",
@@ -7,12 +8,33 @@ const SystemNotice = () => (
7
8
  backgroundColor: "#f9f9f9",
8
9
  fontSize: "14px",
9
10
  textAlign: "center",
10
- }}>
11
- <strong style={{ display: "block", marginBottom: "0.5rem", textAlign:"center", fontSize:"smaller" }}>🛡 WE HAVE YOUR BACK</strong>
12
- <p style={{fontSize:"x-small", textAlign:"center"}}>For added safety and your protection, keep payments and communications within Hirepanther.
13
- {/* <a href="#">Learn more</a> */}
14
- </p>
11
+ }}
12
+ >
13
+ <div
14
+ style={{
15
+ fontSize: "32px", // 🔥 control icon size here
16
+ lineHeight: 1,
17
+ marginBottom: "0.25rem",
18
+ }}
19
+ >
20
+ 🛡
15
21
  </div>
16
- );
17
- export default SystemNotice;
18
-
22
+
23
+ <strong
24
+ style={{
25
+ display: "block",
26
+ marginBottom: "0.5rem",
27
+ fontSize: "12px",
28
+ letterSpacing: "0.5px",
29
+ }}
30
+ >
31
+ WE HAVE YOUR BACK
32
+ </strong>
33
+
34
+ <p style={{ fontSize: "11px", margin: 0 }}>
35
+ For added safety and your protection, keep payments and communications
36
+ within Hirepanther.
37
+ </p>
38
+ </div>
39
+ );
40
+ export default SystemNotice;
@@ -23,7 +23,7 @@ const VirtualizedChatList = ({ conversations }: Props) => {
23
23
  <div
24
24
  ref={parentRef}
25
25
  style={{
26
- height: `400px`,
26
+ // height: `400px`,
27
27
  width: "100%",
28
28
  // position: "relative",
29
29
  overflow: "auto",
@@ -37,6 +37,7 @@ interface MessageProps {
37
37
  type?: "user" | "system" | "system-completion";
38
38
  meta?: {
39
39
  bookingDetails?: {
40
+ bookingId: string;
40
41
  status: string; // e.g., "confirmed", "pending", "cancelled"
41
42
  serviceId: string;
42
43
  date: string;
@@ -60,7 +61,7 @@ const Message = ({ message }: MessageProps) => {
60
61
 
61
62
  const handleConfirm = () => {
62
63
  console.log("Booking confirmed!");
63
- window.location.href = `/booking/all`;
64
+ window.location.href = `/booking/all#${message.meta?.bookingDetails?.bookingId}`;
64
65
  // Update booking status to Confirmed
65
66
  };
66
67
 
@@ -420,7 +421,10 @@ const Message = ({ message }: MessageProps) => {
420
421
  <div className="file-icon">
421
422
  {media.type === "document" && "📄"}
422
423
  </div>
423
- <div className="file-info">
424
+ <div className="file-info"
425
+ onClick={() =>
426
+ window.open(`${cdnUrl}${media.url}`, "_blank")
427
+ }>
424
428
  <span className="file-name">{media.name}</span>
425
429
  <span className="file-size">
426
430
  {(media.size / 1024).toFixed(1)} KB
@@ -541,6 +545,40 @@ const Message = ({ message }: MessageProps) => {
541
545
  return now.getTime() - messageDate.getTime() > oneDayInMs;
542
546
  };
543
547
 
548
+ const formatLastMessageTime = (dateString: string) => {
549
+ const date = new Date(dateString);
550
+ const now = new Date();
551
+
552
+ const isToday = date.toDateString() === now.toDateString();
553
+
554
+ const yesterday = new Date();
555
+ yesterday.setDate(now.getDate() - 1);
556
+
557
+ const isYesterday = date.toDateString() === yesterday.toDateString();
558
+
559
+ if (isToday) {
560
+ return date.toLocaleTimeString([], {
561
+ hour: "2-digit",
562
+ minute: "2-digit",
563
+ });
564
+ }
565
+
566
+ if (isYesterday) {
567
+ return "Yesterday";
568
+ }
569
+
570
+ // MM/DD format
571
+ return date.toLocaleDateString("en-US", {
572
+ month: "2-digit",
573
+ day: "2-digit",
574
+ });
575
+ };
576
+
577
+ const messageTime =
578
+ message.status === "deleted" || message.status === "edited"
579
+ ? message.updatedAt
580
+ : message.createdAt;
581
+
544
582
  const hasMedia = message.media && message.media.length > 0;
545
583
 
546
584
  return (
@@ -638,23 +676,7 @@ const Message = ({ message }: MessageProps) => {
638
676
  )
639
677
  )}
640
678
  <div className={`${timestamp}`}>
641
- {message.status === "deleted"
642
- ? // Show deleted timestamp if message is deleted
643
- new Date(message.updatedAt).toLocaleTimeString([], {
644
- hour: "2-digit",
645
- minute: "2-digit",
646
- })
647
- : message.status === "edited"
648
- ? // Show updated timestamp if message was edited
649
- new Date(message.updatedAt).toLocaleTimeString([], {
650
- hour: "2-digit",
651
- minute: "2-digit",
652
- })
653
- : // Default to created timestamp
654
- new Date(message.createdAt).toLocaleTimeString([], {
655
- hour: "2-digit",
656
- minute: "2-digit",
657
- })}
679
+ {formatLastMessageTime(messageTime)}
658
680
  <span className="status-icon">{getStatusIcon()}</span>
659
681
  </div>
660
682
  </div>
@@ -8,19 +8,16 @@ import { getChatConfig } from "../../Chat.config";
8
8
  import defaultProfilePicture from "../../assets/pngegg.png";
9
9
 
10
10
  const Conversation = ({ conversation }: ConversationProps) => {
11
- const {
12
- setSelectedConversation,
13
- setOnlineUsers,
14
- } = useChatUIStore();
15
- const { socket, isUserOnline, } = useChatContext();
11
+ const { setSelectedConversation, setOnlineUsers } = useChatUIStore();
12
+ const { socket, isUserOnline } = useChatContext();
16
13
  const selectedConversation = useChatUIStore(
17
14
  (state) => state.selectedConversation
18
15
  );
19
16
  const { userId } = useChatContext();
20
- const { role } = getChatConfig();
17
+ const { role } = getChatConfig();
21
18
 
22
19
  const participant = conversation.participantDetails?.find(
23
- (p:any) => p._id !== userId
20
+ (p: any) => p._id !== userId
24
21
  );
25
22
 
26
23
  const handleSelectConversation = () => {
@@ -81,12 +78,40 @@ const Conversation = ({ conversation }: ConversationProps) => {
81
78
  ? `Booking #${conversation.bookingId}`
82
79
  : participant?.name || "Conversation";
83
80
 
84
- const lastMessageTimestamp = new Date(
85
- conversation.lastMessage?.updatedAt || conversation.lastMessage?.createdAt || conversation.createdAt
86
- ).toLocaleTimeString([], {
87
- hour: "2-digit",
88
- minute: "2-digit",
89
- });
81
+ const formatLastMessageTime = (dateString: string) => {
82
+ const date = new Date(dateString);
83
+ const now = new Date();
84
+
85
+ const isToday = date.toDateString() === now.toDateString();
86
+
87
+ const yesterday = new Date();
88
+ yesterday.setDate(now.getDate() - 1);
89
+
90
+ const isYesterday = date.toDateString() === yesterday.toDateString();
91
+
92
+ if (isToday) {
93
+ return date.toLocaleTimeString([], {
94
+ hour: "2-digit",
95
+ minute: "2-digit",
96
+ });
97
+ }
98
+
99
+ if (isYesterday) {
100
+ return "Yesterday";
101
+ }
102
+
103
+ // MM/DD format
104
+ return date.toLocaleDateString("en-US", {
105
+ month: "2-digit",
106
+ day: "2-digit",
107
+ });
108
+ };
109
+
110
+ const lastMessageTimestamp = formatLastMessageTime(
111
+ conversation.lastMessage?.updatedAt ||
112
+ conversation.lastMessage?.createdAt ||
113
+ conversation.createdAt
114
+ );
90
115
 
91
116
  return (
92
117
  <div
@@ -104,7 +129,11 @@ const Conversation = ({ conversation }: ConversationProps) => {
104
129
  <>
105
130
  <img
106
131
  className="w-10 h-10 rounded-full"
107
- src={participant?.profilePicture ? participant?.profilePicture: defaultProfilePicture}
132
+ src={
133
+ participant?.profilePicture
134
+ ? participant?.profilePicture
135
+ : defaultProfilePicture
136
+ }
108
137
  alt="User Avatar"
109
138
  />
110
139
  <span
@@ -121,7 +150,7 @@ const Conversation = ({ conversation }: ConversationProps) => {
121
150
  </p>
122
151
  <div className="flex items-center gap-2">
123
152
  {unreadCount > 0 && (
124
- <span className="background text-white text-xs rounded-full h-5 w-5 flex items-center justify-center">
153
+ <span className="background text-white text-xs rounded-full h-5 w-5 flex items-center justify-center">
125
154
  {unreadCount}
126
155
  </span>
127
156
  )}