@pubuduth-aplicy/chat-ui 2.1.28 → 2.1.29

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.28",
3
+ "version": "2.1.29",
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": "",
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1
2
  /* eslint-disable @typescript-eslint/no-unused-vars */
2
3
 
3
4
  import { useChatContext } from "../../providers/ChatProvider";
@@ -10,6 +11,7 @@ interface MessageProps {
10
11
  message: {
11
12
  senderId: string;
12
13
  message: string;
14
+ createdAt:any;
13
15
  };
14
16
  }
15
17
 
@@ -21,7 +23,13 @@ const Message = ({ message }: MessageProps) => {
21
23
  const alignItems = fromMe ? "chatMessagesBubble_me" : "chatMessagesBubble_Other";
22
24
  console.log('messagedis',message);
23
25
 
26
+ const date = new Date(message.createdAt);
27
+ const hours = date.getUTCHours();
28
+ const minutes = date.getUTCMinutes();
29
+ const seconds = date.getUTCSeconds();
24
30
 
31
+ // Format the time as HH:mm:ss (24-hour format)
32
+ const time = `${hours}.${minutes}`;
25
33
  return (
26
34
  <>
27
35
  <div className='chatMessage'>
@@ -29,7 +37,7 @@ console.log('messagedis',message);
29
37
  <div style={{color:"#374151"}}>
30
38
  <div className={`chatMessagesBubble_inner ${alignItems} ${bubbleBgColor} `}>
31
39
  <p style={{fontSize:"14px"}}>{message.message}</p>
32
- <div className='chatMessagesBubble_Time'>15.00</div>
40
+ <div className='chatMessagesBubble_Time'>{time}</div>
33
41
  </div>
34
42
  </div>
35
43
  {/* <div className="clear-both flex text-gray-700" /> */}
@@ -52,36 +52,6 @@ const Messages = () => {
52
52
  }
53
53
 
54
54
  return (
55
- // <div className='px-4 flex-1 overflow-auto'>
56
- // {!loading &&
57
- // messages.length > 0 &&
58
- // messages.map((message) => (
59
- // <div key={message._id} ref={lastMessageRef}>
60
- // <Message message={message} />
61
- // </div>
62
- // ))}
63
-
64
- // {loading && [...Array(3)].map((_, idx) => <MessageSkeleton key={idx} />)}
65
- // {!loading && messages.length === 0 && (
66
- // <p className='text-center'>Send a message to start the conversation</p>
67
- // )}
68
- // </div>
69
-
70
- // <div className='chatMessages'>
71
- // {messages?.messages.length > 0 &&
72
- // messages?.messages.map((message: any) => (
73
- // <div key={message._id} ref={lastMessageRef}>
74
- // <Message message={message} />
75
- // </div>
76
- // ))}
77
-
78
- // {/* {loading && [...Array(3)].map((_, idx) => <MessageSkeleton key={idx} />)} */}
79
- // {messages?.length === 0 && (
80
- // <p style={{textAlign:"center"}}>Send a message to start the conversation</p>
81
- // )}
82
- // </div>
83
-
84
-
85
55
  <div className="chatMessages">
86
56
  {localMessages.length > 0 ? (
87
57
  localMessages.map((message: any) => (
@@ -2,20 +2,7 @@
2
2
  // import useConversation from "../../zustand/useConversation";
3
3
 
4
4
  import useChatUIStore from "../../stores/Zustant";
5
-
6
- interface ConversationProps {
7
- conversation: {
8
- participantDetails:{
9
- _id: string;
10
- profilePic: string;
11
- firstname: string;
12
- idpic:string;
13
-
14
- }
15
- _id:string;
16
- };
17
- lastIdx: boolean;
18
- }
5
+ import { ConversationProps } from "../../types/type";
19
6
 
20
7
  const Conversation = ({ conversation, lastIdx }: ConversationProps) => {
21
8
  const { setSelectedConversation } = useChatUIStore();
@@ -22,7 +22,9 @@ const {userId} =useChatContext()
22
22
  return
23
23
  }
24
24
 
25
- const conversation = data.find((c: { username: string }) => c.username.toLowerCase().includes(search.toLowerCase()));
25
+ const conversation = data?.find((c: { _id: string; participantDetails: { username: string } }) =>
26
+ c.participantDetails.username.toLowerCase().includes(search.toLowerCase())
27
+ );
26
28
 
27
29
  if (conversation) {
28
30
  setSelectedConversation(conversation);
@@ -15,7 +15,7 @@ export const useGetConversations = (id: any) => {
15
15
  });
16
16
  };
17
17
 
18
- export const useMessages = (chatId: string, userid: string) => {
18
+ export const useMessages = (chatId: string| undefined, userid: string) => {
19
19
  return useQuery({
20
20
  queryKey: ['messages', chatId, userid],
21
21
  queryFn: () => {
@@ -10,7 +10,7 @@ export const sendMessage = async ({ chatId,senderId, message }: { chatId: any; s
10
10
  };
11
11
 
12
12
 
13
- export const fetchMessages = async (chatId: string, userid: string) => {
13
+ export const fetchMessages = async (chatId: string|undefined, userid: string) => {
14
14
  try {
15
15
  const response = await apiClient.get(`${Path.getmessage}/${chatId}/${userid}`);
16
16
  console.log(response); // Check the full response
package/src/types/type.ts CHANGED
@@ -1,37 +1,51 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  export interface ChatWindowProps {
3
- userId: string;
3
+ userId: string;
4
4
  }
5
5
 
6
6
  export interface ParticipantDetails {
7
- _id: string;
8
- username: string;
9
- password: string;
10
- acctype: string;
11
- contactno: string;
12
- country: string;
13
- email: string;
14
- verified: string;
15
- profilePic: string;
16
- createdAt: string;
17
- updatedAt: string;
18
- __v: number;
19
- }
20
-
7
+ _id: string;
8
+ username: string;
9
+ password: string;
10
+ acctype: string;
11
+ contactno: string;
12
+ country: string;
13
+ email: string;
14
+ verified: string;
15
+ profilePic: string;
16
+ createdAt: string;
17
+ updatedAt: string;
18
+ __v: number;
19
+ }
20
+
21
21
  export interface Conversation {
22
- _id: string;
23
- createdAt: string;
24
- updatedAt: string;
25
- __v: number;
26
- participantDetails: ParticipantDetails;
27
- }
28
-
22
+ _id: string;
23
+ createdAt: string;
24
+ updatedAt: string;
25
+ __v: number;
26
+ participantDetails: ParticipantDetails;
27
+ }
28
+
29
29
  export interface ServiceInfo {
30
- conversationsWithParticipantDetails: Conversation[];
31
- }
32
-
30
+ conversationsWithParticipantDetails: Conversation[];
31
+ }
32
+
33
33
  export interface ApiResponse {
34
- success: boolean;
35
- message: string;
36
- serviceInfo: ServiceInfo;
37
- }
34
+ success: boolean;
35
+ message: string;
36
+ serviceInfo: ServiceInfo;
37
+ }
38
+
39
+ export interface ConversationProps {
40
+ conversation: {
41
+ participantDetails: {
42
+ _id: string;
43
+ profilePic: string;
44
+ firstname: string;
45
+ idpic: string;
46
+
47
+ }
48
+ _id: string;
49
+ };
50
+ lastIdx: boolean;
51
+ }