@myrjfa/ui 1.0.8 → 1.0.10
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/dist/chat/ChatMain.d.ts +9 -0
- package/dist/chat/ChatMain.d.ts.map +1 -0
- package/dist/chat/ChatMain.js +272 -0
- package/dist/chat/ChatSidebar.d.ts +13 -0
- package/dist/chat/ChatSidebar.d.ts.map +1 -0
- package/dist/chat/ChatSidebar.js +23 -0
- package/dist/chat/ConversationList.d.ts +12 -0
- package/dist/chat/ConversationList.d.ts.map +1 -0
- package/dist/chat/ConversationList.js +70 -0
- package/dist/chat/ExpensePanel.d.ts +11 -0
- package/dist/chat/ExpensePanel.d.ts.map +1 -0
- package/dist/chat/ExpensePanel.js +235 -0
- package/dist/chat/MessageBubble.d.ts +18 -0
- package/dist/chat/MessageBubble.d.ts.map +1 -0
- package/dist/chat/MessageBubble.js +284 -0
- package/dist/chat/MessageInput.d.ts +21 -0
- package/dist/chat/MessageInput.d.ts.map +1 -0
- package/dist/chat/MessageInput.js +252 -0
- package/dist/chat/MilestonePanel.d.ts +11 -0
- package/dist/chat/MilestonePanel.d.ts.map +1 -0
- package/dist/chat/MilestonePanel.js +173 -0
- package/dist/chat/components/ParticipantSelector.d.ts +11 -0
- package/dist/chat/components/ParticipantSelector.d.ts.map +1 -0
- package/dist/chat/components/ParticipantSelector.js +17 -0
- package/dist/chat/components/SplitInputs.d.ts +11 -0
- package/dist/chat/components/SplitInputs.d.ts.map +1 -0
- package/dist/chat/components/SplitInputs.js +83 -0
- package/dist/chat/components/SplitTypeSelector.d.ts +8 -0
- package/dist/chat/components/SplitTypeSelector.d.ts.map +1 -0
- package/dist/chat/components/SplitTypeSelector.js +13 -0
- package/dist/chat/dialogs/AddMemberDialog.d.ts +10 -0
- package/dist/chat/dialogs/AddMemberDialog.d.ts.map +1 -0
- package/dist/chat/dialogs/AddMemberDialog.js +50 -0
- package/dist/chat/dialogs/CameraDialog.d.ts +8 -0
- package/dist/chat/dialogs/CameraDialog.d.ts.map +1 -0
- package/dist/chat/dialogs/CameraDialog.js +80 -0
- package/dist/chat/dialogs/CreatePollDialog.d.ts +8 -0
- package/dist/chat/dialogs/CreatePollDialog.d.ts.map +1 -0
- package/dist/chat/dialogs/CreatePollDialog.js +38 -0
- package/dist/chat/dialogs/ExpenseAnalyticsDialog.d.ts +19 -0
- package/dist/chat/dialogs/ExpenseAnalyticsDialog.d.ts.map +1 -0
- package/dist/chat/dialogs/ExpenseAnalyticsDialog.js +52 -0
- package/dist/chat/dialogs/GroupInfoDialog.d.ts +10 -0
- package/dist/chat/dialogs/GroupInfoDialog.d.ts.map +1 -0
- package/dist/chat/dialogs/GroupInfoDialog.js +71 -0
- package/dist/chat/dialogs/GroupInfoViewDialog.d.ts +9 -0
- package/dist/chat/dialogs/GroupInfoViewDialog.d.ts.map +1 -0
- package/dist/chat/dialogs/GroupInfoViewDialog.js +15 -0
- package/dist/chat/dialogs/NewChatDialog.d.ts +2 -0
- package/dist/chat/dialogs/NewChatDialog.d.ts.map +1 -0
- package/dist/chat/dialogs/NewChatDialog.js +63 -0
- package/dist/chat/dialogs/NewGroupDialog.d.ts +2 -0
- package/dist/chat/dialogs/NewGroupDialog.d.ts.map +1 -0
- package/dist/chat/dialogs/NewGroupDialog.js +69 -0
- package/dist/chat/dialogs/ParticipantsDialog.d.ts +11 -0
- package/dist/chat/dialogs/ParticipantsDialog.d.ts.map +1 -0
- package/dist/chat/dialogs/ParticipantsDialog.js +93 -0
- package/dist/chat/dialogs/UserProfileDialog.d.ts +10 -0
- package/dist/chat/dialogs/UserProfileDialog.d.ts.map +1 -0
- package/dist/chat/dialogs/UserProfileDialog.js +100 -0
- package/dist/chat/index.d.ts +8 -0
- package/dist/chat/index.d.ts.map +1 -0
- package/dist/chat/index.js +7 -0
- package/dist/dashboard/action-buttons.js +4 -5
- package/dist/dashboard/app-sidebar.js +46 -128
- package/dist/dashboard/card-header.js +1 -2
- package/dist/dashboard/dashboard-components.js +3 -5
- package/dist/dashboard/data-table.d.ts +18 -18
- package/dist/dashboard/data-table.js +54 -66
- package/dist/dashboard/nav-main.js +4 -5
- package/dist/dashboard/nav-secondary.js +2 -25
- package/dist/dashboard/stats-card.js +1 -2
- package/dist/dashboard/table.js +8 -54
- package/dist/header/mobile-nav-item.js +1 -2
- package/dist/header/mobile-navbar.js +8 -9
- package/dist/header/nav-item.d.ts +2 -1
- package/dist/header/nav-item.d.ts.map +1 -1
- package/dist/header/nav-item.js +2 -3
- package/dist/index.d.ts +57 -56
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +57 -57
- package/dist/main/footer.js +5 -9
- package/dist/main/navbar.d.ts.map +1 -1
- package/dist/main/navbar.js +53 -136
- package/dist/main/paginationBar.js +12 -14
- package/dist/main/portfolio/portfolioItem.js +1 -2
- package/dist/main/portfolio/portfolioPopup.js +16 -17
- package/dist/main/review-page.d.ts.map +1 -1
- package/dist/main/review-page.js +131 -198
- package/dist/misc/accordion.js +8 -34
- package/dist/misc/alert-dialog.js +22 -55
- package/dist/misc/alert.js +7 -32
- package/dist/misc/alertdialogclaude.js +50 -125
- package/dist/misc/avatar.js +6 -31
- package/dist/misc/badge.d.ts +8 -8
- package/dist/misc/badge.js +4 -27
- package/dist/misc/button.d.ts +9 -9
- package/dist/misc/button.js +4 -27
- package/dist/misc/card.js +12 -40
- package/dist/misc/carousel.js +37 -61
- package/dist/misc/checkbox.js +2 -25
- package/dist/misc/command.d.ts +3 -1
- package/dist/misc/command.d.ts.map +1 -1
- package/dist/misc/command.js +18 -49
- package/dist/misc/datepicker.js +66 -76
- package/dist/misc/dialog.js +20 -52
- package/dist/misc/dropdown-menu.js +30 -67
- package/dist/misc/faq.js +2 -3
- package/dist/misc/file-preview.js +43 -97
- package/dist/misc/filter.d.ts.map +1 -1
- package/dist/misc/filter.js +18 -21
- package/dist/misc/filterBar.js +136 -160
- package/dist/misc/form.d.ts +1 -1
- package/dist/misc/form.d.ts.map +1 -1
- package/dist/misc/form.js +39 -60
- package/dist/misc/image-cropper.d.ts +10 -0
- package/dist/misc/image-cropper.d.ts.map +1 -0
- package/dist/misc/image-cropper.js +44 -0
- package/dist/misc/input.js +2 -25
- package/dist/misc/label.js +2 -25
- package/dist/misc/line-carousel.js +3 -13
- package/dist/misc/multiImageUploader.d.ts +8 -8
- package/dist/misc/multiImageUploader.js +10 -11
- package/dist/misc/newsLetter.js +18 -78
- package/dist/misc/notification.d.ts +1 -2
- package/dist/misc/notification.d.ts.map +1 -1
- package/dist/misc/notification.js +89 -125
- package/dist/misc/pagination.js +16 -45
- package/dist/misc/password-eye.js +2 -3
- package/dist/misc/popover.d.ts.map +1 -1
- package/dist/misc/popover.js +8 -34
- package/dist/misc/progress.js +2 -25
- package/dist/misc/scroll-area.js +5 -29
- package/dist/misc/searchBar.js +27 -31
- package/dist/misc/searchBox.js +18 -22
- package/dist/misc/select.d.ts.map +1 -1
- package/dist/misc/select.js +22 -54
- package/dist/misc/separator.js +2 -25
- package/dist/misc/share.js +48 -104
- package/dist/misc/sheet.js +21 -53
- package/dist/misc/sidebar.d.ts +69 -69
- package/dist/misc/sidebar.js +112 -153
- package/dist/misc/skeleton.d.ts +2 -2
- package/dist/misc/skeleton.js +6 -29
- package/dist/misc/slider.js +3 -26
- package/dist/misc/starRating.js +5 -15
- package/dist/misc/stateCard.js +7 -8
- package/dist/misc/switch.d.ts +5 -0
- package/dist/misc/switch.d.ts.map +1 -0
- package/dist/misc/switch.js +8 -0
- package/dist/misc/tabs.js +8 -34
- package/dist/misc/textarea.js +2 -25
- package/dist/misc/tile.js +31 -92
- package/dist/misc/tooltip.js +8 -34
- package/dist/profile/socialLink.d.ts +1 -1
- package/dist/profile/socialLink.d.ts.map +1 -1
- package/dist/profile/socialLink.js +53 -69
- package/dist/utils/permissions.d.ts +7 -0
- package/dist/utils/permissions.d.ts.map +1 -0
- package/dist/utils/permissions.js +38 -0
- package/package.json +8 -5
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Conversation } from "@myrjfa/state/dist/lib/models/chat";
|
|
2
|
+
interface ChatMainProps {
|
|
3
|
+
conversation: Conversation;
|
|
4
|
+
currentUserId: string;
|
|
5
|
+
onBack: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function ChatMain({ conversation, currentUserId, onBack, }: ChatMainProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=ChatMain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatMain.d.ts","sourceRoot":"","sources":["../../src/chat/ChatMain.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAW,MAAM,oCAAoC,CAAC;AAchF,UAAU,aAAa;IACnB,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,wBAAgB,QAAQ,CAAC,EACrB,YAAY,EACZ,aAAa,EACb,MAAM,GACT,EAAE,aAAa,2CA2iBf"}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import React, { useEffect, useRef, useCallback } from "react";
|
|
4
|
+
import { chatApi } from "@myrjfa/state/dist/lib/actions/chat";
|
|
5
|
+
import { useChatContext } from "@myrjfa/state/dist/lib/context/ChatContext";
|
|
6
|
+
import { MessageBubble } from "./MessageBubble";
|
|
7
|
+
import { MessageInput } from "./MessageInput";
|
|
8
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../misc/dropdown-menu";
|
|
9
|
+
import { ArrowLeft, Info, MoreVertical, Users, Phone } from "lucide-react";
|
|
10
|
+
import { useRouter } from "next/navigation";
|
|
11
|
+
import { Avatar, AvatarFallback, AvatarImage } from "../misc/avatar";
|
|
12
|
+
import { MilestonePanel } from "./MilestonePanel";
|
|
13
|
+
import { ExpensePanel } from "./ExpensePanel";
|
|
14
|
+
import { ParticipantsDialog } from "./dialogs/ParticipantsDialog";
|
|
15
|
+
import { GroupInfoDialog } from "./dialogs/GroupInfoDialog";
|
|
16
|
+
import { GroupInfoViewDialog } from "./dialogs/GroupInfoViewDialog";
|
|
17
|
+
import { ListTodo, ReceiptText, MessageCircle, FilePenLine } from "lucide-react";
|
|
18
|
+
import { Button } from "../misc/button";
|
|
19
|
+
import { confirmActions, deleteActions, showAlert } from "../misc/alertdialogclaude";
|
|
20
|
+
import { userApi } from "@myrjfa/state/dist/lib/actions/user";
|
|
21
|
+
import { checkPhonePermission } from "../utils/permissions";
|
|
22
|
+
export function ChatMain({ conversation, currentUserId, onBack, }) {
|
|
23
|
+
var _a, _b, _c, _d, _e;
|
|
24
|
+
const { socket, messages, setMessages, sendMessage, typingUsers, onlineUsers, editMessage, toggleMessageReaction, deleteMessage, markRead, createPoll, votePoll, refreshConversations } = useChatContext();
|
|
25
|
+
const messagesEndRef = useRef(null);
|
|
26
|
+
const messagesContainerRef = useRef(null);
|
|
27
|
+
const [activePanel, setActivePanel] = React.useState("chat");
|
|
28
|
+
const [isParticipantsOpen, setIsParticipantsOpen] = React.useState(false);
|
|
29
|
+
const [isGroupInfoOpen, setIsGroupInfoOpen] = React.useState(false);
|
|
30
|
+
const [isGroupInfoViewOpen, setIsGroupInfoViewOpen] = React.useState(false);
|
|
31
|
+
const [loading, setLoading] = React.useState(true);
|
|
32
|
+
const [replyMessage, setReplyMessage] = React.useState(null);
|
|
33
|
+
const [editingMessage, setEditingMessage] = React.useState(null);
|
|
34
|
+
const [hasBlocked, setHasBlocked] = React.useState(false);
|
|
35
|
+
const [isBlocked, setIsBlocked] = React.useState(false);
|
|
36
|
+
const otherUser = conversation.participants.length == 2 ? conversation.participants.find(p => p.userId !== currentUserId) : null;
|
|
37
|
+
const router = useRouter();
|
|
38
|
+
// Reset active panel when conversation changes
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
setActivePanel("chat");
|
|
41
|
+
setIsBlocked(false);
|
|
42
|
+
setHasBlocked(false);
|
|
43
|
+
setIsGroupInfoOpen(false);
|
|
44
|
+
setIsGroupInfoViewOpen(false);
|
|
45
|
+
setIsParticipantsOpen(false);
|
|
46
|
+
setEditingMessage(null);
|
|
47
|
+
setReplyMessage(null);
|
|
48
|
+
}, [conversation._id]);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
let cancelled = false;
|
|
51
|
+
setLoading(true);
|
|
52
|
+
chatApi
|
|
53
|
+
.getMessages(conversation._id, { limit: 50 })
|
|
54
|
+
.then((data) => {
|
|
55
|
+
if (!cancelled) {
|
|
56
|
+
setMessages(data);
|
|
57
|
+
setLoading(false);
|
|
58
|
+
if (document.visibilityState === "visible") {
|
|
59
|
+
const unreadIds = data.filter(m => { var _a; return !((_a = m.readBy) === null || _a === void 0 ? void 0 : _a.some(r => r.userId === currentUserId)) && m.senderId !== currentUserId; }).map(m => m._id);
|
|
60
|
+
if (unreadIds.length > 0) {
|
|
61
|
+
markRead(conversation._id, unreadIds);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
.catch((e) => {
|
|
67
|
+
console.error(e);
|
|
68
|
+
if (!cancelled)
|
|
69
|
+
setLoading(false);
|
|
70
|
+
});
|
|
71
|
+
return () => {
|
|
72
|
+
cancelled = true;
|
|
73
|
+
};
|
|
74
|
+
}, [conversation._id, setMessages]);
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
var _a;
|
|
77
|
+
(_a = messagesEndRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView({ behavior: "smooth" });
|
|
78
|
+
}, [messages]);
|
|
79
|
+
// Check block status for individual chats
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (conversation.type === 'individual') {
|
|
82
|
+
if (otherUser) {
|
|
83
|
+
userApi.checkIfBlocked(otherUser.userId, otherUser.role).then(b => {
|
|
84
|
+
setIsBlocked(b.isBlocked);
|
|
85
|
+
setHasBlocked(b.hasBlocked);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}, [conversation._id, conversation.type, currentUserId]);
|
|
90
|
+
const initiateEdit = (message) => {
|
|
91
|
+
setEditingMessage(message);
|
|
92
|
+
setReplyMessage(message);
|
|
93
|
+
};
|
|
94
|
+
const handleEdit = useCallback((messageId, newText) => {
|
|
95
|
+
if (newText !== null && newText.trim() !== "" && newText !== (editingMessage === null || editingMessage === void 0 ? void 0 : editingMessage.content.text)) {
|
|
96
|
+
editMessage(messageId, newText);
|
|
97
|
+
}
|
|
98
|
+
setEditingMessage(null);
|
|
99
|
+
setReplyMessage(null);
|
|
100
|
+
}, [editMessage, editingMessage, replyMessage]);
|
|
101
|
+
const handleReact = (messageId, emoji) => {
|
|
102
|
+
if (emoji) {
|
|
103
|
+
toggleMessageReaction(messageId, emoji);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const handleUnreact = (messageId) => {
|
|
107
|
+
if (messageId) {
|
|
108
|
+
toggleMessageReaction(messageId, undefined);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const handleDelete = (messageId) => {
|
|
112
|
+
let confirmUnsend = false;
|
|
113
|
+
showAlert("Are you sure you want to unsend this message?", undefined, deleteActions(() => confirmUnsend = true));
|
|
114
|
+
if (confirmUnsend) {
|
|
115
|
+
deleteMessage(messageId);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
const handleLeaveGroup = async () => {
|
|
119
|
+
if (isAdmin && conversation.participants.filter(p => p.chatRole == "admin").length < 2) {
|
|
120
|
+
await showAlert("Please assign someone else admin before leaving group");
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
let confirmLeave = true;
|
|
124
|
+
showAlert("Are you sure you want to leave this group?", undefined, confirmActions(() => confirmLeave = false));
|
|
125
|
+
if (confirmLeave) {
|
|
126
|
+
try {
|
|
127
|
+
await chatApi.removeParticipant(conversation._id, currentUserId);
|
|
128
|
+
onBack();
|
|
129
|
+
}
|
|
130
|
+
catch (err) {
|
|
131
|
+
console.error("Failed to leave group:", err);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const handleBlockUser = async () => {
|
|
136
|
+
if (otherUser) {
|
|
137
|
+
const response = await userApi.blockUser(otherUser.userId, otherUser.role);
|
|
138
|
+
if (response.error) {
|
|
139
|
+
console.log("Error blocking user " + otherUser.userId + "Error: " + response.error);
|
|
140
|
+
await showAlert("Error blocking user");
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
setHasBlocked(true);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
const handleUnblockUser = async () => {
|
|
148
|
+
if (otherUser) {
|
|
149
|
+
const response = await userApi.unblockUser(otherUser.userId, otherUser.role);
|
|
150
|
+
if (response.error) {
|
|
151
|
+
console.log("Error unblocking user " + otherUser.userId + "Error: " + response.error);
|
|
152
|
+
await showAlert("Error unblocking user");
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
setHasBlocked(false);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const handleDeleteConversation = async () => {
|
|
160
|
+
const confirmMsg = isGroup ? "Are you sure you want to delete this group?" : "Are you sure you want to delete this chat?";
|
|
161
|
+
let confirmDelete = false;
|
|
162
|
+
showAlert(confirmMsg, undefined, deleteActions(() => confirmDelete = true));
|
|
163
|
+
if (confirmDelete) {
|
|
164
|
+
try {
|
|
165
|
+
await chatApi.deleteConversation(conversation._id);
|
|
166
|
+
onBack();
|
|
167
|
+
}
|
|
168
|
+
catch (err) {
|
|
169
|
+
console.error("Failed to delete conversation:", err);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
const handleSend = useCallback((text, files) => {
|
|
174
|
+
sendMessage(conversation._id, text, files, replyMessage === null || replyMessage === void 0 ? void 0 : replyMessage._id);
|
|
175
|
+
setReplyMessage(null);
|
|
176
|
+
}, [conversation._id, sendMessage, replyMessage]);
|
|
177
|
+
const handleOpenPrivateChat = useCallback((userId) => {
|
|
178
|
+
// This is a simplified navigation. In a real application, you might
|
|
179
|
+
// want to check if a conversation with this user already exists
|
|
180
|
+
// and navigate to it, or create a new one.
|
|
181
|
+
router.push(`/chat?u=${userId}`);
|
|
182
|
+
}, [router]);
|
|
183
|
+
const handleScrollToReply = (messageId) => {
|
|
184
|
+
const element = document.getElementById(`message-${messageId}`);
|
|
185
|
+
if (element) {
|
|
186
|
+
element.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
187
|
+
element.classList.add("ring-2", "ring-teal-500");
|
|
188
|
+
setTimeout(() => {
|
|
189
|
+
element.classList.remove("ring-2", "ring-teal-500");
|
|
190
|
+
}, 2000);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
const handleEnableMilestones = () => {
|
|
194
|
+
setIsGroupInfoOpen(true);
|
|
195
|
+
};
|
|
196
|
+
const handleEnableExpenses = () => {
|
|
197
|
+
setIsGroupInfoOpen(true);
|
|
198
|
+
};
|
|
199
|
+
const handleCall = async () => {
|
|
200
|
+
const hasPermission = await checkPhonePermission();
|
|
201
|
+
if (!hasPermission) {
|
|
202
|
+
showAlert("Phone permission required for calls");
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (otherUser) {
|
|
206
|
+
// Initiate tel: link (will prompt to call on mobile/desktop)
|
|
207
|
+
window.location.href = `tel:${otherUser.userId}`;
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
const handleTypingStart = useCallback(() => {
|
|
211
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("typing:start", { conversationId: conversation._id });
|
|
212
|
+
}, [socket, conversation._id]);
|
|
213
|
+
const handleTypingStop = useCallback(() => {
|
|
214
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("typing:stop", { conversationId: conversation._id });
|
|
215
|
+
}, [socket, conversation._id]);
|
|
216
|
+
function getDisplayName() {
|
|
217
|
+
if (conversation.type === "group")
|
|
218
|
+
return conversation.name || "Group Chat";
|
|
219
|
+
const other = conversation.participants.find((p) => p.userId !== currentUserId);
|
|
220
|
+
return (other === null || other === void 0 ? void 0 : other.userId) || "Chat";
|
|
221
|
+
}
|
|
222
|
+
function getSubtitle() {
|
|
223
|
+
if (conversation.type === "group") {
|
|
224
|
+
return `${conversation.participants.length} members`;
|
|
225
|
+
}
|
|
226
|
+
const other = conversation.participants.find((p) => p.userId !== currentUserId);
|
|
227
|
+
if (other && onlineUsers.has(other.userId))
|
|
228
|
+
return "Online";
|
|
229
|
+
return "Offline";
|
|
230
|
+
}
|
|
231
|
+
const getSenderImage = (senderId) => {
|
|
232
|
+
const p = conversation.participants.find(p => p.userId === senderId);
|
|
233
|
+
return (p === null || p === void 0 ? void 0 : p.profilePic) || "";
|
|
234
|
+
};
|
|
235
|
+
const handleInfo = () => {
|
|
236
|
+
if (conversation.type === "individual") {
|
|
237
|
+
const other = conversation.participants.find(p => p.userId !== currentUserId);
|
|
238
|
+
if (other) {
|
|
239
|
+
router.push(`/profile/${other.role}/${other.userId}`);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
else if (conversation.type === "group") {
|
|
243
|
+
setIsGroupInfoViewOpen(true);
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
const typing = typingUsers.get(conversation._id);
|
|
247
|
+
const isGroup = conversation.type === "group";
|
|
248
|
+
const isAdmin = ((_a = conversation.participants.find(p => p.userId === currentUserId)) === null || _a === void 0 ? void 0 : _a.chatRole) === "admin";
|
|
249
|
+
return (_jsxs("div", { className: "flex flex-col h-full bg-gray-50 dark:bg-gray-950", children: [_jsxs("div", { className: "flex items-center gap-3 px-4 py-3 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700 shadow-sm flex-shrink-0", children: [_jsx(Button, { variant: "ghost", size: "icon", onClick: onBack, className: "md:hidden rounded-full", children: _jsx(ArrowLeft, { className: "w-5 h-5" }) }), _jsxs(Avatar, { className: "w-10 h-10 shadow-md flex-shrink-0", children: [_jsx(AvatarImage, { src: isGroup ? conversation.image : isBlocked ? undefined : otherUser === null || otherUser === void 0 ? void 0 : otherUser.profilePic }), _jsx(AvatarFallback, { className: isGroup
|
|
250
|
+
? "bg-gradient-to-br from-teal-500 to-cyan-600 text-white"
|
|
251
|
+
: "bg-gradient-to-br from-teal-400 to-cyan-500 text-white", children: isGroup ? _jsx(Users, { className: "w-5 h-5" }) : getDisplayName().charAt(0).toUpperCase() })] }), _jsxs("div", { className: "flex-1 min-w-0", children: [_jsx("h2", { className: "font-semibold text-gray-900 dark:text-white truncate", children: getDisplayName() }), _jsx("p", { className: "text-xs text-gray-500", children: typing && typing.length > 0 ? (_jsx("span", { className: "text-teal-600 dark:text-teal-400 italic", children: typing.length === 1 ? "typing..." : `${typing.length} people typing...` })) : (getSubtitle()) })] }), !isGroup && !hasBlocked && !isBlocked && (_jsx(Button, { variant: "ghost", size: "icon", onClick: handleCall, className: "rounded-full text-gray-400 hover:text-teal-500 flex-shrink-0", title: "Call", children: _jsx(Phone, { className: "w-5 h-5" }) })), !isBlocked && !hasBlocked && _jsx(Button, { variant: "ghost", size: "icon", onClick: handleInfo, className: "rounded-full text-gray-400 flex-shrink-0", children: _jsx(Info, { className: "w-5 h-5" }) }), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "icon", className: "rounded-full text-gray-400 flex-shrink-0", children: _jsx(MoreVertical, { className: "w-5 h-5" }) }) }), _jsxs(DropdownMenuContent, { align: "end", children: [!isBlocked && !hasBlocked && _jsx(DropdownMenuItem, { onClick: handleInfo, children: "Info" }), isGroup && _jsxs(DropdownMenuItem, { onClick: () => setIsParticipantsOpen(true), children: [_jsx(Users, { className: "w-4 h-4 mr-2" }), isAdmin ? "Manage Members" : "View Members"] }), isAdmin && isGroup && (_jsxs(DropdownMenuItem, { onClick: () => setIsGroupInfoOpen(true), children: [_jsx(FilePenLine, { className: "w-4 h-4 mr-2" }), "Edit Group Info"] })), !isGroup && (otherUser === null || otherUser === void 0 ? void 0 : otherUser.role) == "user" && !isBlocked && (hasBlocked ?
|
|
252
|
+
(_jsx(DropdownMenuItem, { className: "text-red-500", onClick: handleUnblockUser, children: "Unblock User" })) :
|
|
253
|
+
(_jsx(DropdownMenuItem, { className: "text-red-500", onClick: handleBlockUser, children: "Block User" }))), isAdmin && _jsx(DropdownMenuItem, { className: "text-red-500", onClick: handleDeleteConversation, children: isGroup ? "Delete Group" : "Delete Chat" }), isGroup && (_jsx(DropdownMenuItem, { className: "text-red-600", onClick: handleLeaveGroup, children: "Leave Group" }))] })] })] }), isGroup && (_jsxs("div", { className: "flex border-b border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 flex-shrink-0", children: [_jsxs("button", { onClick: () => setActivePanel("chat"), className: `flex-1 py-3 px-4 text-center font-medium text-sm transition-colors border-b-2 ${activePanel === "chat"
|
|
254
|
+
? "border-teal-500 text-teal-600 dark:text-teal-400"
|
|
255
|
+
: "border-transparent text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200"}`, children: [_jsx(MessageCircle, { className: "w-4 h-4 inline mr-2" }), _jsx("span", { className: "hidden sm:inline", children: "Chat" })] }), _jsxs("button", { onClick: () => setActivePanel("milestones"), className: `flex-1 py-3 px-4 text-center font-medium text-sm transition-colors border-b-2 ${activePanel === "milestones"
|
|
256
|
+
? "border-teal-500 text-teal-600 dark:text-teal-400"
|
|
257
|
+
: "border-transparent text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200"}`, children: [_jsx(ListTodo, { className: "w-4 h-4 inline mr-2" }), _jsx("span", { className: "hidden sm:inline", children: "Milestones" })] }), _jsxs("button", { onClick: () => setActivePanel("expenses"), className: `flex-1 py-3 px-4 text-center font-medium text-sm transition-colors border-b-2 ${activePanel === "expenses"
|
|
258
|
+
? "border-teal-500 text-teal-600 dark:text-teal-400"
|
|
259
|
+
: "border-transparent text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200"}`, children: [_jsx(ReceiptText, { className: "w-4 h-4 inline mr-2" }), _jsx("span", { className: "hidden sm:inline", children: "Expenses" })] })] })), _jsxs("div", { className: "flex-1 flex overflow-hidden gap-0", children: [_jsxs("div", { className: `flex flex-col min-w-0 ${isGroup && activePanel !== "chat" ? "hidden md:flex" : "flex"} flex-1`, children: [_jsx("div", { className: "flex-1 overflow-y-auto px-4 py-4 custom-scrollbar bg-indigo-50/20 dark:bg-gray-900/40", ref: messagesContainerRef, children: loading ? (_jsx("div", { className: "flex items-center justify-center h-full", children: _jsx("div", { className: "animate-spin w-8 h-8 border-4 border-teal-500 border-t-transparent rounded-full" }) })) : messages.length === 0 ? (_jsxs("div", { className: "flex flex-col items-center justify-center h-full text-gray-400", children: [_jsx("p", { className: "text-lg", children: "\uD83D\uDC4B Start the conversation!" }), _jsx("p", { className: "text-sm mt-1", children: "Send a message to get things going" })] })) : (_jsxs("div", { className: "max-w-4xl mx-auto space-y-4", children: [messages.map((msg, i) => {
|
|
260
|
+
const prevMsg = messages[i - 1];
|
|
261
|
+
const currDate = new Date(msg.createdAt).toLocaleDateString();
|
|
262
|
+
const prevDate = prevMsg ? new Date(prevMsg.createdAt).toLocaleDateString() : null;
|
|
263
|
+
const showDateBadge = currDate !== prevDate;
|
|
264
|
+
const showSender = isGroup &&
|
|
265
|
+
msg.senderId !== currentUserId &&
|
|
266
|
+
(!prevMsg || prevMsg.senderId !== msg.senderId || showDateBadge);
|
|
267
|
+
return (_jsxs(React.Fragment, { children: [showDateBadge && (_jsx("div", { className: "flex justify-center my-4", children: _jsx("div", { className: "bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400 text-[10px] font-medium px-3 py-1 rounded-full shadow-sm uppercase tracking-wider", children: new Date(msg.createdAt).toLocaleDateString(undefined, { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }) }) })), _jsx(MessageBubble, { message: msg, participants: conversation.participants, currentUserId: currentUserId, showSender: showSender, senderProfilePic: getSenderImage(msg.senderId), onEdit: initiateEdit, onDelete: handleDelete, onReply: (msg) => setReplyMessage(msg), onReactionAdd: handleReact, onReactionRemove: handleUnreact, onScrollToReply: handleScrollToReply, onVote: (pid, idx) => votePoll(pid, idx) })] }, msg._id));
|
|
268
|
+
}), _jsx("div", { ref: messagesEndRef })] })) }), !isBlocked && !hasBlocked && _jsx(MessageInput, { onSend: handleSend, onTypingStart: handleTypingStart, onTypingStop: handleTypingStop, replyTo: replyMessage, editMessage: editingMessage, onEdit: handleEdit, onCancelEdit: () => {
|
|
269
|
+
setEditingMessage(null);
|
|
270
|
+
setReplyMessage(null);
|
|
271
|
+
}, onCancelReply: () => setReplyMessage(null), onAddMilestone: () => setActivePanel("milestones"), onAddExpense: () => setActivePanel("expenses"), onCreatePoll: (q, opts, multi) => createPoll(conversation._id, q, opts, multi), participants: conversation.participants, activePanel: activePanel })] }), isGroup && (_jsxs(_Fragment, { children: [activePanel === "milestones" && (_jsx("div", { className: "hidden md:flex md:flex-col w-80 border-l border-gray-200 dark:border-gray-700 min-w-0", children: _jsx(MilestonePanel, { conversationId: conversation._id, currentUserId: currentUserId, isFeatureEnabled: (_b = conversation.features) === null || _b === void 0 ? void 0 : _b.milestones, isAdmin: isAdmin, onEnableFeature: handleEnableMilestones }) })), activePanel === "expenses" && (_jsx("div", { className: "hidden md:flex md:flex-col w-80 border-l border-gray-200 dark:border-gray-700 min-w-0", children: _jsx(ExpensePanel, { conversationId: conversation._id, currentUserId: currentUserId, isFeatureEnabled: (_c = conversation.features) === null || _c === void 0 ? void 0 : _c.expenses, isAdmin: isAdmin, onEnableFeature: handleEnableExpenses }) }))] })), isGroup && activePanel === "milestones" && (_jsx("div", { className: "md:hidden w-full h-full overflow-hidden", children: _jsx(MilestonePanel, { conversationId: conversation._id, currentUserId: currentUserId, isFullScreen: true, isFeatureEnabled: (_d = conversation.features) === null || _d === void 0 ? void 0 : _d.milestones, isAdmin: isAdmin, onEnableFeature: handleEnableMilestones }) })), isGroup && activePanel === "expenses" && (_jsx("div", { className: "md:hidden w-full h-full overflow-hidden", children: _jsx(ExpensePanel, { conversationId: conversation._id, currentUserId: currentUserId, isFullScreen: true, isFeatureEnabled: (_e = conversation.features) === null || _e === void 0 ? void 0 : _e.expenses, isAdmin: isAdmin, onEnableFeature: handleEnableExpenses }) }))] }), _jsx(ParticipantsDialog, { open: isParticipantsOpen, onOpenChange: setIsParticipantsOpen, conversation: conversation, currentUserId: currentUserId, onUpdate: refreshConversations }), isGroup && (_jsx(GroupInfoDialog, { open: isGroupInfoOpen, onOpenChange: setIsGroupInfoOpen, conversation: conversation, onUpdate: refreshConversations })), isGroup && (_jsx(GroupInfoViewDialog, { open: isGroupInfoViewOpen, onOpenChange: setIsGroupInfoViewOpen, conversation: conversation }))] }));
|
|
272
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Conversation } from "@myrjfa/state/dist/lib/models/chat";
|
|
2
|
+
interface ChatSidebarProps {
|
|
3
|
+
conversations: Conversation[];
|
|
4
|
+
activeConversation: Conversation | null;
|
|
5
|
+
onSelect: (conv: Conversation) => void;
|
|
6
|
+
isConnected: boolean;
|
|
7
|
+
currentUserId: string;
|
|
8
|
+
onlineUsers?: Set<string>;
|
|
9
|
+
typingUsers?: Map<string, string[]>;
|
|
10
|
+
}
|
|
11
|
+
export declare function ChatSidebar({ conversations, activeConversation, onSelect, isConnected, currentUserId, onlineUsers, typingUsers }: ChatSidebarProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=ChatSidebar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatSidebar.d.ts","sourceRoot":"","sources":["../../src/chat/ChatSidebar.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAEvE,UAAU,gBAAgB;IACtB,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,kBAAkB,EAAE,YAAY,GAAG,IAAI,CAAC;IACxC,QAAQ,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;IACvC,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CACvC;AAED,wBAAgB,WAAW,CAAC,EACxB,aAAa,EACb,kBAAkB,EAClB,QAAQ,EACR,WAAW,EACX,aAAa,EACb,WAAW,EACX,WAAW,EACd,EAAE,gBAAgB,2CAoElB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { MessageCircle, Plus, Wifi, WifiOff } from "lucide-react";
|
|
5
|
+
import { Input } from "../misc/input";
|
|
6
|
+
import { ScrollArea } from "../misc/scroll-area";
|
|
7
|
+
import { ConversationList } from "./ConversationList";
|
|
8
|
+
import { NewChatDialog } from "./dialogs/NewChatDialog";
|
|
9
|
+
import { NewGroupDialog } from "./dialogs/NewGroupDialog";
|
|
10
|
+
export function ChatSidebar({ conversations, activeConversation, onSelect, isConnected, currentUserId, onlineUsers, typingUsers }) {
|
|
11
|
+
const [showNewChat, setShowNewChat] = useState(false);
|
|
12
|
+
const [search, setSearch] = useState("");
|
|
13
|
+
const filteredConversations = Array.isArray(conversations)
|
|
14
|
+
? conversations.filter(c => {
|
|
15
|
+
var _a;
|
|
16
|
+
if (!search)
|
|
17
|
+
return true;
|
|
18
|
+
const name = c.name || ((_a = c.participants.find(p => p.userId !== currentUserId)) === null || _a === void 0 ? void 0 : _a.userId) || "";
|
|
19
|
+
return name.toLowerCase().includes(search.toLowerCase());
|
|
20
|
+
})
|
|
21
|
+
: [];
|
|
22
|
+
return (_jsxs("div", { className: `w-full md:w-96 md:min-w-[384px] border-r border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 flex flex-col h-full ${activeConversation ? "hidden md:flex" : "flex"}`, children: [_jsxs("div", { className: "flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-800", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(MessageCircle, { className: "w-6 h-6 text-teal-500" }), _jsx("h1", { className: "text-xl font-bold text-gray-900 dark:text-gray-100", children: "Messages" })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("div", { className: "flex items-center gap-1", children: isConnected ? (_jsx(Wifi, { className: "w-4 h-4 text-green-500" })) : (_jsx(WifiOff, { className: "w-4 h-4 text-red-500" })) }), _jsx("button", { onClick: () => setShowNewChat(!showNewChat), className: "p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-full transition-colors text-gray-600 dark:text-gray-400 cursor-pointer", children: _jsx(Plus, { className: "w-5 h-5" }) })] })] }), _jsx("div", { className: "p-3", children: _jsx(Input, { placeholder: "Search conversations...", value: search, onChange: (e) => setSearch(e.target.value), className: "bg-gray-100 dark:bg-gray-800 border-none" }) }), showNewChat && (_jsxs("div", { className: "px-3 pb-3 flex gap-2", children: [_jsx(NewChatDialog, {}), _jsx(NewGroupDialog, {})] })), _jsx(ScrollArea, { className: "flex-1", children: _jsx(ConversationList, { conversations: filteredConversations, activeConversation: activeConversation, onSelect: onSelect, currentUserId: currentUserId, onlineUsers: onlineUsers, typingUsers: typingUsers }) })] }));
|
|
23
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Conversation } from "@myrjfa/state/dist/lib/models/chat";
|
|
2
|
+
interface ChatListProps {
|
|
3
|
+
conversations: Conversation[];
|
|
4
|
+
activeConversation: Conversation | null;
|
|
5
|
+
onSelect: (conv: Conversation) => void;
|
|
6
|
+
currentUserId: string;
|
|
7
|
+
onlineUsers?: Set<string>;
|
|
8
|
+
typingUsers?: Map<string, string[]>;
|
|
9
|
+
}
|
|
10
|
+
export declare function ConversationList({ conversations, activeConversation, onSelect, currentUserId, onlineUsers, typingUsers }: ChatListProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=ConversationList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConversationList.d.ts","sourceRoot":"","sources":["../../src/chat/ConversationList.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAEvE,UAAU,aAAa;IACnB,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,kBAAkB,EAAE,YAAY,GAAG,IAAI,CAAC;IACxC,QAAQ,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;IACvC,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CACvC;AAED,wBAAgB,gBAAgB,CAAC,EAC7B,aAAa,EACb,kBAAkB,EAClB,QAAQ,EACR,aAAa,EACb,WAAuB,EACvB,WAAuB,EAC1B,EAAE,aAAa,2CA4Hf"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Users, User, MessageCircle, ListTodo, ReceiptText, AtSign } from "lucide-react";
|
|
4
|
+
import { Avatar, AvatarFallback, AvatarImage } from "../misc/avatar";
|
|
5
|
+
import { cn } from "@myrjfa/state/dist/lib/utils";
|
|
6
|
+
export function ConversationList({ conversations, activeConversation, onSelect, currentUserId, onlineUsers = new Set(), typingUsers = new Map() }) {
|
|
7
|
+
function getDisplayName(conv) {
|
|
8
|
+
if (conv.type === "group")
|
|
9
|
+
return conv.name || "Group Chat";
|
|
10
|
+
const other = conv.participants.find((p) => p.userId !== currentUserId);
|
|
11
|
+
// We might want to fetch user details if name is missing?
|
|
12
|
+
// For now, assume ID or fetched data.
|
|
13
|
+
// In real app, we should populate this.
|
|
14
|
+
return (other === null || other === void 0 ? void 0 : other.userId) || "Chat";
|
|
15
|
+
}
|
|
16
|
+
function getDisplayImage(conv) {
|
|
17
|
+
if (conv.type === "group")
|
|
18
|
+
return conv.image || "";
|
|
19
|
+
const other = conv.participants.find((p) => p.userId !== currentUserId);
|
|
20
|
+
return (other === null || other === void 0 ? void 0 : other.profilePic) || "";
|
|
21
|
+
}
|
|
22
|
+
// Identify the "other" user for avatar
|
|
23
|
+
function getOtherParticipantId(conv) {
|
|
24
|
+
if (conv.type === "group")
|
|
25
|
+
return null;
|
|
26
|
+
const other = conv.participants.find((p) => p.userId !== currentUserId);
|
|
27
|
+
return other === null || other === void 0 ? void 0 : other.userId;
|
|
28
|
+
}
|
|
29
|
+
function isOtherOnline(conv) {
|
|
30
|
+
if (conv.type !== "individual")
|
|
31
|
+
return false;
|
|
32
|
+
const otherAndId = getOtherParticipantId(conv);
|
|
33
|
+
return otherAndId ? onlineUsers.has(otherAndId) : false;
|
|
34
|
+
}
|
|
35
|
+
function formatTime(dateStr) {
|
|
36
|
+
if (!dateStr)
|
|
37
|
+
return "";
|
|
38
|
+
const date = new Date(dateStr);
|
|
39
|
+
const now = new Date();
|
|
40
|
+
const diff = now.getTime() - date.getTime();
|
|
41
|
+
if (diff < 60000)
|
|
42
|
+
return "Just now";
|
|
43
|
+
if (diff < 3600000)
|
|
44
|
+
return `${Math.floor(diff / 60000)}m`;
|
|
45
|
+
if (diff < 86400000)
|
|
46
|
+
return date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
|
47
|
+
return date.toLocaleDateString([], { month: "short", day: "numeric" });
|
|
48
|
+
}
|
|
49
|
+
function getTypingText(convId) {
|
|
50
|
+
const users = typingUsers.get(convId);
|
|
51
|
+
if (!users || users.length === 0)
|
|
52
|
+
return null;
|
|
53
|
+
if (users.length === 1)
|
|
54
|
+
return "typing...";
|
|
55
|
+
return `${users.length} people typing...`;
|
|
56
|
+
}
|
|
57
|
+
if (conversations.length === 0) {
|
|
58
|
+
return (_jsxs("div", { className: "flex flex-col items-center justify-center h-full text-gray-400 p-8", children: [_jsx(MessageCircle, { className: "w-16 h-16 mb-4 opacity-30" }), _jsx("p", { className: "text-lg font-medium", children: "No conversations yet" }), _jsx("p", { className: "text-sm mt-1", children: "Start a new chat to begin" })] }));
|
|
59
|
+
}
|
|
60
|
+
return (_jsx("div", { className: "flex-1 overflow-y-auto", children: conversations.map((conv) => {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
const isActive = (activeConversation === null || activeConversation === void 0 ? void 0 : activeConversation._id) === conv._id;
|
|
63
|
+
const typing = getTypingText(conv._id);
|
|
64
|
+
const isOnline = isOtherOnline(conv);
|
|
65
|
+
const participant = conv.participants.find(p => p.userId === currentUserId);
|
|
66
|
+
const unread = (participant === null || participant === void 0 ? void 0 : participant.unreadCounts) || { messages: 0, milestones: 0, expenses: 0, mentions: 0 };
|
|
67
|
+
const totalUnread = unread.messages + unread.milestones + unread.expenses + unread.mentions;
|
|
68
|
+
return (_jsxs("button", { onClick: () => onSelect(conv), className: cn("w-full flex items-center gap-3 p-4 hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-all duration-200 border-b border-gray-100 dark:border-gray-800", isActive ? "bg-indigo-50 dark:bg-indigo-950/30 border-l-4 border-l-indigo-500" : "border-l-4 border-l-transparent"), children: [_jsxs("div", { className: "relative", children: [_jsxs(Avatar, { children: [_jsx(AvatarImage, { src: getDisplayImage(conv) }), _jsx(AvatarFallback, { className: conv.type === "group" ? "bg-indigo-100 text-indigo-600" : "bg-teal-100 text-teal-600", children: conv.type === "group" ? _jsx(Users, { className: "w-4 h-4" }) : _jsx(User, { className: "w-4 h-4" }) })] }), isOnline && (_jsx("span", { className: "absolute bottom-0 right-0 w-3 h-3 bg-green-500 border-2 border-white dark:border-gray-900 rounded-full" }))] }), _jsxs("div", { className: "flex-1 min-w-0 text-left", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("span", { className: "font-semibold text-gray-900 dark:text-gray-100 truncate text-sm", children: getDisplayName(conv) }), _jsx("span", { className: "text-xs text-gray-400 ml-2 whitespace-nowrap", children: formatTime((_a = conv.lastMessage) === null || _a === void 0 ? void 0 : _a.sentAt) })] }), _jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 truncate mt-0.5 flex-1", children: typing ? (_jsx("span", { className: "text-indigo-500 italic", children: typing })) : (((_b = conv.lastMessage) === null || _b === void 0 ? void 0 : _b.content) || "No messages yet") }), totalUnread > 0 && (_jsxs("div", { className: "flex gap-1 items-center shrink-0 mt-0.5", children: [unread.mentions > 0 && _jsx(AtSign, { className: "w-3 h-3 text-red-500" }), unread.milestones > 0 && _jsx(ListTodo, { className: "w-3 h-3 text-teal-500" }), unread.expenses > 0 && _jsx(ReceiptText, { className: "w-3 h-3 text-orange-500" }), _jsx("span", { className: "bg-indigo-600 text-white text-[10px] font-bold px-1.5 py-0.5 rounded-full min-w-[20px] text-center shadow-sm", children: totalUnread })] }))] })] })] }, conv._id));
|
|
69
|
+
}) }));
|
|
70
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface ExpensePanelProps {
|
|
2
|
+
conversationId: string;
|
|
3
|
+
currentUserId: string;
|
|
4
|
+
isFullScreen?: boolean;
|
|
5
|
+
isFeatureEnabled?: boolean;
|
|
6
|
+
isAdmin?: boolean;
|
|
7
|
+
onEnableFeature?: () => void;
|
|
8
|
+
}
|
|
9
|
+
export declare function ExpensePanel({ conversationId, currentUserId, isFullScreen, isFeatureEnabled, isAdmin, onEnableFeature }: ExpensePanelProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=ExpensePanel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpensePanel.d.ts","sourceRoot":"","sources":["../../src/chat/ExpensePanel.tsx"],"names":[],"mappings":"AAiBA,UAAU,iBAAiB;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;CAChC;AAED,wBAAgB,YAAY,CAAC,EACzB,cAAc,EACd,aAAa,EACb,YAAoB,EACpB,gBAAwB,EACxB,OAAe,EACf,eAAe,EAClB,EAAE,iBAAiB,2CAw0BnB"}
|