Spaces:
Running
Running
axeronis commited on
Commit ·
cc5ef83
1
Parent(s): 9d4625f
feat: UI/UX Overhaul - Premium Chat Interface (3-Column Layout)
Browse files- frontend/app/chats/page.tsx +84 -292
- frontend/components/ChatWindow.tsx +63 -46
- frontend/components/ClientCard.tsx +28 -11
- frontend/components/LeadsList.tsx +179 -51
frontend/app/chats/page.tsx
CHANGED
|
@@ -1,342 +1,134 @@
|
|
| 1 |
'use client'
|
| 2 |
|
| 3 |
import { useState, useEffect, useMemo } from 'react'
|
|
|
|
|
|
|
|
|
|
| 4 |
import { useQuery } from '@tanstack/react-query'
|
| 5 |
-
import {
|
| 6 |
import { ChatWindow } from '@/components/ChatWindow'
|
| 7 |
import { ClientCard } from '@/components/ClientCard'
|
| 8 |
-
import {
|
| 9 |
-
import { cn } from '@/lib/utils'
|
| 10 |
-
import { subscribeToLeads, isRealtimeEnabled } from '@/lib/supabaseClient'
|
| 11 |
-
import { Search, Filter, Flame, MessageSquare, Inbox } from 'lucide-react'
|
| 12 |
|
| 13 |
export default function ChatsPage() {
|
| 14 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
const [searchQuery, setSearchQuery] = useState('')
|
| 16 |
const [activeTab, setActiveTab] = useState<'all' | 'hot' | 'unread'>('all')
|
| 17 |
-
const
|
| 18 |
|
|
|
|
| 19 |
const { data: leads, isLoading: leadsLoading, refetch: refetchLeads } = useQuery({
|
| 20 |
queryKey: ['leads', user?.tenant_id],
|
| 21 |
-
queryFn: () => leadsApi.getLeads(
|
| 22 |
-
enabled: !!user,
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
const { data: conversation, isLoading: conversationLoading, refetch: refetchConversation } = useQuery({
|
| 26 |
-
queryKey: ['conversation', user?.tenant_id, selectedLead?.id],
|
| 27 |
-
queryFn: () => leadsApi.getConversation(selectedLead!.id),
|
| 28 |
-
enabled: !!user && !!selectedLead,
|
| 29 |
})
|
| 30 |
|
| 31 |
-
//
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
console.log('🔌 Setting up Leads Realtime subscription')
|
| 36 |
-
|
| 37 |
-
const unsubscribe = subscribeToLeads(user.tenant_id, (updatedLead) => {
|
| 38 |
-
console.log('🔄 Lead updated via Realtime:', updatedLead)
|
| 39 |
-
refetchLeads()
|
| 40 |
-
|
| 41 |
-
if (selectedLead && selectedLead.id === updatedLead.id) {
|
| 42 |
-
console.log('✅ Updating selected lead state with fresh data')
|
| 43 |
-
setSelectedLead(prev => prev ? { ...prev, ...updatedLead } : null)
|
| 44 |
-
}
|
| 45 |
-
})
|
| 46 |
-
|
| 47 |
-
return () => {
|
| 48 |
-
console.log('🔌 Cleaning up Leads Realtime subscription')
|
| 49 |
-
unsubscribe()
|
| 50 |
-
}
|
| 51 |
-
}, [user?.tenant_id, refetchLeads, selectedLead])
|
| 52 |
-
|
| 53 |
-
const handleTakeover = async () => {
|
| 54 |
-
if (!selectedLead || !user) return
|
| 55 |
-
|
| 56 |
try {
|
| 57 |
-
await leadsApi.
|
| 58 |
-
|
|
|
|
| 59 |
} catch (error) {
|
| 60 |
-
console.error('
|
| 61 |
-
|
|
|
|
| 62 |
}
|
| 63 |
}
|
| 64 |
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
|
|
|
| 68 |
}
|
| 69 |
-
// Filter Leads
|
| 70 |
-
const filteredLeads = useMemo(() => {
|
| 71 |
-
if (!leads) return []
|
| 72 |
-
return leads.filter(lead => {
|
| 73 |
-
const matchesSearch = (lead.name || '').toLowerCase().includes(searchQuery.toLowerCase())
|
| 74 |
-
const matchesTab =
|
| 75 |
-
activeTab === 'all' ? true :
|
| 76 |
-
activeTab === 'hot' ? lead.heat_level === 'HOT' :
|
| 77 |
-
activeTab === 'unread' ? (lead.status || '').toLowerCase() === 'new' : true
|
| 78 |
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
if (authLoading || !user) {
|
| 84 |
return (
|
| 85 |
<div className="flex items-center justify-center h-screen bg-slate-50">
|
| 86 |
-
<
|
| 87 |
</div>
|
| 88 |
)
|
| 89 |
}
|
| 90 |
|
| 91 |
return (
|
| 92 |
-
<div className="h-screen
|
| 93 |
-
{/*
|
| 94 |
-
<div className=
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
</span>
|
| 106 |
-
</div>
|
| 107 |
-
|
| 108 |
-
{/* Search Bar */}
|
| 109 |
-
<div className="relative">
|
| 110 |
-
<Search className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400" />
|
| 111 |
-
<input
|
| 112 |
-
type="text"
|
| 113 |
-
placeholder="Поиск по имени..."
|
| 114 |
-
value={searchQuery}
|
| 115 |
-
onChange={(e) => setSearchQuery(e.target.value)}
|
| 116 |
-
className="w-full pl-9 pr-4 py-2 bg-slate-50 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-500 transition-all"
|
| 117 |
-
/>
|
| 118 |
-
</div>
|
| 119 |
-
|
| 120 |
-
{/* Tabs */}
|
| 121 |
-
<div className="flex p-1 bg-slate-100 rounded-lg">
|
| 122 |
-
<button
|
| 123 |
-
onClick={() => setActiveTab('all')}
|
| 124 |
-
className={cn(
|
| 125 |
-
"flex-1 py-1.5 text-xs font-medium rounded-md transition-all",
|
| 126 |
-
activeTab === 'all' ? "bg-white text-slate-900 shadow-sm" : "text-slate-500 hover:text-slate-700"
|
| 127 |
-
)}
|
| 128 |
-
>
|
| 129 |
-
Все
|
| 130 |
-
</button>
|
| 131 |
-
<button
|
| 132 |
-
onClick={() => setActiveTab('hot')}
|
| 133 |
-
className={cn(
|
| 134 |
-
"flex-1 py-1.5 text-xs font-medium rounded-md transition-all flex items-center justify-center gap-1",
|
| 135 |
-
activeTab === 'hot' ? "bg-white text-red-600 shadow-sm" : "text-slate-500 hover:text-slate-700"
|
| 136 |
-
)}
|
| 137 |
-
>
|
| 138 |
-
<Flame className="w-3 h-3" />
|
| 139 |
-
Горячие
|
| 140 |
-
</button>
|
| 141 |
-
<button
|
| 142 |
-
onClick={() => setActiveTab('unread')}
|
| 143 |
-
className={cn(
|
| 144 |
-
"flex-1 py-1.5 text-xs font-medium rounded-md transition-all",
|
| 145 |
-
activeTab === 'unread' ? "bg-white text-indigo-600 shadow-sm" : "text-slate-500 hover:text-slate-700"
|
| 146 |
-
)}
|
| 147 |
-
>
|
| 148 |
-
Новые
|
| 149 |
-
</button>
|
| 150 |
-
</div>
|
| 151 |
-
</div>
|
| 152 |
-
|
| 153 |
-
{/* List Content */}
|
| 154 |
-
<div className="flex-1 overflow-y-auto">
|
| 155 |
-
{leadsLoading ? (
|
| 156 |
-
// Skeleton Loading
|
| 157 |
-
<div className="divide-y divide-slate-100">
|
| 158 |
-
{[1, 2, 3, 4, 5].map((i) => (
|
| 159 |
-
<div key={i} className="p-4 animate-pulse">
|
| 160 |
-
<div className="flex justify-between mb-2">
|
| 161 |
-
<div className="h-4 bg-slate-200 rounded w-24"></div>
|
| 162 |
-
<div className="h-3 bg-slate-200 rounded w-12"></div>
|
| 163 |
-
</div>
|
| 164 |
-
<div className="h-3 bg-slate-200 rounded w-3/4 mb-2"></div>
|
| 165 |
-
<div className="flex gap-2">
|
| 166 |
-
<div className="h-2 bg-slate-200 rounded w-8"></div>
|
| 167 |
-
<div className="h-2 bg-slate-200 rounded w-12"></div>
|
| 168 |
-
</div>
|
| 169 |
-
</div>
|
| 170 |
-
))}
|
| 171 |
-
</div>
|
| 172 |
-
) : filteredLeads.length > 0 ? (
|
| 173 |
-
<div className="divide-y divide-slate-100">
|
| 174 |
-
{filteredLeads.map((lead) => {
|
| 175 |
-
const isSelected = selectedLead?.id === lead.id
|
| 176 |
-
|
| 177 |
-
// Map heat_level to status dot color
|
| 178 |
-
const getStatusDotColor = (heatLevel: string) => {
|
| 179 |
-
switch (heatLevel.toUpperCase()) {
|
| 180 |
-
case 'HOT': return 'bg-red-500 shadow-[0_0_8px_rgba(239,68,68,0.4)]'
|
| 181 |
-
case 'WARM': return 'bg-amber-500 shadow-[0_0_8px_rgba(245,158,11,0.4)]'
|
| 182 |
-
case 'COLD': return 'bg-blue-500 shadow-[0_0_8px_rgba(59,130,246,0.4)]'
|
| 183 |
-
default: return 'bg-slate-300'
|
| 184 |
-
}
|
| 185 |
-
}
|
| 186 |
-
|
| 187 |
-
const getBadgeLabel = (heatLevel: string) => {
|
| 188 |
-
switch (heatLevel.toUpperCase()) {
|
| 189 |
-
case 'HOT': return 'Горячий'
|
| 190 |
-
case 'WARM': return 'Тёплый'
|
| 191 |
-
case 'COLD': return 'Холодный'
|
| 192 |
-
default: return heatLevel
|
| 193 |
-
}
|
| 194 |
-
}
|
| 195 |
-
|
| 196 |
-
const getPsychotypeLabel = (psychotype: string) => {
|
| 197 |
-
const lower = psychotype.toLowerCase()
|
| 198 |
-
const map: Record<string, string> = {
|
| 199 |
-
'dominant': 'Доминантный',
|
| 200 |
-
'influential': 'Влияющий',
|
| 201 |
-
'steady': 'Стабильный',
|
| 202 |
-
'conscientious': 'Аналитический',
|
| 203 |
-
'unknown': 'Не определён'
|
| 204 |
-
}
|
| 205 |
-
return map[lower] || psychotype
|
| 206 |
-
}
|
| 207 |
-
|
| 208 |
-
return (
|
| 209 |
-
<div
|
| 210 |
-
key={lead.id}
|
| 211 |
-
onClick={() => setSelectedLead(lead)}
|
| 212 |
-
className={cn(
|
| 213 |
-
"p-4 cursor-pointer transition-all duration-200 hover:bg-slate-50 border-l-4 border-transparent group relative",
|
| 214 |
-
isSelected
|
| 215 |
-
? "bg-indigo-50/50 border-indigo-600"
|
| 216 |
-
: "hover:border-slate-200"
|
| 217 |
-
)}
|
| 218 |
-
>
|
| 219 |
-
<div className="flex items-start justify-between mb-1">
|
| 220 |
-
<div className="flex items-center gap-2 min-w-0">
|
| 221 |
-
<h3 className={cn(
|
| 222 |
-
"font-semibold text-sm truncate transition-colors",
|
| 223 |
-
isSelected ? "text-indigo-900" : "text-slate-900"
|
| 224 |
-
)}>
|
| 225 |
-
{lead.name || 'Без имени'}
|
| 226 |
-
</h3>
|
| 227 |
-
{lead.heat_score > 0 && (
|
| 228 |
-
<span className={cn(
|
| 229 |
-
"text-[10px] font-bold px-1.5 py-0.5 rounded-full",
|
| 230 |
-
lead.heat_score >= 80 ? "bg-red-100 text-red-700" :
|
| 231 |
-
lead.heat_score >= 50 ? "bg-amber-100 text-amber-700" :
|
| 232 |
-
"bg-blue-100 text-blue-700"
|
| 233 |
-
)}>
|
| 234 |
-
{lead.heat_score}
|
| 235 |
-
</span>
|
| 236 |
-
)}
|
| 237 |
-
</div>
|
| 238 |
-
<span className="text-[10px] text-slate-400 font-medium whitespace-nowrap ml-2">
|
| 239 |
-
{new Date(lead.last_message_at).toLocaleTimeString('ru-RU', { hour: '2-digit', minute: '2-digit' })}
|
| 240 |
-
</span>
|
| 241 |
-
</div>
|
| 242 |
-
|
| 243 |
-
<div className="flex items-center gap-2 mb-2">
|
| 244 |
-
<div className={cn("w-2 h-2 rounded-full", getStatusDotColor(lead.heat_level))} />
|
| 245 |
-
<span className="text-xs text-slate-500 font-medium">
|
| 246 |
-
{getBadgeLabel(lead.heat_level)}
|
| 247 |
-
</span>
|
| 248 |
-
<span className="text-slate-300">•</span>
|
| 249 |
-
<span className="text-xs text-slate-400 truncate max-w-[100px]">
|
| 250 |
-
{getPsychotypeLabel(lead.psychotype)}
|
| 251 |
-
</span>
|
| 252 |
-
</div>
|
| 253 |
-
|
| 254 |
-
<p className={cn(
|
| 255 |
-
"text-xs line-clamp-2 leading-relaxed",
|
| 256 |
-
isSelected ? "text-indigo-900/70" : "text-slate-500"
|
| 257 |
-
)}>
|
| 258 |
-
{lead.ai_summary_json?.intent || lead.ai_summary_json?.recommendation || 'Нет анализа'}
|
| 259 |
-
</p>
|
| 260 |
-
</div>
|
| 261 |
-
)
|
| 262 |
-
})}
|
| 263 |
-
</div>
|
| 264 |
-
) : (
|
| 265 |
-
<div className="flex flex-col items-center justify-center py-12 px-6 text-center">
|
| 266 |
-
<div className="w-16 h-16 rounded-full bg-slate-50 flex items-center justify-center mb-4">
|
| 267 |
-
<Inbox className="w-8 h-8 text-slate-300" />
|
| 268 |
-
</div>
|
| 269 |
-
<h3 className="text-sm font-semibold text-slate-900 mb-1">Нет лидов</h3>
|
| 270 |
-
<p className="text-xs text-slate-500">
|
| 271 |
-
{searchQuery ? 'По вашему запросу ничего не найдено' : 'Лиды появятся здесь, когда придут сообщения'}
|
| 272 |
-
</p>
|
| 273 |
-
</div>
|
| 274 |
-
)}
|
| 275 |
-
</div>
|
| 276 |
</div>
|
| 277 |
|
| 278 |
-
{/*
|
| 279 |
-
<div className=
|
| 280 |
-
"flex-1 bg-slate-50 h-screen overflow-hidden",
|
| 281 |
-
selectedLead ? "block" : "hidden md:block"
|
| 282 |
-
)}>
|
| 283 |
{selectedLead ? (
|
| 284 |
-
<
|
| 285 |
-
{
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
conversationId={conversation.id}
|
| 298 |
-
lead={selectedLead}
|
| 299 |
-
conversation={conversation}
|
| 300 |
-
isAnalyzing={selectedLead.processing_status === 'analyzing' || selectedLead.processing_status === 'generating'}
|
| 301 |
-
onRefresh={refetchConversation}
|
| 302 |
-
onTakeover={handleTakeover}
|
| 303 |
-
onBack={() => setSelectedLead(null)}
|
| 304 |
-
/>
|
| 305 |
-
) : null}
|
| 306 |
-
</div>
|
| 307 |
) : (
|
| 308 |
-
<div className="h-full flex items-center justify-center
|
| 309 |
-
<div className="
|
| 310 |
-
<
|
| 311 |
-
|
| 312 |
-
</div>
|
| 313 |
-
<p className="text-lg font-semibold mb-2 text-slate-900">Выберите диалог</p>
|
| 314 |
-
<p className="text-sm text-slate-500">Выберите лида из списка слева<br />для просмотра переписки</p>
|
| 315 |
</div>
|
|
|
|
| 316 |
</div>
|
| 317 |
)}
|
| 318 |
</div>
|
| 319 |
|
| 320 |
-
{/*
|
| 321 |
-
<div className="
|
| 322 |
{selectedLead ? (
|
| 323 |
<ClientCard
|
| 324 |
lead={selectedLead}
|
| 325 |
-
onTakeover={
|
| 326 |
-
isAnalyzing={selectedLead.processing_status === 'analyzing'
|
| 327 |
-
onRefresh={
|
| 328 |
conversationId={conversation?.id}
|
| 329 |
tenantId={user.tenant_id}
|
| 330 |
/>
|
| 331 |
) : (
|
| 332 |
-
<div className="flex items-center justify-center
|
| 333 |
-
|
| 334 |
-
<div className="w-14 h-14 mx-auto mb-3 rounded-full bg-gradient-to-br from-indigo-100 to-purple-100 flex items-center justify-center">
|
| 335 |
-
<Flame className="w-7 h-7 text-indigo-600" />
|
| 336 |
-
</div>
|
| 337 |
-
<p className="text-sm font-semibold text-slate-900 mb-1">Интеллект ИИ</p>
|
| 338 |
-
<p className="text-xs text-slate-500">Выберите лида для<br />просмотра анализа</p>
|
| 339 |
-
</div>
|
| 340 |
</div>
|
| 341 |
)}
|
| 342 |
</div>
|
|
|
|
| 1 |
'use client'
|
| 2 |
|
| 3 |
import { useState, useEffect, useMemo } from 'react'
|
| 4 |
+
import { useRouter } from 'next/navigation'
|
| 5 |
+
import { useAuth } from '@/contexts/AuthContext'
|
| 6 |
+
import { leadsApi, Lead, Message } from '@/lib/api'
|
| 7 |
import { useQuery } from '@tanstack/react-query'
|
| 8 |
+
import { LeadsList } from '@/components/LeadsList'
|
| 9 |
import { ChatWindow } from '@/components/ChatWindow'
|
| 10 |
import { ClientCard } from '@/components/ClientCard'
|
| 11 |
+
import { Loader2 } from 'lucide-react'
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
export default function ChatsPage() {
|
| 14 |
+
const router = useRouter()
|
| 15 |
+
const { user, isLoading: authLoading } = useAuth()
|
| 16 |
+
const [selectedLead, setSelectedLead] = useState<Lead | undefined>(undefined)
|
| 17 |
+
const [messages, setMessages] = useState<Message[]>([])
|
| 18 |
+
const [messagesLoading, setMessagesLoading] = useState(false)
|
| 19 |
const [searchQuery, setSearchQuery] = useState('')
|
| 20 |
const [activeTab, setActiveTab] = useState<'all' | 'hot' | 'unread'>('all')
|
| 21 |
+
const [conversation, setConversation] = useState<any>(null)
|
| 22 |
|
| 23 |
+
// Fetch Leads
|
| 24 |
const { data: leads, isLoading: leadsLoading, refetch: refetchLeads } = useQuery({
|
| 25 |
queryKey: ['leads', user?.tenant_id],
|
| 26 |
+
queryFn: () => leadsApi.getLeads(),
|
| 27 |
+
enabled: !!user?.tenant_id,
|
| 28 |
+
refetchInterval: 5000
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
})
|
| 30 |
|
| 31 |
+
// Fetch Conversation
|
| 32 |
+
const fetchConversation = async (leadId: string) => {
|
| 33 |
+
setMessagesLoading(true)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
try {
|
| 35 |
+
const data = await leadsApi.getConversation(leadId)
|
| 36 |
+
setMessages(data.messages || [])
|
| 37 |
+
setConversation(data)
|
| 38 |
} catch (error) {
|
| 39 |
+
console.error('Error fetching conversation:', error)
|
| 40 |
+
} finally {
|
| 41 |
+
setMessagesLoading(false)
|
| 42 |
}
|
| 43 |
}
|
| 44 |
|
| 45 |
+
// Handle Lead Selection
|
| 46 |
+
const handleSelectLead = (lead: Lead) => {
|
| 47 |
+
setSelectedLead(lead)
|
| 48 |
+
fetchConversation(lead.id)
|
| 49 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
+
// Initial Selection
|
| 52 |
+
useEffect(() => {
|
| 53 |
+
if (leads && leads.length > 0 && !selectedLead) {
|
| 54 |
+
// Optional: Auto-select first lead
|
| 55 |
+
// handleSelectLead(leads[0])
|
| 56 |
+
}
|
| 57 |
+
}, [leads])
|
| 58 |
+
|
| 59 |
+
// Refresh Handlers
|
| 60 |
+
const handleRefresh = async () => {
|
| 61 |
+
await refetchLeads()
|
| 62 |
+
if (selectedLead) {
|
| 63 |
+
await fetchConversation(selectedLead.id)
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
|
| 67 |
if (authLoading || !user) {
|
| 68 |
return (
|
| 69 |
<div className="flex items-center justify-center h-screen bg-slate-50">
|
| 70 |
+
<Loader2 className="w-8 h-8 animate-spin text-indigo-600" />
|
| 71 |
</div>
|
| 72 |
)
|
| 73 |
}
|
| 74 |
|
| 75 |
return (
|
| 76 |
+
<div className="flex h-screen overflow-hidden bg-white">
|
| 77 |
+
{/* Left Column: Leads List (25%) */}
|
| 78 |
+
<div className="w-1/4 min-w-[300px] max-w-[400px] h-full border-r border-slate-200 z-20">
|
| 79 |
+
<LeadsList
|
| 80 |
+
leads={leads}
|
| 81 |
+
isLoading={leadsLoading}
|
| 82 |
+
selectedLeadId={selectedLead?.id}
|
| 83 |
+
onSelectLead={handleSelectLead}
|
| 84 |
+
searchQuery={searchQuery}
|
| 85 |
+
setSearchQuery={setSearchQuery}
|
| 86 |
+
activeTab={activeTab}
|
| 87 |
+
setActiveTab={setActiveTab}
|
| 88 |
+
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
</div>
|
| 90 |
|
| 91 |
+
{/* Center Column: Chat Window (50%) */}
|
| 92 |
+
<div className="flex-1 h-full min-w-[400px] relative z-10">
|
|
|
|
|
|
|
|
|
|
| 93 |
{selectedLead ? (
|
| 94 |
+
<ChatWindow
|
| 95 |
+
messages={messages}
|
| 96 |
+
leadId={selectedLead.id}
|
| 97 |
+
tenantId={user.tenant_id}
|
| 98 |
+
conversationId={conversation?.id}
|
| 99 |
+
lead={selectedLead}
|
| 100 |
+
conversation={conversation}
|
| 101 |
+
isLoading={messagesLoading}
|
| 102 |
+
isAnalyzing={selectedLead.processing_status === 'analyzing'}
|
| 103 |
+
onRefresh={handleRefresh}
|
| 104 |
+
onTakeover={() => { }} // Implement takeover logic if needed
|
| 105 |
+
onBack={() => setSelectedLead(undefined)} // Mobile back
|
| 106 |
+
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
) : (
|
| 108 |
+
<div className="h-full flex flex-col items-center justify-center bg-slate-50 text-slate-400">
|
| 109 |
+
<div className="w-16 h-16 bg-white rounded-2xl flex items-center justify-center shadow-sm mb-4">
|
| 110 |
+
<Loader2 className="w-8 h-8 animate-spin text-indigo-200" />
|
| 111 |
+
{/* Or a static icon if not loading */}
|
|
|
|
|
|
|
|
|
|
| 112 |
</div>
|
| 113 |
+
<p className="font-medium">Выберите диалог из списка</p>
|
| 114 |
</div>
|
| 115 |
)}
|
| 116 |
</div>
|
| 117 |
|
| 118 |
+
{/* Right Column: Client Intelligence (25%) */}
|
| 119 |
+
<div className="w-1/4 min-w-[300px] max-w-[400px] h-full border-l border-slate-200 bg-white hidden lg:block z-20">
|
| 120 |
{selectedLead ? (
|
| 121 |
<ClientCard
|
| 122 |
lead={selectedLead}
|
| 123 |
+
onTakeover={() => { }}
|
| 124 |
+
isAnalyzing={selectedLead.processing_status === 'analyzing'}
|
| 125 |
+
onRefresh={handleRefresh}
|
| 126 |
conversationId={conversation?.id}
|
| 127 |
tenantId={user.tenant_id}
|
| 128 |
/>
|
| 129 |
) : (
|
| 130 |
+
<div className="h-full flex items-center justify-center bg-slate-50/50 text-slate-400 text-sm">
|
| 131 |
+
Нет выбранного лида
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
</div>
|
| 133 |
)}
|
| 134 |
</div>
|
frontend/components/ChatWindow.tsx
CHANGED
|
@@ -135,7 +135,7 @@ export function ChatWindow({ messages, leadId, tenantId, conversationId, lead, c
|
|
| 135 |
setIsSending(true)
|
| 136 |
|
| 137 |
try {
|
| 138 |
-
// @ts-ignore
|
| 139 |
await leadsApi.sendMessage(leadId, inputMessage)
|
| 140 |
setOptimisticMessages(prev => prev.filter(m => m.id !== tempId))
|
| 141 |
} catch (error) {
|
|
@@ -178,14 +178,14 @@ export function ChatWindow({ messages, leadId, tenantId, conversationId, lead, c
|
|
| 178 |
return (
|
| 179 |
<div className="flex flex-col h-full bg-slate-50 font-['Inter'] relative">
|
| 180 |
{/* Header */}
|
| 181 |
-
<div className="bg-white border-b border-slate-200
|
| 182 |
-
<div className="flex items-center gap-
|
| 183 |
<button onClick={onBack} className="md:hidden p-2 -ml-2 text-slate-500 hover:text-slate-900">
|
| 184 |
<ArrowLeft className="w-5 h-5" />
|
| 185 |
</button>
|
| 186 |
|
| 187 |
<div className="flex items-center gap-3">
|
| 188 |
-
<div className="w-10 h-10 rounded-full bg-gradient-to-br from-indigo-100 to-purple-100 flex items-center justify-center text-indigo-600 font-bold text-sm border border-indigo-50 relative">
|
| 189 |
{lead?.name?.charAt(0) || 'L'}
|
| 190 |
<div className={cn(
|
| 191 |
"absolute bottom-0 right-0 w-3 h-3 rounded-full border-2 border-white",
|
|
@@ -197,9 +197,9 @@ export function ChatWindow({ messages, leadId, tenantId, conversationId, lead, c
|
|
| 197 |
<div>
|
| 198 |
<h2 className="font-bold text-slate-900 text-sm">{lead?.name || 'Лид'}</h2>
|
| 199 |
<div className="flex items-center gap-2">
|
| 200 |
-
<span className="text-xs text-slate-500">{(lead as any)?.channel_source || 'Unknown'}</span>
|
| 201 |
{isAnalyzing && (
|
| 202 |
-
<span className="flex items-center gap-1 text-[10px] text-indigo-600 bg-indigo-50 px-
|
| 203 |
<Sparkles className="w-3 h-3" />
|
| 204 |
AI думает...
|
| 205 |
</span>
|
|
@@ -209,15 +209,15 @@ export function ChatWindow({ messages, leadId, tenantId, conversationId, lead, c
|
|
| 209 |
</div>
|
| 210 |
</div>
|
| 211 |
|
| 212 |
-
<div className="flex items-center gap-
|
| 213 |
<button
|
| 214 |
onClick={handleToggleAI}
|
| 215 |
disabled={isTogglingAI}
|
| 216 |
className={cn(
|
| 217 |
-
"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs font-
|
| 218 |
isAIActive
|
| 219 |
? "bg-indigo-50 text-indigo-700 border-indigo-200 hover:bg-indigo-100"
|
| 220 |
-
: "bg-
|
| 221 |
)}
|
| 222 |
>
|
| 223 |
{isTogglingAI ? (
|
|
@@ -238,9 +238,9 @@ export function ChatWindow({ messages, leadId, tenantId, conversationId, lead, c
|
|
| 238 |
</div>
|
| 239 |
|
| 240 |
{/* Stage Stepper */}
|
| 241 |
-
<div className="bg-white border-b border-slate-100 px-
|
| 242 |
{loadingStages ? (
|
| 243 |
-
<div className="h-8 w-full bg-slate-
|
| 244 |
) : (
|
| 245 |
<StageStepper
|
| 246 |
stages={stages}
|
|
@@ -252,7 +252,7 @@ export function ChatWindow({ messages, leadId, tenantId, conversationId, lead, c
|
|
| 252 |
</div>
|
| 253 |
|
| 254 |
{/* Messages Area */}
|
| 255 |
-
<div className="flex-1 overflow-y-auto p-
|
| 256 |
{isLoading ? (
|
| 257 |
<div className="flex items-center justify-center h-full">
|
| 258 |
<Loader2 className="w-8 h-8 animate-spin text-indigo-600" />
|
|
@@ -268,16 +268,33 @@ export function ChatWindow({ messages, leadId, tenantId, conversationId, lead, c
|
|
| 268 |
) : (
|
| 269 |
<>
|
| 270 |
{allMessages.map((msg, index) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
const isAI = msg.sender_type === 'ai'
|
|
|
|
| 272 |
const prevMsg = index > 0 ? allMessages[index - 1] : null
|
| 273 |
const showDate = shouldShowDateSeparator(msg, prevMsg)
|
| 274 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 275 |
|
| 276 |
return (
|
| 277 |
<div key={msg.id}>
|
| 278 |
{showDate && (
|
| 279 |
<div className="flex items-center justify-center my-6">
|
| 280 |
-
<span className="text-[10px] font-
|
| 281 |
{getDateLabel(msg.created_at)}
|
| 282 |
</span>
|
| 283 |
</div>
|
|
@@ -289,39 +306,39 @@ export function ChatWindow({ messages, leadId, tenantId, conversationId, lead, c
|
|
| 289 |
transition={{ duration: 0.3 }}
|
| 290 |
className={cn(
|
| 291 |
"flex w-full max-w-3xl mx-auto group",
|
| 292 |
-
|
| 293 |
isSequence ? "mt-1" : "mt-4"
|
| 294 |
)}
|
| 295 |
>
|
| 296 |
<div className={cn(
|
| 297 |
-
"flex gap-3 max-w-[
|
| 298 |
-
|
| 299 |
)}>
|
| 300 |
-
{/* Avatar - only show for first message in sequence
|
| 301 |
<div className={cn(
|
| 302 |
"w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 shadow-sm mt-auto mb-1 transition-opacity",
|
| 303 |
-
|
| 304 |
-
isSequence ? "opacity-0" : "opacity-100"
|
| 305 |
)}>
|
| 306 |
-
{isAI ? <Bot className="w-4 h-4" /> : <User className="w-4 h-4" />}
|
| 307 |
</div>
|
| 308 |
|
| 309 |
{/* Message Bubble */}
|
| 310 |
<div className="flex flex-col gap-1 min-w-0">
|
| 311 |
<div className={cn(
|
| 312 |
-
"px-4 py-
|
| 313 |
-
|
| 314 |
-
? "bg-
|
| 315 |
-
: "bg-
|
| 316 |
-
isSequence &&
|
| 317 |
-
isSequence && !
|
| 318 |
)}>
|
| 319 |
{msg.content}
|
| 320 |
</div>
|
| 321 |
{!isSequence && (
|
| 322 |
<span className={cn(
|
| 323 |
"text-[10px] text-slate-400 px-1",
|
| 324 |
-
|
| 325 |
)}>
|
| 326 |
{formatDate(msg.created_at)}
|
| 327 |
</span>
|
|
@@ -340,16 +357,16 @@ export function ChatWindow({ messages, leadId, tenantId, conversationId, lead, c
|
|
| 340 |
initial={{ opacity: 0, y: 10 }}
|
| 341 |
animate={{ opacity: 1, y: 0 }}
|
| 342 |
exit={{ opacity: 0, scale: 0.9 }}
|
| 343 |
-
className="flex w-full max-w-3xl mx-auto justify-
|
| 344 |
>
|
| 345 |
-
<div className="flex gap-3">
|
| 346 |
<div className="w-8 h-8 rounded-full bg-indigo-600 text-white flex items-center justify-center flex-shrink-0 shadow-sm mt-auto mb-1">
|
| 347 |
<Bot className="w-4 h-4" />
|
| 348 |
</div>
|
| 349 |
-
<div className="bg-
|
| 350 |
-
<span className="w-1.5 h-1.5 bg-
|
| 351 |
-
<span className="w-1.5 h-1.5 bg-
|
| 352 |
-
<span className="w-1.5 h-1.5 bg-
|
| 353 |
</div>
|
| 354 |
</div>
|
| 355 |
</motion.div>
|
|
@@ -360,16 +377,16 @@ export function ChatWindow({ messages, leadId, tenantId, conversationId, lead, c
|
|
| 360 |
<div ref={messagesEndRef} />
|
| 361 |
</div>
|
| 362 |
|
| 363 |
-
{/* Input Area */}
|
| 364 |
-
<div className="p-
|
| 365 |
-
<div className="max-w-
|
| 366 |
<form
|
| 367 |
onSubmit={handleSendMessage}
|
| 368 |
-
className="flex items-end gap-2 bg-
|
| 369 |
>
|
| 370 |
<button
|
| 371 |
type="button"
|
| 372 |
-
className="p-2 text-slate-400 hover:text-indigo-600 hover:bg-
|
| 373 |
>
|
| 374 |
<Paperclip className="w-5 h-5" />
|
| 375 |
</button>
|
|
@@ -384,14 +401,14 @@ export function ChatWindow({ messages, leadId, tenantId, conversationId, lead, c
|
|
| 384 |
}
|
| 385 |
}}
|
| 386 |
placeholder="Напишите сообщение..."
|
| 387 |
-
className="flex-1 bg-transparent border-none focus:ring-0 resize-none max-h-32 py-2 text-sm text-slate-900 placeholder:text-slate-400"
|
| 388 |
rows={1}
|
| 389 |
-
style={{ minHeight: '
|
| 390 |
/>
|
| 391 |
|
| 392 |
<button
|
| 393 |
type="button"
|
| 394 |
-
className="p-2 text-slate-400 hover:text-indigo-600 hover:bg-
|
| 395 |
>
|
| 396 |
<Smile className="w-5 h-5" />
|
| 397 |
</button>
|
|
@@ -400,10 +417,10 @@ export function ChatWindow({ messages, leadId, tenantId, conversationId, lead, c
|
|
| 400 |
type="submit"
|
| 401 |
disabled={!inputMessage.trim() || isSending}
|
| 402 |
className={cn(
|
| 403 |
-
"p-2 rounded-xl transition-all duration-200 shadow-sm",
|
| 404 |
inputMessage.trim() && !isSending
|
| 405 |
? "bg-indigo-600 text-white hover:bg-indigo-700 hover:scale-105 active:scale-95"
|
| 406 |
-
: "bg-slate-
|
| 407 |
)}
|
| 408 |
>
|
| 409 |
{isSending ? (
|
|
@@ -414,8 +431,8 @@ export function ChatWindow({ messages, leadId, tenantId, conversationId, lead, c
|
|
| 414 |
</button>
|
| 415 |
</form>
|
| 416 |
<div className="text-center mt-2">
|
| 417 |
-
<p className="text-[10px] text-slate-400">
|
| 418 |
-
Enter для отправки
|
| 419 |
</p>
|
| 420 |
</div>
|
| 421 |
</div>
|
|
|
|
| 135 |
setIsSending(true)
|
| 136 |
|
| 137 |
try {
|
| 138 |
+
// @ts-ignore
|
| 139 |
await leadsApi.sendMessage(leadId, inputMessage)
|
| 140 |
setOptimisticMessages(prev => prev.filter(m => m.id !== tempId))
|
| 141 |
} catch (error) {
|
|
|
|
| 178 |
return (
|
| 179 |
<div className="flex flex-col h-full bg-slate-50 font-['Inter'] relative">
|
| 180 |
{/* Header */}
|
| 181 |
+
<div className="bg-white border-b border-slate-200 px-6 py-3 flex items-center justify-between shadow-sm z-10 flex-shrink-0">
|
| 182 |
+
<div className="flex items-center gap-4">
|
| 183 |
<button onClick={onBack} className="md:hidden p-2 -ml-2 text-slate-500 hover:text-slate-900">
|
| 184 |
<ArrowLeft className="w-5 h-5" />
|
| 185 |
</button>
|
| 186 |
|
| 187 |
<div className="flex items-center gap-3">
|
| 188 |
+
<div className="w-10 h-10 rounded-full bg-gradient-to-br from-indigo-100 to-purple-100 flex items-center justify-center text-indigo-600 font-bold text-sm border border-indigo-50 relative shadow-sm">
|
| 189 |
{lead?.name?.charAt(0) || 'L'}
|
| 190 |
<div className={cn(
|
| 191 |
"absolute bottom-0 right-0 w-3 h-3 rounded-full border-2 border-white",
|
|
|
|
| 197 |
<div>
|
| 198 |
<h2 className="font-bold text-slate-900 text-sm">{lead?.name || 'Лид'}</h2>
|
| 199 |
<div className="flex items-center gap-2">
|
| 200 |
+
<span className="text-xs text-slate-500 font-medium">{(lead as any)?.channel_source || 'Unknown'}</span>
|
| 201 |
{isAnalyzing && (
|
| 202 |
+
<span className="flex items-center gap-1 text-[10px] text-indigo-600 bg-indigo-50 px-2 py-0.5 rounded-full animate-pulse border border-indigo-100 font-semibold">
|
| 203 |
<Sparkles className="w-3 h-3" />
|
| 204 |
AI думает...
|
| 205 |
</span>
|
|
|
|
| 209 |
</div>
|
| 210 |
</div>
|
| 211 |
|
| 212 |
+
<div className="flex items-center gap-3">
|
| 213 |
<button
|
| 214 |
onClick={handleToggleAI}
|
| 215 |
disabled={isTogglingAI}
|
| 216 |
className={cn(
|
| 217 |
+
"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs font-semibold transition-all duration-200 border shadow-sm",
|
| 218 |
isAIActive
|
| 219 |
? "bg-indigo-50 text-indigo-700 border-indigo-200 hover:bg-indigo-100"
|
| 220 |
+
: "bg-white text-slate-600 border-slate-200 hover:bg-slate-50"
|
| 221 |
)}
|
| 222 |
>
|
| 223 |
{isTogglingAI ? (
|
|
|
|
| 238 |
</div>
|
| 239 |
|
| 240 |
{/* Stage Stepper */}
|
| 241 |
+
<div className="bg-white border-b border-slate-100 px-6 py-2 overflow-x-auto scrollbar-hide flex-shrink-0">
|
| 242 |
{loadingStages ? (
|
| 243 |
+
<div className="h-8 w-full bg-slate-50 animate-pulse rounded-lg" />
|
| 244 |
) : (
|
| 245 |
<StageStepper
|
| 246 |
stages={stages}
|
|
|
|
| 252 |
</div>
|
| 253 |
|
| 254 |
{/* Messages Area */}
|
| 255 |
+
<div className="flex-1 overflow-y-auto p-6 space-y-6 bg-slate-50 scrollbar-thin scrollbar-thumb-slate-200">
|
| 256 |
{isLoading ? (
|
| 257 |
<div className="flex items-center justify-center h-full">
|
| 258 |
<Loader2 className="w-8 h-8 animate-spin text-indigo-600" />
|
|
|
|
| 268 |
) : (
|
| 269 |
<>
|
| 270 |
{allMessages.map((msg, index) => {
|
| 271 |
+
// Logic:
|
| 272 |
+
// 'human' -> Agent (Me) -> Right
|
| 273 |
+
// 'ai' -> Agent (Bot) -> Right
|
| 274 |
+
// 'lead' / 'user' (anything else) -> Lead -> Left
|
| 275 |
+
|
| 276 |
+
// NOTE: We need to be sure about 'sender_type'.
|
| 277 |
+
// Usually in this app: 'human' = Operator, 'ai' = Bot.
|
| 278 |
+
// The 'lead' messages usually have sender_type = 'lead' or 'user'.
|
| 279 |
+
// Let's assume anything NOT 'human' and NOT 'ai' is the Lead.
|
| 280 |
+
|
| 281 |
+
const isMe = msg.sender_type === 'human' || msg.sender_type === 'ai'
|
| 282 |
const isAI = msg.sender_type === 'ai'
|
| 283 |
+
|
| 284 |
const prevMsg = index > 0 ? allMessages[index - 1] : null
|
| 285 |
const showDate = shouldShowDateSeparator(msg, prevMsg)
|
| 286 |
+
|
| 287 |
+
// Group if same side and no date separator
|
| 288 |
+
const isSequence = prevMsg &&
|
| 289 |
+
((isMe && (prevMsg.sender_type === 'human' || prevMsg.sender_type === 'ai')) ||
|
| 290 |
+
(!isMe && (prevMsg.sender_type !== 'human' && prevMsg.sender_type !== 'ai'))) &&
|
| 291 |
+
!showDate
|
| 292 |
|
| 293 |
return (
|
| 294 |
<div key={msg.id}>
|
| 295 |
{showDate && (
|
| 296 |
<div className="flex items-center justify-center my-6">
|
| 297 |
+
<span className="text-[10px] font-bold text-slate-400 bg-slate-100/80 px-3 py-1 rounded-full uppercase tracking-wide">
|
| 298 |
{getDateLabel(msg.created_at)}
|
| 299 |
</span>
|
| 300 |
</div>
|
|
|
|
| 306 |
transition={{ duration: 0.3 }}
|
| 307 |
className={cn(
|
| 308 |
"flex w-full max-w-3xl mx-auto group",
|
| 309 |
+
isMe ? "justify-end" : "justify-start",
|
| 310 |
isSequence ? "mt-1" : "mt-4"
|
| 311 |
)}
|
| 312 |
>
|
| 313 |
<div className={cn(
|
| 314 |
+
"flex gap-3 max-w-[75%]",
|
| 315 |
+
isMe ? "flex-row-reverse" : "flex-row"
|
| 316 |
)}>
|
| 317 |
+
{/* Avatar - only show for first message in sequence */}
|
| 318 |
<div className={cn(
|
| 319 |
"w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 shadow-sm mt-auto mb-1 transition-opacity",
|
| 320 |
+
isMe ? "bg-indigo-600 text-white" : "bg-white text-slate-600 border border-slate-200",
|
| 321 |
+
isSequence ? "opacity-0 w-0 overflow-hidden ml-0 mr-0" : "opacity-100" // Hide avatar in sequence
|
| 322 |
)}>
|
| 323 |
+
{isMe ? (isAI ? <Bot className="w-4 h-4" /> : <User className="w-4 h-4" />) : <User className="w-4 h-4" />}
|
| 324 |
</div>
|
| 325 |
|
| 326 |
{/* Message Bubble */}
|
| 327 |
<div className="flex flex-col gap-1 min-w-0">
|
| 328 |
<div className={cn(
|
| 329 |
+
"px-4 py-2.5 text-sm leading-relaxed shadow-sm relative break-words",
|
| 330 |
+
isMe
|
| 331 |
+
? "bg-indigo-600 text-white rounded-2xl rounded-br-none"
|
| 332 |
+
: "bg-white text-slate-800 border border-slate-100 rounded-2xl rounded-bl-none",
|
| 333 |
+
isSequence && isMe && "rounded-tr-md rounded-br-md",
|
| 334 |
+
isSequence && !isMe && "rounded-tl-md rounded-bl-md"
|
| 335 |
)}>
|
| 336 |
{msg.content}
|
| 337 |
</div>
|
| 338 |
{!isSequence && (
|
| 339 |
<span className={cn(
|
| 340 |
"text-[10px] text-slate-400 px-1",
|
| 341 |
+
isMe ? "text-right" : "text-left"
|
| 342 |
)}>
|
| 343 |
{formatDate(msg.created_at)}
|
| 344 |
</span>
|
|
|
|
| 357 |
initial={{ opacity: 0, y: 10 }}
|
| 358 |
animate={{ opacity: 1, y: 0 }}
|
| 359 |
exit={{ opacity: 0, scale: 0.9 }}
|
| 360 |
+
className="flex w-full max-w-3xl mx-auto justify-end mt-4"
|
| 361 |
>
|
| 362 |
+
<div className="flex gap-3 flex-row-reverse">
|
| 363 |
<div className="w-8 h-8 rounded-full bg-indigo-600 text-white flex items-center justify-center flex-shrink-0 shadow-sm mt-auto mb-1">
|
| 364 |
<Bot className="w-4 h-4" />
|
| 365 |
</div>
|
| 366 |
+
<div className="bg-indigo-600 text-white px-4 py-3 rounded-2xl rounded-br-none shadow-sm flex items-center gap-1">
|
| 367 |
+
<span className="w-1.5 h-1.5 bg-white/70 rounded-full animate-bounce [animation-delay:-0.3s]"></span>
|
| 368 |
+
<span className="w-1.5 h-1.5 bg-white/70 rounded-full animate-bounce [animation-delay:-0.15s]"></span>
|
| 369 |
+
<span className="w-1.5 h-1.5 bg-white/70 rounded-full animate-bounce"></span>
|
| 370 |
</div>
|
| 371 |
</div>
|
| 372 |
</motion.div>
|
|
|
|
| 377 |
<div ref={messagesEndRef} />
|
| 378 |
</div>
|
| 379 |
|
| 380 |
+
{/* Input Area - Floating */}
|
| 381 |
+
<div className="p-6 bg-slate-50 flex-shrink-0">
|
| 382 |
+
<div className="max-w-4xl mx-auto relative">
|
| 383 |
<form
|
| 384 |
onSubmit={handleSendMessage}
|
| 385 |
+
className="flex items-end gap-2 bg-white p-2 rounded-2xl shadow-[0_4px_20px_-4px_rgba(0,0,0,0.1)] border border-slate-100 focus-within:ring-2 focus-within:ring-indigo-500/20 transition-all"
|
| 386 |
>
|
| 387 |
<button
|
| 388 |
type="button"
|
| 389 |
+
className="p-2.5 text-slate-400 hover:text-indigo-600 hover:bg-slate-50 rounded-xl transition-colors"
|
| 390 |
>
|
| 391 |
<Paperclip className="w-5 h-5" />
|
| 392 |
</button>
|
|
|
|
| 401 |
}
|
| 402 |
}}
|
| 403 |
placeholder="Напишите сообщение..."
|
| 404 |
+
className="flex-1 bg-transparent border-none focus:ring-0 resize-none max-h-32 py-2.5 text-sm text-slate-900 placeholder:text-slate-400"
|
| 405 |
rows={1}
|
| 406 |
+
style={{ minHeight: '44px' }}
|
| 407 |
/>
|
| 408 |
|
| 409 |
<button
|
| 410 |
type="button"
|
| 411 |
+
className="p-2.5 text-slate-400 hover:text-indigo-600 hover:bg-slate-50 rounded-xl transition-colors"
|
| 412 |
>
|
| 413 |
<Smile className="w-5 h-5" />
|
| 414 |
</button>
|
|
|
|
| 417 |
type="submit"
|
| 418 |
disabled={!inputMessage.trim() || isSending}
|
| 419 |
className={cn(
|
| 420 |
+
"p-2.5 rounded-xl transition-all duration-200 shadow-sm",
|
| 421 |
inputMessage.trim() && !isSending
|
| 422 |
? "bg-indigo-600 text-white hover:bg-indigo-700 hover:scale-105 active:scale-95"
|
| 423 |
+
: "bg-slate-100 text-slate-300 cursor-not-allowed"
|
| 424 |
)}
|
| 425 |
>
|
| 426 |
{isSending ? (
|
|
|
|
| 431 |
</button>
|
| 432 |
</form>
|
| 433 |
<div className="text-center mt-2">
|
| 434 |
+
<p className="text-[10px] text-slate-400 font-medium">
|
| 435 |
+
Enter для отправки • Shift + Enter для переноса
|
| 436 |
</p>
|
| 437 |
</div>
|
| 438 |
</div>
|
frontend/components/ClientCard.tsx
CHANGED
|
@@ -7,7 +7,8 @@ import {
|
|
| 7 |
Brain, TrendingUp, DollarSign, Target, Clock, AlertCircle,
|
| 8 |
Lightbulb, User as UserIcon, CheckCircle2, Phone, Check,
|
| 9 |
Loader2, RefreshCw, Bot, Zap, Database, Shield, MessageSquare,
|
| 10 |
-
AlertTriangle, ThumbsUp, PenTool, Copy, ChevronDown, ChevronUp
|
|
|
|
| 11 |
} from 'lucide-react'
|
| 12 |
import { useToast } from '@/contexts/ToastContext'
|
| 13 |
import { motion, AnimatePresence } from 'framer-motion'
|
|
@@ -87,13 +88,13 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 87 |
<Brain className="w-5 h-5" />
|
| 88 |
</div>
|
| 89 |
<div>
|
| 90 |
-
<h2 className="font-bold text-slate-900 text-sm">AI
|
| 91 |
-
<p className="text-xs text-slate-500">
|
| 92 |
</div>
|
| 93 |
</div>
|
| 94 |
|
| 95 |
{/* Score Ring */}
|
| 96 |
-
<div className="relative w-
|
| 97 |
<svg className="w-full h-full transform -rotate-90">
|
| 98 |
<defs>
|
| 99 |
<linearGradient id="scoreGradient" x1="0%" y1="0%" x2="100%" y2="0%">
|
|
@@ -101,24 +102,24 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 101 |
<stop offset="100%" stopColor={data.heat_score >= 80 ? '#f87171' : data.heat_score >= 50 ? '#fbbf24' : '#60a5fa'} />
|
| 102 |
</linearGradient>
|
| 103 |
</defs>
|
| 104 |
-
<circle cx="
|
| 105 |
<circle
|
| 106 |
-
cx="
|
| 107 |
stroke="url(#scoreGradient)"
|
| 108 |
-
strokeWidth="
|
| 109 |
fill="none"
|
| 110 |
-
strokeDasharray={
|
| 111 |
-
strokeDashoffset={
|
| 112 |
className="transition-all duration-1000 ease-out"
|
| 113 |
strokeLinecap="round"
|
| 114 |
/>
|
| 115 |
</svg>
|
| 116 |
-
<span className={cn("absolute text-
|
| 117 |
{data.heat_score}
|
| 118 |
</span>
|
| 119 |
|
| 120 |
{/* Tooltip */}
|
| 121 |
-
<div className="absolute top-full right-0 mt-2 w-48 bg-slate-800 text-white text-[10px] p-2 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-20">
|
| 122 |
Оценка готовности к покупке на основе анализа диалога
|
| 123 |
</div>
|
| 124 |
</div>
|
|
@@ -127,6 +128,22 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 127 |
{/* Content */}
|
| 128 |
<div className="flex-1 overflow-y-auto p-5 space-y-6 scrollbar-thin scrollbar-thumb-slate-200">
|
| 129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
{/* Key Metrics Grid */}
|
| 131 |
<div className="grid grid-cols-2 gap-3">
|
| 132 |
<div className="p-3 bg-slate-50 rounded-xl border border-slate-100 hover:border-indigo-100 transition-colors">
|
|
|
|
| 7 |
Brain, TrendingUp, DollarSign, Target, Clock, AlertCircle,
|
| 8 |
Lightbulb, User as UserIcon, CheckCircle2, Phone, Check,
|
| 9 |
Loader2, RefreshCw, Bot, Zap, Database, Shield, MessageSquare,
|
| 10 |
+
AlertTriangle, ThumbsUp, PenTool, Copy, ChevronDown, ChevronUp,
|
| 11 |
+
Mail, Archive, PhoneCall
|
| 12 |
} from 'lucide-react'
|
| 13 |
import { useToast } from '@/contexts/ToastContext'
|
| 14 |
import { motion, AnimatePresence } from 'framer-motion'
|
|
|
|
| 88 |
<Brain className="w-5 h-5" />
|
| 89 |
</div>
|
| 90 |
<div>
|
| 91 |
+
<h2 className="font-bold text-slate-900 text-sm">AI Summary</h2>
|
| 92 |
+
<p className="text-xs text-slate-500">Анализ диалога</p>
|
| 93 |
</div>
|
| 94 |
</div>
|
| 95 |
|
| 96 |
{/* Score Ring */}
|
| 97 |
+
<div className="relative w-14 h-14 flex items-center justify-center group cursor-help">
|
| 98 |
<svg className="w-full h-full transform -rotate-90">
|
| 99 |
<defs>
|
| 100 |
<linearGradient id="scoreGradient" x1="0%" y1="0%" x2="100%" y2="0%">
|
|
|
|
| 102 |
<stop offset="100%" stopColor={data.heat_score >= 80 ? '#f87171' : data.heat_score >= 50 ? '#fbbf24' : '#60a5fa'} />
|
| 103 |
</linearGradient>
|
| 104 |
</defs>
|
| 105 |
+
<circle cx="28" cy="28" r="24" stroke="#f1f5f9" strokeWidth="5" fill="none" />
|
| 106 |
<circle
|
| 107 |
+
cx="28" cy="28" r="24"
|
| 108 |
stroke="url(#scoreGradient)"
|
| 109 |
+
strokeWidth="5"
|
| 110 |
fill="none"
|
| 111 |
+
strokeDasharray={151}
|
| 112 |
+
strokeDashoffset={151 - (data.heat_score / 100) * 151}
|
| 113 |
className="transition-all duration-1000 ease-out"
|
| 114 |
strokeLinecap="round"
|
| 115 |
/>
|
| 116 |
</svg>
|
| 117 |
+
<span className={cn("absolute text-sm font-bold", getScoreColor(data.heat_score))}>
|
| 118 |
{data.heat_score}
|
| 119 |
</span>
|
| 120 |
|
| 121 |
{/* Tooltip */}
|
| 122 |
+
<div className="absolute top-full right-0 mt-2 w-48 bg-slate-800 text-white text-[10px] p-2 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-20 shadow-xl">
|
| 123 |
Оценка готовности к покупке на основе анализа диалога
|
| 124 |
</div>
|
| 125 |
</div>
|
|
|
|
| 128 |
{/* Content */}
|
| 129 |
<div className="flex-1 overflow-y-auto p-5 space-y-6 scrollbar-thin scrollbar-thumb-slate-200">
|
| 130 |
|
| 131 |
+
{/* Action Buttons */}
|
| 132 |
+
<div className="grid grid-cols-3 gap-2">
|
| 133 |
+
<button className="flex flex-col items-center justify-center gap-1 p-2 rounded-xl bg-slate-50 hover:bg-slate-100 border border-slate-100 transition-colors group">
|
| 134 |
+
<PhoneCall className="w-4 h-4 text-slate-500 group-hover:text-indigo-600" />
|
| 135 |
+
<span className="text-[10px] font-medium text-slate-600">Call</span>
|
| 136 |
+
</button>
|
| 137 |
+
<button className="flex flex-col items-center justify-center gap-1 p-2 rounded-xl bg-slate-50 hover:bg-slate-100 border border-slate-100 transition-colors group">
|
| 138 |
+
<Mail className="w-4 h-4 text-slate-500 group-hover:text-indigo-600" />
|
| 139 |
+
<span className="text-[10px] font-medium text-slate-600">Email</span>
|
| 140 |
+
</button>
|
| 141 |
+
<button className="flex flex-col items-center justify-center gap-1 p-2 rounded-xl bg-slate-50 hover:bg-slate-100 border border-slate-100 transition-colors group">
|
| 142 |
+
<Archive className="w-4 h-4 text-slate-500 group-hover:text-indigo-600" />
|
| 143 |
+
<span className="text-[10px] font-medium text-slate-600">Archive</span>
|
| 144 |
+
</button>
|
| 145 |
+
</div>
|
| 146 |
+
|
| 147 |
{/* Key Metrics Grid */}
|
| 148 |
<div className="grid grid-cols-2 gap-3">
|
| 149 |
<div className="p-3 bg-slate-50 rounded-xl border border-slate-100 hover:border-indigo-100 transition-colors">
|
frontend/components/LeadsList.tsx
CHANGED
|
@@ -1,66 +1,194 @@
|
|
| 1 |
'use client'
|
| 2 |
|
| 3 |
import { Lead } from '@/lib/api'
|
| 4 |
-
import { cn
|
| 5 |
-
import {
|
| 6 |
|
| 7 |
interface LeadsListProps {
|
| 8 |
-
leads: Lead[]
|
| 9 |
-
|
|
|
|
| 10 |
onSelectLead: (lead: Lead) => void
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
}
|
| 12 |
|
| 13 |
-
export function LeadsList({
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
return (
|
| 15 |
-
<div className="
|
| 16 |
-
{
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
className=
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
>
|
| 27 |
-
<
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
</div>
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
</div>
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
<
|
|
|
|
|
|
|
| 61 |
</div>
|
| 62 |
-
|
| 63 |
-
|
| 64 |
</div>
|
| 65 |
)
|
| 66 |
}
|
|
|
|
| 1 |
'use client'
|
| 2 |
|
| 3 |
import { Lead } from '@/lib/api'
|
| 4 |
+
import { cn } from '@/lib/utils'
|
| 5 |
+
import { Search, Flame, Inbox, CheckCircle2 } from 'lucide-react'
|
| 6 |
|
| 7 |
interface LeadsListProps {
|
| 8 |
+
leads: Lead[] | undefined
|
| 9 |
+
isLoading: boolean
|
| 10 |
+
selectedLeadId: string | undefined
|
| 11 |
onSelectLead: (lead: Lead) => void
|
| 12 |
+
searchQuery: string
|
| 13 |
+
setSearchQuery: (query: string) => void
|
| 14 |
+
activeTab: 'all' | 'hot' | 'unread'
|
| 15 |
+
setActiveTab: (tab: 'all' | 'hot' | 'unread') => void
|
| 16 |
}
|
| 17 |
|
| 18 |
+
export function LeadsList({
|
| 19 |
+
leads,
|
| 20 |
+
isLoading,
|
| 21 |
+
selectedLeadId,
|
| 22 |
+
onSelectLead,
|
| 23 |
+
searchQuery,
|
| 24 |
+
setSearchQuery,
|
| 25 |
+
activeTab,
|
| 26 |
+
setActiveTab
|
| 27 |
+
}: LeadsListProps) {
|
| 28 |
+
|
| 29 |
+
// Filter Logic
|
| 30 |
+
const filteredLeads = leads?.filter(lead => {
|
| 31 |
+
const matchesSearch = (lead.name || '').toLowerCase().includes(searchQuery.toLowerCase())
|
| 32 |
+
const matchesTab =
|
| 33 |
+
activeTab === 'all' ? true :
|
| 34 |
+
activeTab === 'hot' ? lead.heat_level === 'HOT' :
|
| 35 |
+
activeTab === 'unread' ? (lead.status || '').toLowerCase() === 'new' : true
|
| 36 |
+
|
| 37 |
+
return matchesSearch && matchesTab
|
| 38 |
+
}) || []
|
| 39 |
+
|
| 40 |
return (
|
| 41 |
+
<div className="flex flex-col h-full bg-white border-r border-slate-200">
|
| 42 |
+
{/* Header & Search */}
|
| 43 |
+
<div className="p-4 border-b border-slate-100 space-y-3 flex-shrink-0">
|
| 44 |
+
<div className="flex items-center justify-between">
|
| 45 |
+
<h2 className="text-lg font-bold text-slate-900 tracking-tight">Входящие</h2>
|
| 46 |
+
<span className="text-xs font-semibold text-slate-500 bg-slate-100 px-2 py-0.5 rounded-full">
|
| 47 |
+
{leads?.length || 0}
|
| 48 |
+
</span>
|
| 49 |
+
</div>
|
| 50 |
+
|
| 51 |
+
{/* Search Bar */}
|
| 52 |
+
<div className="relative group">
|
| 53 |
+
<Search className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400 group-focus-within:text-indigo-500 transition-colors" />
|
| 54 |
+
<input
|
| 55 |
+
type="text"
|
| 56 |
+
placeholder="Поиск..."
|
| 57 |
+
value={searchQuery}
|
| 58 |
+
onChange={(e) => setSearchQuery(e.target.value)}
|
| 59 |
+
className="w-full pl-9 pr-4 py-2 bg-slate-50 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-500 transition-all placeholder:text-slate-400"
|
| 60 |
+
/>
|
| 61 |
+
</div>
|
| 62 |
+
|
| 63 |
+
{/* Tabs */}
|
| 64 |
+
<div className="flex p-1 bg-slate-100 rounded-lg">
|
| 65 |
+
<button
|
| 66 |
+
onClick={() => setActiveTab('all')}
|
| 67 |
+
className={cn(
|
| 68 |
+
"flex-1 py-1.5 text-xs font-semibold rounded-md transition-all",
|
| 69 |
+
activeTab === 'all' ? "bg-white text-slate-900 shadow-sm" : "text-slate-500 hover:text-slate-700"
|
| 70 |
+
)}
|
| 71 |
+
>
|
| 72 |
+
Все
|
| 73 |
+
</button>
|
| 74 |
+
<button
|
| 75 |
+
onClick={() => setActiveTab('hot')}
|
| 76 |
+
className={cn(
|
| 77 |
+
"flex-1 py-1.5 text-xs font-semibold rounded-md transition-all flex items-center justify-center gap-1",
|
| 78 |
+
activeTab === 'hot' ? "bg-white text-red-600 shadow-sm" : "text-slate-500 hover:text-slate-700"
|
| 79 |
+
)}
|
| 80 |
+
>
|
| 81 |
+
<Flame className="w-3 h-3" />
|
| 82 |
+
Горячие
|
| 83 |
+
</button>
|
| 84 |
+
<button
|
| 85 |
+
onClick={() => setActiveTab('unread')}
|
| 86 |
+
className={cn(
|
| 87 |
+
"flex-1 py-1.5 text-xs font-semibold rounded-md transition-all",
|
| 88 |
+
activeTab === 'unread' ? "bg-white text-indigo-600 shadow-sm" : "text-slate-500 hover:text-slate-700"
|
| 89 |
+
)}
|
| 90 |
+
>
|
| 91 |
+
Новые
|
| 92 |
+
</button>
|
| 93 |
+
</div>
|
| 94 |
+
</div>
|
| 95 |
+
|
| 96 |
+
{/* List Content */}
|
| 97 |
+
<div className="flex-1 overflow-y-auto scrollbar-thin scrollbar-thumb-slate-200 hover:scrollbar-thumb-slate-300">
|
| 98 |
+
{isLoading ? (
|
| 99 |
+
// Skeleton Loading
|
| 100 |
+
<div className="divide-y divide-slate-50">
|
| 101 |
+
{[1, 2, 3, 4, 5].map((i) => (
|
| 102 |
+
<div key={i} className="p-4 flex gap-3 animate-pulse">
|
| 103 |
+
<div className="w-10 h-10 rounded-full bg-slate-100 flex-shrink-0" />
|
| 104 |
+
<div className="flex-1 space-y-2">
|
| 105 |
+
<div className="flex justify-between">
|
| 106 |
+
<div className="h-4 bg-slate-100 rounded w-24"></div>
|
| 107 |
+
<div className="h-3 bg-slate-100 rounded w-12"></div>
|
| 108 |
+
</div>
|
| 109 |
+
<div className="h-3 bg-slate-100 rounded w-3/4"></div>
|
| 110 |
+
</div>
|
| 111 |
</div>
|
| 112 |
+
))}
|
| 113 |
+
</div>
|
| 114 |
+
) : filteredLeads.length > 0 ? (
|
| 115 |
+
<div className="divide-y divide-slate-50">
|
| 116 |
+
{filteredLeads.map((lead) => {
|
| 117 |
+
const isSelected = selectedLeadId === lead.id
|
| 118 |
+
|
| 119 |
+
// Status Dot Color
|
| 120 |
+
const getStatusDotColor = (heatLevel: string) => {
|
| 121 |
+
switch (heatLevel.toUpperCase()) {
|
| 122 |
+
case 'HOT': return 'bg-red-500 shadow-[0_0_6px_rgba(239,68,68,0.4)]'
|
| 123 |
+
case 'WARM': return 'bg-amber-500 shadow-[0_0_6px_rgba(245,158,11,0.4)]'
|
| 124 |
+
case 'COLD': return 'bg-blue-500 shadow-[0_0_6px_rgba(59,130,246,0.4)]'
|
| 125 |
+
default: return 'bg-slate-300'
|
| 126 |
+
}
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
return (
|
| 130 |
+
<div
|
| 131 |
+
key={lead.id}
|
| 132 |
+
onClick={() => onSelectLead(lead)}
|
| 133 |
+
className={cn(
|
| 134 |
+
"p-4 cursor-pointer transition-all duration-200 hover:bg-slate-50 border-l-[3px] group",
|
| 135 |
+
isSelected
|
| 136 |
+
? "bg-indigo-50/60 border-indigo-600"
|
| 137 |
+
: "border-transparent hover:border-slate-200"
|
| 138 |
+
)}
|
| 139 |
+
>
|
| 140 |
+
<div className="flex items-start gap-3">
|
| 141 |
+
{/* Avatar */}
|
| 142 |
+
<div className="relative flex-shrink-0">
|
| 143 |
+
<div className={cn(
|
| 144 |
+
"w-10 h-10 rounded-full flex items-center justify-center text-sm font-bold shadow-sm transition-colors",
|
| 145 |
+
isSelected ? "bg-indigo-100 text-indigo-700" : "bg-slate-100 text-slate-500 group-hover:bg-white group-hover:shadow-md"
|
| 146 |
+
)}>
|
| 147 |
+
{lead.name?.charAt(0).toUpperCase() || '?'}
|
| 148 |
+
</div>
|
| 149 |
+
<div className={cn(
|
| 150 |
+
"absolute -bottom-0.5 -right-0.5 w-3.5 h-3.5 rounded-full border-2 border-white",
|
| 151 |
+
getStatusDotColor(lead.heat_level)
|
| 152 |
+
)} />
|
| 153 |
+
</div>
|
| 154 |
+
|
| 155 |
+
{/* Content */}
|
| 156 |
+
<div className="flex-1 min-w-0">
|
| 157 |
+
<div className="flex items-center justify-between mb-0.5">
|
| 158 |
+
<h3 className={cn(
|
| 159 |
+
"font-semibold text-sm truncate",
|
| 160 |
+
isSelected ? "text-indigo-900" : "text-slate-900"
|
| 161 |
+
)}>
|
| 162 |
+
{lead.name || 'Без имени'}
|
| 163 |
+
</h3>
|
| 164 |
+
<span className="text-[10px] text-slate-400 font-medium whitespace-nowrap ml-2">
|
| 165 |
+
{new Date(lead.last_message_at).toLocaleTimeString('ru-RU', { hour: '2-digit', minute: '2-digit' })}
|
| 166 |
+
</span>
|
| 167 |
+
</div>
|
| 168 |
+
|
| 169 |
+
<p className={cn(
|
| 170 |
+
"text-xs truncate leading-relaxed",
|
| 171 |
+
isSelected ? "text-indigo-700/70" : "text-slate-500"
|
| 172 |
+
)}>
|
| 173 |
+
{lead.ai_summary_json?.intent || lead.ai_summary_json?.recommendation || 'Нет анализа'}
|
| 174 |
+
</p>
|
| 175 |
+
</div>
|
| 176 |
+
</div>
|
| 177 |
+
</div>
|
| 178 |
+
)
|
| 179 |
+
})}
|
| 180 |
</div>
|
| 181 |
+
) : (
|
| 182 |
+
<div className="flex flex-col items-center justify-center py-12 px-6 text-center">
|
| 183 |
+
<div className="w-12 h-12 rounded-full bg-slate-50 flex items-center justify-center mb-3">
|
| 184 |
+
<Inbox className="w-6 h-6 text-slate-300" />
|
| 185 |
+
</div>
|
| 186 |
+
<p className="text-xs text-slate-500">
|
| 187 |
+
{searchQuery ? 'Ничего не найдено' : 'Список пуст'}
|
| 188 |
+
</p>
|
| 189 |
</div>
|
| 190 |
+
)}
|
| 191 |
+
</div>
|
| 192 |
</div>
|
| 193 |
)
|
| 194 |
}
|