@pubuduth-aplicy/chat-ui 2.0.9 → 2.1.1
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 +1 -1
- package/src/components/Chat.tsx +3 -2
- package/src/components/sidebar/Conversation.tsx +6 -6
- package/src/components/sidebar/Conversations.tsx +2 -2
- package/src/components/sidebar/SearchInput.tsx +5 -4
- package/src/components/sidebar/Sidebar.tsx +3 -2
- package/src/index.css +214 -0
- package/src/service/sidebarApi.ts +22 -16
- package/src/types/type.ts +28 -4
package/package.json
CHANGED
package/src/components/Chat.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Sidebar } from './sidebar/Sidebar'
|
|
2
|
+
import '../index.css'
|
|
2
3
|
// import MessageContainer from './components/messages/MessageContainer'
|
|
3
4
|
// import useConversation from '../../zustand/useConversation';
|
|
4
5
|
|
|
@@ -8,8 +9,8 @@ export const Chat = () => {
|
|
|
8
9
|
// const { selectedConversation, setSelectedConversation } = useConversation();
|
|
9
10
|
return (
|
|
10
11
|
<>
|
|
11
|
-
<div className='container
|
|
12
|
-
<div className='grid
|
|
12
|
+
<div className='container'>
|
|
13
|
+
<div className='grid bg-gray-400 bg-clip-padding backdrop-filter backdrop-blur-lg bg-opacity-0'>
|
|
13
14
|
<div/>
|
|
14
15
|
{/* {selectedConversation? (
|
|
15
16
|
<><div className={`xs:hidden md:grid md:col-span-3 border max-h-screen overflow-y-auto`}><Sidebar /></div>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// import useConversation from "../../zustand/useConversation";
|
|
3
3
|
|
|
4
4
|
import useChatUIStore from "../../stores/Zustant";
|
|
5
|
+
import '../../index.css'
|
|
5
6
|
|
|
6
7
|
interface ConversationProps {
|
|
7
8
|
conversation: {
|
|
@@ -21,24 +22,23 @@ const Conversation = ({ conversation, lastIdx }: ConversationProps) => {
|
|
|
21
22
|
return (
|
|
22
23
|
<>
|
|
23
24
|
<div
|
|
24
|
-
className={`
|
|
25
|
-
`}
|
|
25
|
+
className={`conversation-item`}
|
|
26
26
|
onClick={() => setSelectedConversation(conversation)}
|
|
27
27
|
>
|
|
28
28
|
<img
|
|
29
|
-
className="
|
|
29
|
+
className="conversation-image"
|
|
30
30
|
src={conversation.profilePic}
|
|
31
31
|
/>
|
|
32
|
-
<div className="
|
|
32
|
+
<div className="conversation-content">
|
|
33
33
|
<div className="self-stretch justify-start items-center inline-flex">
|
|
34
|
-
<div className="
|
|
34
|
+
<div className="conversation-username">
|
|
35
35
|
{conversation.username}
|
|
36
36
|
</div>
|
|
37
37
|
</div>
|
|
38
38
|
</div>
|
|
39
39
|
</div>
|
|
40
40
|
|
|
41
|
-
{!lastIdx && <div className="divider
|
|
41
|
+
{!lastIdx && <div className="divider" />}
|
|
42
42
|
</>
|
|
43
43
|
);
|
|
44
44
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { useGetConversations } from "../../hooks/queries/useChatApi";
|
|
4
4
|
import { useChatContext } from "../../providers/ChatProvider";
|
|
5
5
|
import Conversation from "./Conversation";
|
|
6
|
-
|
|
6
|
+
import '../../index.css'
|
|
7
7
|
const Conversations = () => {
|
|
8
8
|
const { userId } = useChatContext();
|
|
9
9
|
const { data: conversations } = useGetConversations(userId);
|
|
@@ -11,7 +11,7 @@ const Conversations = () => {
|
|
|
11
11
|
console.log("userId",userId);
|
|
12
12
|
// const { loading, conversations } = useGetConversations();
|
|
13
13
|
return (
|
|
14
|
-
<div className="
|
|
14
|
+
<div className="conversations">
|
|
15
15
|
{conversations?.map((conversation: any, idx: any) => (
|
|
16
16
|
<Conversation
|
|
17
17
|
key={conversation._id}
|
|
@@ -4,6 +4,7 @@ import searchicon from '../../assets/icons8-search.svg'
|
|
|
4
4
|
import useChatUIStore from '../../stores/Zustant';
|
|
5
5
|
import { useGetConversations } from '../../hooks/queries/useChatApi';
|
|
6
6
|
import { useChatContext } from '../../providers/ChatProvider';
|
|
7
|
+
import '../../index.css'
|
|
7
8
|
// import { MagnifyingGlass } from "@phosphor-icons/react"
|
|
8
9
|
// import useGetConversations from "../../hooks/useGetConversations";
|
|
9
10
|
// import useConversation from '../../zustand/useConversation'
|
|
@@ -36,10 +37,10 @@ const {userId} =useChatContext()
|
|
|
36
37
|
<>
|
|
37
38
|
|
|
38
39
|
<form onSubmit={handleSubmit}>
|
|
39
|
-
<div className="
|
|
40
|
-
<div className="
|
|
41
|
-
<img src={searchicon} className="
|
|
42
|
-
<input className="
|
|
40
|
+
<div className="searchContainer">
|
|
41
|
+
<div className="search">
|
|
42
|
+
<img src={searchicon} className="searchimg" />
|
|
43
|
+
<input className="searchinput"
|
|
43
44
|
placeholder='Search…'
|
|
44
45
|
value={search}
|
|
45
46
|
onChange={(e) => setSearch(e.target.value)}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import Conversations from "./Conversations";
|
|
2
2
|
import SearchInput from "./SearchInput";
|
|
3
|
+
import '../../index.css'
|
|
3
4
|
|
|
4
5
|
export const Sidebar = () => {
|
|
5
6
|
return (
|
|
6
|
-
<div className='
|
|
7
|
+
<div className='sidebar'>
|
|
7
8
|
<SearchInput />
|
|
8
|
-
<div className='divider
|
|
9
|
+
<div className='divider sidebarcon'></div>
|
|
9
10
|
<Conversations />
|
|
10
11
|
|
|
11
12
|
</div>
|
package/src/index.css
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
.sidebar {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
padding: 16px;
|
|
5
|
+
border-right: 1px;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.sidebarcon {
|
|
9
|
+
padding: 0 12px 0 12px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.searchContainer {
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
justify-content: start;
|
|
15
|
+
align-items: center;
|
|
16
|
+
gap: 16px;
|
|
17
|
+
padding: 8px 16px 8px 16px;
|
|
18
|
+
height: 56px;
|
|
19
|
+
align-self: stretch;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.search {
|
|
23
|
+
border-radius: 22px;
|
|
24
|
+
display: flex;
|
|
25
|
+
justify-content: start;
|
|
26
|
+
align-items: center;
|
|
27
|
+
gap: 16px;
|
|
28
|
+
background-color: #f5f5f5;
|
|
29
|
+
padding: 8px 16px 8px 16px;
|
|
30
|
+
flex-grow: 1;
|
|
31
|
+
flex-shrink: 1;
|
|
32
|
+
height: 40px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.searchimg {
|
|
36
|
+
padding-left: 2.5px;
|
|
37
|
+
padding-right: 3px;
|
|
38
|
+
padding-top: 2.5px;
|
|
39
|
+
padding-bottom: 3px;
|
|
40
|
+
height: 24px;
|
|
41
|
+
width: 24px;
|
|
42
|
+
display: flex;
|
|
43
|
+
justify-content: center;
|
|
44
|
+
align-items: center;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.searchinput {
|
|
48
|
+
width: 100%;
|
|
49
|
+
height: 20px;
|
|
50
|
+
background-color: #f5f5f5;
|
|
51
|
+
outline: none;
|
|
52
|
+
color: #64748b;
|
|
53
|
+
font-size: 16px;
|
|
54
|
+
font-weight: 400;
|
|
55
|
+
line-height: 1.25;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.conversation-item {
|
|
59
|
+
height: 72px;
|
|
60
|
+
padding: 0.5rem 0.75rem;
|
|
61
|
+
border-radius: 0.375rem;
|
|
62
|
+
/* equivalent to rounded */
|
|
63
|
+
display: inline-flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
justify-content: flex-start;
|
|
66
|
+
cursor: pointer;
|
|
67
|
+
gap: 1rem;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.conversation-item:hover {
|
|
71
|
+
background-color: #38bdf8;
|
|
72
|
+
/* equivalent to hover:bg-sky-500 */
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* CSS for the image */
|
|
76
|
+
.conversation-image {
|
|
77
|
+
width: 3rem;
|
|
78
|
+
height: 3rem;
|
|
79
|
+
border-radius: 50%;
|
|
80
|
+
position: relative;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* CSS for the inner div */
|
|
84
|
+
.conversation-content {
|
|
85
|
+
display: inline-flex;
|
|
86
|
+
flex-direction: column;
|
|
87
|
+
justify-content: flex-start;
|
|
88
|
+
align-items: flex-start;
|
|
89
|
+
gap: 0.25rem;
|
|
90
|
+
flex-grow: 1;
|
|
91
|
+
flex-shrink: 0;
|
|
92
|
+
flex-basis: 0;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* CSS for the username */
|
|
96
|
+
.conversation-username {
|
|
97
|
+
display: inline-flex;
|
|
98
|
+
align-items: center;
|
|
99
|
+
justify-content: flex-start;
|
|
100
|
+
flex-grow: 1;
|
|
101
|
+
font-family: 'Inter', sans-serif;
|
|
102
|
+
font-size: 1rem;
|
|
103
|
+
font-weight: 600;
|
|
104
|
+
color: #1e293b;
|
|
105
|
+
line-height: 1.25rem;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* Divider */
|
|
109
|
+
.divider {
|
|
110
|
+
height: 0.25rem;
|
|
111
|
+
/* equivalent to h-1 */
|
|
112
|
+
margin: 0;
|
|
113
|
+
padding: 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.conversations{
|
|
117
|
+
display: flex;
|
|
118
|
+
flex-direction: column;
|
|
119
|
+
overflow: auto;
|
|
120
|
+
padding: 8px 0 8px 0;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.container {
|
|
124
|
+
max-width: 100%;
|
|
125
|
+
margin-left: auto;
|
|
126
|
+
margin-right: auto;
|
|
127
|
+
margin-bottom: 1.25rem; /* mb-5 */
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/* Grid Layout */
|
|
131
|
+
.grid {
|
|
132
|
+
display: grid;
|
|
133
|
+
grid-template-columns: repeat(1, 1fr); /* grid-cols-1 */
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@media (min-width: 768px) {
|
|
137
|
+
.md\:grid-cols-9 {
|
|
138
|
+
grid-template-columns: repeat(9, 1fr); /* md:grid-cols-9 */
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
@media (min-width: 640px) {
|
|
143
|
+
.sm\:h-\[450px\] {
|
|
144
|
+
height: 450px; /* sm:h-[450px] */
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
@media (min-width: 768px) {
|
|
149
|
+
.md\:h-\[550px\] {
|
|
150
|
+
height: 550px; /* md:h-[550px] */
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/* Background and Other Styles */
|
|
155
|
+
.bg-gray-400 {
|
|
156
|
+
background-color: #cbd5e0; /* gray-400 */
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.bg-clip-padding {
|
|
160
|
+
background-clip: padding-box;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.backdrop-filter {
|
|
164
|
+
-webkit-backdrop-filter: blur(10px); /* backdrop-filter */
|
|
165
|
+
backdrop-filter: blur(10px);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.backdrop-blur-lg {
|
|
169
|
+
backdrop-filter: blur(10px); /* blur-lg */
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.bg-opacity-0 {
|
|
173
|
+
background-opacity: 0; /* bg-opacity-0 */
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/* First Inner Div */
|
|
177
|
+
.grid > div {
|
|
178
|
+
/* Any additional styling needed for this div */
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/* Sidebar Div */
|
|
182
|
+
.sidebar {
|
|
183
|
+
display: none; /* xs:hidden */
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
@media (min-width: 768px) {
|
|
187
|
+
.md\:col-span-3 {
|
|
188
|
+
grid-column: span 3 / span 3; /* md:col-span-3 */
|
|
189
|
+
}
|
|
190
|
+
.md\:grid {
|
|
191
|
+
display: grid; /* md:grid */
|
|
192
|
+
}
|
|
193
|
+
.md\:col-span-4 {
|
|
194
|
+
grid-column: span 4 / span 4; /* md:col-span-4 */
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/* Border and Overflow */
|
|
199
|
+
.border {
|
|
200
|
+
border: 1px solid #e5e7eb; /* light gray border, adjust as needed */
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.max-h-screen {
|
|
204
|
+
max-height: 100vh; /* max-h-screen */
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.overflow-y-auto {
|
|
208
|
+
overflow-y: auto; /* overflow-y-auto */
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/* MessageContainer */
|
|
212
|
+
.message-container {
|
|
213
|
+
/* Any styles related to MessageContainer */
|
|
214
|
+
}
|
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import { apiClient } from "../lib/api/apiClient";
|
|
3
3
|
import { Path } from "../lib/api/endpoint";
|
|
4
|
-
import { ApiResponse
|
|
4
|
+
import { ApiResponse } from "../types/type";
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
export const getAllConversationData = async (userid: string) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
8
|
+
try {
|
|
9
|
+
const res = await apiClient.get<ApiResponse>(`${Path.getconversation}/${userid}`);
|
|
10
|
+
|
|
11
|
+
// Access conversations with participant details from the API response
|
|
12
|
+
const { conversationsWithParticipantDetails } = res.data.serviceInfo;
|
|
13
|
+
|
|
14
|
+
// If needed, you can map the conversations in the specific structure
|
|
15
|
+
const formattedConversations = conversationsWithParticipantDetails.map((conversation) => ({
|
|
16
|
+
_id: conversation._id,
|
|
17
|
+
participantDetails: conversation.participantDetails,
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
// Return the formatted conversations
|
|
21
|
+
return formattedConversations;
|
|
22
|
+
} catch (error: any) {
|
|
23
|
+
console.error("ERROR: ", error);
|
|
24
|
+
// Optionally log the error to an external logger
|
|
25
|
+
// logger.error(error);
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
};
|
package/src/types/type.ts
CHANGED
|
@@ -3,11 +3,35 @@ export interface ChatWindowProps {
|
|
|
3
3
|
userId: string;
|
|
4
4
|
}
|
|
5
5
|
|
|
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
|
+
|
|
6
21
|
export interface Conversation {
|
|
7
22
|
_id: string;
|
|
8
|
-
|
|
23
|
+
createdAt: string;
|
|
24
|
+
updatedAt: string;
|
|
25
|
+
__v: number;
|
|
26
|
+
participantDetails: ParticipantDetails;
|
|
9
27
|
}
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
|
|
28
|
+
|
|
29
|
+
export interface ServiceInfo {
|
|
30
|
+
conversationsWithParticipantDetails: Conversation[];
|
|
13
31
|
}
|
|
32
|
+
|
|
33
|
+
export interface ApiResponse {
|
|
34
|
+
success: boolean;
|
|
35
|
+
message: string;
|
|
36
|
+
serviceInfo: ServiceInfo;
|
|
37
|
+
}
|