@pubuduth-aplicy/chat-ui 2.1.21 → 2.1.23

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.21",
3
+ "version": "2.1.23",
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": "",
@@ -12,14 +12,18 @@ export const Chat = () => {
12
12
  <div className='grid-container'>
13
13
  {selectedConversation ? (
14
14
  <>
15
- <div className={`sidebarContainer`}><Sidebar /></div>
15
+ <div className={`sidebarContainer`}>
16
+ <Sidebar />
17
+ </div>
16
18
  <div className='messageContainer'>
17
19
  <MessageContainer />
18
20
  </div>
19
21
  </>
20
22
  ) : (
21
23
  <>
22
- <div className='sidebarContainer'><Sidebar /></div>
24
+ <div className='sidebarContainer'>
25
+ <Sidebar />
26
+ </div>
23
27
  <div className='messageContainer'>
24
28
  <MessageContainer />
25
29
  </div>
@@ -30,9 +30,10 @@ const MessageContainer = () => {
30
30
  <img className="chatMessageContainerInnerImg" alt="Profile" src={selectedConversation.participantDetails.idpic}/>
31
31
  <div className="chatMessageContainerOutter">
32
32
  <div className="chatMessageContainerOutterDiv">
33
- <div className="chatMessageContainerOutterDiv_name">
33
+ <p className="chatMessageContainerOutterDiv_name">
34
34
  {selectedConversation.participantDetails.firstname}
35
- </div>
35
+ </p>
36
+ <p className="text-sm text-[#12bbb5]">Online</p>
36
37
  </div>
37
38
  </div>
38
39
  {/* <h4 className=" inline-block py-2 text-left font-sans font-semibold normal-case">Lara Abegnale</h4> */}
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1
2
  import React, { useState } from 'react';
2
3
  import { useMessageMutation } from '../../hooks/mutations/useSendMessage';
3
4
  import { useChatContext } from '../../providers/ChatProvider';
@@ -7,17 +8,18 @@ import useChatUIStore from '../../stores/Zustant';
7
8
 
8
9
  const MessageInput = () => {
9
10
  const { socket } = useChatContext();
11
+ const {userId}=useChatContext()
10
12
  const { selectedConversation } = useChatUIStore();
11
13
  const [message, setMessage] = useState(""); // State for storing the message input
12
14
  const { mutate: sendMessage } = useMessageMutation();
13
15
 
14
- const handleSubmit = async (e) => {
16
+ const handleSubmit = async (e:any) => {
15
17
  e.preventDefault();
16
18
  if (!message)
17
19
  return;
18
20
  if (selectedConversation?._id) {
19
21
  // Send message
20
- sendMessage({ chatId:selectedConversation._id, message });
22
+ sendMessage({ chatId:selectedConversation._id,senderId:userId, message });
21
23
 
22
24
  // Emit message to socket
23
25
  socket.emit('sendMessage', { chatId: selectedConversation._id, message });
@@ -11,7 +11,6 @@ import useChatUIStore from "../../stores/Zustant";
11
11
  const Messages = () => {
12
12
  const { selectedConversation } = useChatUIStore()
13
13
  const {userId}=useChatContext()
14
- console.log(selectedConversation); // Ensure chatId is correct
15
14
  console.log(userId);
16
15
  const { data: messages, isLoading, isError, error } = useMessages(selectedConversation?._id, userId);
17
16
  // useListenMessages();
@@ -33,15 +33,19 @@ console.log(conversation);
33
33
  >
34
34
  <img
35
35
  className="chatSidebarConversationImg"
36
- src={conversation.participantDetails.profilePic|| conversation.participantDetails.idpic}
36
+ src={conversation.participantDetails?.profilePic|| conversation.participantDetails?.idpic}
37
37
  />
38
38
  <div className="chatSidebarConversationContainer">
39
- <div className="chatSidebarConversationInnerDiv">
40
- <div className="chatSidebarConversationOuterDiv">
39
+ {/* <div className="chatSidebarConversationInnerDiv"> */}
40
+ <p className="text-sm text-gray-500">
41
41
  {conversation.participantDetails.firstname}
42
- </div>
43
- </div>
42
+ </p>
43
+ <p className="chatSidebarConversationOuterDiv">
44
+ Do you know which
45
+ </p>
46
+ {/* </div> */}
44
47
  </div>
48
+ <span className="text-xs text-gray-500">08:12 AM</span>
45
49
  </div>
46
50
 
47
51
  {!lastIdx && <div className="divider my-0 py-0 h-1" />}
@@ -12,6 +12,7 @@ const Conversations = () => {
12
12
  // const { loading, conversations } = useGetConversations();
13
13
  return (
14
14
  <div className="chatSidebarConversations">
15
+ <h2 className="text-lg font-semibold text-gray-700">All Chats</h2>
15
16
  {conversations?.map((conversation: any, idx: any) => (
16
17
  <Conversation
17
18
  key={conversation._id}
@@ -2,8 +2,8 @@
2
2
  import { apiClient } from "../lib/api/apiClient";
3
3
  import { Path } from "../lib/api/endpoint";
4
4
 
5
- export const sendMessage = async ({ chatId, message }: { chatId: any; message: string }) => {
6
- const response = await apiClient.post(`${Path.sendmessage}/${chatId}`, {
5
+ export const sendMessage = async ({ chatId,senderId, message }: { chatId: any; senderId:any; message: string }) => {
6
+ const response = await apiClient.post(`${Path.sendmessage}/${chatId}/${senderId}`, {
7
7
  message
8
8
  })
9
9
  return response.data;
@@ -37,6 +37,8 @@
37
37
  padding-left: 1rem;
38
38
  padding-right: 1rem;
39
39
  gap: 1rem;
40
+ border-bottom: 1px;
41
+ width: 100%;
40
42
  justify-content: flex-start;
41
43
  align-items: center;
42
44
  align-self: stretch;
@@ -72,11 +74,13 @@
72
74
  .chatSidebarInput {
73
75
  outline-style: none;
74
76
  width: 100%;
75
- height: 1.25rem;
77
+ padding: 8px 4px;
76
78
  font-size: 1rem;
79
+ border-radius: 4px;
77
80
  line-height: 1.5rem;
78
81
  font-weight: 400;
79
82
  line-height: 1.25;
83
+
80
84
  }
81
85
 
82
86
  .chatSidebarConversations {
@@ -90,14 +94,15 @@
90
94
  .chatSidebarConversationMain {
91
95
  display: inline-flex;
92
96
  padding: 0.5rem;
93
- padding-top: 0.75rem;
94
- padding-bottom: 0.75rem;
95
- gap: 1rem;
96
- justify-content: flex-start;
97
+ margin-top: 0.875rem;
98
+ /* padding-top: 0.75rem;
99
+ padding-bottom: 0.75rem; */
100
+ gap: 0.75rem;
101
+ /* justify-content: flex-start; */
97
102
  align-items: center;
98
103
  border-radius: 0.25rem;
99
104
  cursor: pointer;
100
- height: 72px;
105
+ /* height: 72px; */
101
106
 
102
107
  :hover {
103
108
  background-color: #0ea5e9;
@@ -112,13 +117,14 @@
112
117
  }
113
118
 
114
119
  .chatSidebarConversationContainer {
115
- display: inline-flex;
116
- flex-basis: 0px;
120
+ /* display: inline-flex; */
121
+ flex: 1 1 0%;
122
+ /* flex-basis: 0px;
117
123
  flex-direction: column;
118
124
  shrink: 1;
119
125
  gap: 0.25rem;
120
126
  justify-content: flex-start;
121
- align-items: flex-start;
127
+ align-items: flex-start; */
122
128
  }
123
129
 
124
130
  .chatSidebarConversationInnerDiv {
@@ -130,7 +136,8 @@
130
136
 
131
137
  .chatSidebarConversationOuterDiv {
132
138
  flex-basis: 0px;
133
- shrink: 1;
139
+ /* shrink: 1; */
140
+ color: #374151;
134
141
  font-size: 1rem;
135
142
  line-height: 1.5rem;
136
143
  font-weight: 600;
@@ -233,88 +240,88 @@
233
240
  }
234
241
 
235
242
  .chatMessages {
236
- overflow: auto;
243
+ overflow-y: auto;
237
244
  padding-left: 1rem;
238
245
  padding-right: 1rem;
239
246
  flex: 1 1 0%;
240
247
  }
241
248
 
242
- .chatMessagesBubble_me{
243
- float: right;
244
- background-color: #34D399;
245
- }
246
-
247
- .chatMessagesBubble_Other{
248
- float: left;
249
- background-color: #1D4ED8;
250
- }
251
-
252
- .chatMessage{
253
- overflow-y: auto;
254
- padding-left: 2rem;
255
- padding-right: 2rem;
256
- padding-top: 2rem;
257
- flex-grow: 1;
258
- max-height: 100vh;
259
- text-align: left;
260
- color: #374151;
261
- }
262
-
263
- .chatMessagesContainer{
264
- position: relative;
265
- margin-bottom: 1.5rem;
266
- text-align: left;
267
- }
268
-
269
- .chatMessagesBubble_inner{
270
- display: block;
271
- position: relative;
272
- padding-top: 0.75rem;
273
- padding-bottom: 0.75rem;
274
- padding-left: 1rem;
275
- padding-right: 1rem;
276
- border-radius: 0.375rem;
277
- color: #ffffff;
278
- word-break: break-all;
279
- }
280
-
281
- .chatMessagesBubble_Time{
282
- display: flex;
283
- float: right;
284
- gap: 0.25rem;
285
- align-items: center;
286
- font-size: 0.75rem;
287
- line-height: 1rem;
288
- opacity: 0.5;
289
- }
290
-
291
- .chatMessageInputDiv{
292
- position: sticky;
293
- bottom: 0;
294
- padding-left: 1rem;
295
- padding-right: 1rem;
296
- margin-top: 0.75rem;
297
- margin-bottom: 0.75rem;
298
- }
299
-
300
- .chatMessageInput{
301
- display: block;
302
- padding: 0.625rem;
303
- border-radius: 1rem;
304
- border-width: 1px;
305
- border-style: none;
306
- outline-style: none;
307
- width: 100%;
308
- font-size: 0.875rem;
309
- line-height: 1.25rem;
310
- }
311
-
312
- .chatMessageInputSubmit{
313
- display: flex;
314
- position: absolute;
315
- top: 0;
316
- bottom: 0;
317
- align-items: center;
249
+ .chatMessagesBubble_me {
250
+ float: right;
251
+ background-color: #34D399;
252
+ }
253
+
254
+ .chatMessagesBubble_Other {
255
+ float: left;
256
+ background-color: #1D4ED8;
257
+ }
258
+
259
+ .chatMessage {
260
+ overflow-y: auto;
261
+ padding-left: 2rem;
262
+ padding-right: 2rem;
263
+ padding-top: 2rem;
264
+ flex-grow: 1;
265
+ max-height: 100vh;
266
+ text-align: left;
267
+ color: #374151;
268
+ }
269
+
270
+ .chatMessagesContainer {
271
+ position: relative;
272
+ margin-bottom: 1.5rem;
273
+ text-align: left;
274
+ }
275
+
276
+ .chatMessagesBubble_inner {
277
+ display: block;
278
+ position: relative;
279
+ padding-top: 0.75rem;
280
+ padding-bottom: 0.75rem;
281
+ padding-left: 1rem;
282
+ padding-right: 1rem;
283
+ border-radius: 0.375rem;
284
+ color: #ffffff;
285
+ word-break: break-all;
286
+ }
287
+
288
+ .chatMessagesBubble_Time {
289
+ display: flex;
290
+ float: right;
291
+ gap: 0.25rem;
292
+ align-items: center;
293
+ font-size: 0.75rem;
294
+ line-height: 1rem;
295
+ opacity: 0.5;
296
+ }
297
+
298
+ .chatMessageInputDiv {
299
+ position: sticky;
300
+ bottom: 0;
301
+ padding-left: 1rem;
302
+ padding-right: 1rem;
303
+ margin-top: 0.75rem;
304
+ margin-bottom: 0.75rem;
305
+ }
306
+
307
+ .chatMessageInput {
308
+ display: block;
309
+ padding: 0.625rem;
310
+ border-radius: 1rem;
311
+ border-width: 1px;
312
+ border-style: none;
313
+ outline-style: none;
314
+ width: 100%;
315
+ font-size: 0.875rem;
316
+ line-height: 1.25rem;
317
+ }
318
+
319
+ .chatMessageInputSubmit {
320
+ display: flex;
321
+ position: absolute;
322
+ top: 0;
323
+ bottom: 0;
324
+ align-items: center;
318
325
  }
319
326
 
320
327
  @media (min-width: 640px) {