From 102e9c8e4f5fab00167d311520006cfca44e7e0e Mon Sep 17 00:00:00 2001 From: mlogclub Date: Wed, 6 May 2026 21:08:09 +0800 Subject: [PATCH] refactor: clean up imports and improve ConversationList structure --- .../_components/conversation-list.tsx | 166 +++++++++--------- 1 file changed, 82 insertions(+), 84 deletions(-) diff --git a/web/app/dashboard/conversations/_components/conversation-list.tsx b/web/app/dashboard/conversations/_components/conversation-list.tsx index b1bbb5c..d2a8c78 100644 --- a/web/app/dashboard/conversations/_components/conversation-list.tsx +++ b/web/app/dashboard/conversations/_components/conversation-list.tsx @@ -1,16 +1,16 @@ "use client" -import { UserIcon } from "lucide-react" +import { UserIcon } from "lucide-react"; -import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" -import { ScrollArea } from "@/components/ui/scroll-area" -import { formatDateTime } from "@/lib/utils" -import { useAgentConversationsStore } from "@/lib/stores/agent-conversations" +import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; +import { ScrollArea } from "@/components/ui/scroll-area"; +import { getEnumLabel } from "@/lib/enums"; import { - IMConversationStatus, - IMConversationStatusLabels, -} from "@/lib/generated/enums" -import { getEnumLabel } from "@/lib/enums" + IMConversationStatus, + IMConversationStatusLabels, +} from "@/lib/generated/enums"; +import { useAgentConversationsStore } from "@/lib/stores/agent-conversations"; +import { formatDateTime } from "@/lib/utils"; function getStatusVariant(status: number) { switch (status) { @@ -38,86 +38,84 @@ export function ConversationList({ onAfterSelect }: ConversationListProps) { const selectConversation = useAgentConversationsStore((state) => state.selectConversation) return ( - -
- {loading ? ( -
- 加载中... -
- ) : conversations.length > 0 ? ( - conversations.map((conversation) => { - const isSelected = selectedId === conversation.id - return ( -
{ - void selectConversation(conversation.id).then( - () => { - onAfterSelect?.() - }, - () => {}, - ) - }} - > -
-
- - - - - - -
-
- - {conversation.customerName || `客户 #${conversation.customerId || conversation.id}`} - - {conversation.agentUnreadCount > 0 ? ( -
- {conversation.agentUnreadCount > 99 - ? "99+" - : conversation.agentUnreadCount} -
- ) : null} -
-
- {conversation.lastMessageAt - ? formatDateTime(conversation.lastMessageAt) - : "暂无时间"} -
+ + {loading ? ( +
+ 加载中... +
+ ) : conversations.length > 0 ? ( + conversations.map((conversation) => { + const isSelected = selectedId === conversation.id + return ( +
{ + void selectConversation(conversation.id).then( + () => { + onAfterSelect?.() + }, + () => {}, + ) + }} + > +
+
+ + + + + + +
+
+ + {conversation.customerName || `客户 #${conversation.customerId || conversation.id}`} + + {conversation.agentUnreadCount > 0 ? ( +
+ {conversation.agentUnreadCount > 99 + ? "99+" + : conversation.agentUnreadCount} +
+ ) : null} +
+
+ {conversation.lastMessageAt + ? formatDateTime(conversation.lastMessageAt) + : "暂无时间"}
-
- {conversation.lastMessageSummary || "暂无最新消息"} -
-
- - {getEnumLabel(IMConversationStatusLabels, conversation.status)} +
+
+ {conversation.lastMessageSummary || "暂无最新消息"} +
+
+ + {getEnumLabel(IMConversationStatusLabels, conversation.status)} + + {conversation.status === IMConversationStatus.Pending && + conversation.currentTeamName ? ( + + 值班组:{conversation.currentTeamName} - {conversation.status === IMConversationStatus.Pending && - conversation.currentTeamName ? ( - - 值班组:{conversation.currentTeamName} - - ) : null} -
+ ) : null}
- ) - }) - ) : ( -
- 暂无会话 -
- )} -
+
+ ) + }) + ) : ( +
+ 暂无会话 +
+ )} ) }