Spaces:
Running
Running
axeronis commited on
Commit ·
88db97e
1
Parent(s): 191da31
fix: Restore ClientCard.tsx to full version
Browse files- Recovered from broken state (158 lines -> 416 lines)
- Reverted to working version from b705668
- frontend/components/ClientCard.tsx +380 -122
frontend/components/ClientCard.tsx
CHANGED
|
@@ -1,138 +1,396 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
</span>
|
| 21 |
-
|
| 22 |
</div>
|
| 23 |
</div>
|
| 24 |
-
)
|
| 25 |
-
}
|
| 26 |
|
| 27 |
-
{
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
<
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
<
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
</div
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
<
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
<
|
| 70 |
-
<button
|
| 71 |
-
onClick={() => copyToClipboard(data.hidden_signals || '', 'Скрытые сигналы')}
|
| 72 |
-
className="absolute top-2 right-2 p-1.5 bg-white rounded-md shadow-sm border border-slate-100 opacity-0 group-hover:opacity-100 transition-opacity hover:text-indigo-600"
|
| 73 |
-
title="Копировать"
|
| 74 |
-
>
|
| 75 |
-
<Copy className="w-3 h-3" />
|
| 76 |
-
</button>
|
| 77 |
</div>
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
)}
|
| 80 |
-
</AnimatePresence>
|
| 81 |
-
</div>
|
| 82 |
-
)
|
| 83 |
-
}
|
| 84 |
|
| 85 |
-
{
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
<div className="
|
| 106 |
-
<p className="text-xs text-slate-600 leading-relaxed mt-2">{data.recommendation}</p>
|
| 107 |
<button
|
| 108 |
-
onClick={() =>
|
| 109 |
-
className="
|
| 110 |
-
title="Копировать"
|
| 111 |
>
|
| 112 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
</div>
|
| 115 |
-
|
| 116 |
-
)}
|
| 117 |
-
</AnimatePresence>
|
| 118 |
-
</div>
|
| 119 |
-
)
|
| 120 |
-
}
|
| 121 |
-
</div >
|
| 122 |
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
|
| 134 |
-
|
| 135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
)
|
| 137 |
}
|
| 138 |
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import { useState, useEffect } from 'react'
|
| 4 |
+
import { Lead } from '@/lib/api'
|
| 5 |
+
import { cn } from '@/lib/utils'
|
| 6 |
+
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 |
+
Mail, Archive, PhoneCall, MapPin, Briefcase
|
| 12 |
+
} from 'lucide-react'
|
| 13 |
+
import { useToast } from '@/contexts/ToastContext'
|
| 14 |
+
import { motion, AnimatePresence } from 'framer-motion'
|
| 15 |
+
|
| 16 |
+
interface ClientCardProps {
|
| 17 |
+
lead: Lead
|
| 18 |
+
onTakeover: () => void
|
| 19 |
+
isAnalyzing?: boolean
|
| 20 |
+
onRefresh?: () => void
|
| 21 |
+
conversationId?: string
|
| 22 |
+
tenantId?: string
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversationId, tenantId }: ClientCardProps) {
|
| 26 |
+
const { success, error } = useToast()
|
| 27 |
+
const summary = lead.ai_summary_json || {}
|
| 28 |
+
const [expandedSection, setExpandedSection] = useState<string | null>(null)
|
| 29 |
+
const [isReanalyzing, setIsReanalyzing] = useState(false)
|
| 30 |
+
const [currentStage, setCurrentStage] = useState<any>(null)
|
| 31 |
+
|
| 32 |
+
useEffect(() => {
|
| 33 |
+
if (!lead.current_stage_id) return
|
| 34 |
+
fetch(`/api/v1/playbook/stages`, {
|
| 35 |
+
headers: { 'Authorization': `Bearer ${localStorage.getItem('auth_token')}` }
|
| 36 |
+
})
|
| 37 |
+
.then(r => r.ok ? r.json() : [])
|
| 38 |
+
.then(stages => {
|
| 39 |
+
const stage = stages.find((s: any) => s.id === lead.current_stage_id)
|
| 40 |
+
if (stage) setCurrentStage(stage)
|
| 41 |
+
})
|
| 42 |
+
.catch(console.error)
|
| 43 |
+
}, [lead.current_stage_id])
|
| 44 |
+
|
| 45 |
+
const handleReanalyze = async () => {
|
| 46 |
+
setIsReanalyzing(true)
|
| 47 |
+
try {
|
| 48 |
+
const res = await fetch(`/api/v1/leads/${lead.id}/analyze`, {
|
| 49 |
+
method: 'POST',
|
| 50 |
+
headers: {
|
| 51 |
+
'Content-Type': 'application/json',
|
| 52 |
+
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`
|
| 53 |
+
}
|
| 54 |
+
})
|
| 55 |
+
if (!res.ok) throw new Error('Failed')
|
| 56 |
+
success('Анализ запущен', 'AI переанализирует данные')
|
| 57 |
+
setTimeout(() => onRefresh?.(), 3000)
|
| 58 |
+
} catch {
|
| 59 |
+
error('Ошибка', 'Не удалось запустить анализ')
|
| 60 |
+
} finally {
|
| 61 |
+
setIsReanalyzing(false)
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
// Helper to clean values
|
| 65 |
+
const cleanValue = (value: any, fallback: string): string => {
|
| 66 |
+
if (!value || typeof value !== 'string') return fallback
|
| 67 |
+
const errorPatterns = ['unknown', 'error', 'failed', 'undefined']
|
| 68 |
+
return errorPatterns.some(p => value.toLowerCase().includes(p)) ? fallback : value
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
// Structured Data
|
| 72 |
+
const data = {
|
| 73 |
+
intent: cleanValue(summary.intent || lead.need, 'Не определено'),
|
| 74 |
+
budget: cleanValue(summary.budget || lead.budget, 'Не определён'),
|
| 75 |
+
authority: cleanValue(summary.authority || lead.authority, 'Неизвестно'),
|
| 76 |
+
timeline: cleanValue(summary.timeline || lead.timeline, 'Не указаны'),
|
| 77 |
+
pain_points: Array.isArray(summary.pain_points) ? summary.pain_points : [],
|
| 78 |
+
objections: Array.isArray(summary.objections) ? summary.objections : [],
|
| 79 |
+
psychotype: cleanValue(summary.psychotype || lead.psychotype, 'unknown'),
|
| 80 |
+
hidden_signals: summary.hidden_signals,
|
| 81 |
+
recommendation: summary.recommendation,
|
| 82 |
+
draft_reply: summary.draft_reply,
|
| 83 |
+
heat_score: typeof summary.heat_score === 'number' ? summary.heat_score : (lead.heat_score || 0)
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
// Psychotype Colors & Labels
|
| 87 |
+
const getPsychotypeInfo = (type: string) => {
|
| 88 |
+
const map: Record<string, { label: string; color: string; bg: string; icon: any }> = {
|
| 89 |
+
'dominant': { label: 'Доминантный', color: 'text-red-600', bg: 'bg-red-50', icon: Zap },
|
| 90 |
+
'influential': { label: 'Влияющий', color: 'text-amber-600', bg: 'bg-amber-50', icon: StarIcon },
|
| 91 |
+
'steady': { label: 'Стабильный', color: 'text-emerald-600', bg: 'bg-emerald-50', icon: Shield },
|
| 92 |
+
'conscientious': { label: 'Аналитический', color: 'text-blue-600', bg: 'bg-blue-50', icon: Database },
|
| 93 |
+
'unknown': { label: 'Не определён', color: 'text-slate-500', bg: 'bg-slate-50', icon: UserIcon }
|
| 94 |
+
}
|
| 95 |
+
return map[type.toLowerCase()] || map['unknown']
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
const psychotype = getPsychotypeInfo(data.psychotype)
|
| 99 |
+
|
| 100 |
+
// Score Color
|
| 101 |
+
const getScoreColor = (score: number) => {
|
| 102 |
+
if (score >= 80) return 'text-red-500'
|
| 103 |
+
if (score >= 50) return 'text-amber-500'
|
| 104 |
+
return 'text-blue-500'
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
const copyToClipboard = (text: string, label: string) => {
|
| 108 |
+
navigator.clipboard.writeText(text)
|
| 109 |
+
success("Скопировано", `${label} скопировано в буфер обмена`)
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
const toggleSection = (section: string) => {
|
| 113 |
+
setExpandedSection(expandedSection === section ? null : section)
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
return (
|
| 117 |
+
<div className="h-full flex flex-col bg-slate-100 font-['Inter'] border-l border-slate-200">
|
| 118 |
+
{/* Header */}
|
| 119 |
+
<div className="p-5 border-b border-slate-200 flex items-center justify-between bg-white sticky top-0 z-10 shadow-sm">
|
| 120 |
+
<div className="flex items-center gap-3">
|
| 121 |
+
<div className="w-10 h-10 rounded-xl bg-indigo-50 flex items-center justify-center text-indigo-600 shadow-sm ring-1 ring-indigo-100">
|
| 122 |
+
<Brain className="w-5 h-5" />
|
| 123 |
+
</div>
|
| 124 |
+
<div>
|
| 125 |
+
<h2 className="font-bold text-slate-900 text-sm">AI Summary</h2>
|
| 126 |
+
<p className="text-[10px] text-slate-500 font-medium">Анализ диалога</p>
|
| 127 |
+
{currentStage && (
|
| 128 |
+
<span className="flex items-center gap-1 px-2 py-0.5 bg-indigo-50 border border-indigo-200 rounded-md text-[10px] font-semibold text-indigo-700">
|
| 129 |
+
<Target className="w-3 h-3" />
|
| 130 |
+
{currentStage.name}
|
| 131 |
+
</span>
|
| 132 |
+
)}
|
| 133 |
+
</div>
|
| 134 |
+
</div>
|
| 135 |
+
|
| 136 |
+
<div className="flex items-center gap-3">
|
| 137 |
+
{/* Refresh Button */}
|
| 138 |
+
<button
|
| 139 |
+
onClick={handleReanalyze}
|
| 140 |
+
disabled={isReanalyzing || isAnalyzing}
|
| 141 |
+
className="flex items-center gap-1.5 px-3 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px] font-bold text-slate-600 hover:text-indigo-600 hover:border-indigo-200 hover:bg-indigo-50 transition-all shadow-sm active:scale-95 disabled:opacity-50 disabled:cursor-not-allowed"
|
| 142 |
+
>
|
| 143 |
+
<Brain className={cn("w-3 h-3", (isReanalyzing || isAnalyzing) && "animate-pulse")} />
|
| 144 |
+
<span>{isReanalyzing ? 'Анализ...' : 'Анализ'}</span>
|
| 145 |
+
</button>
|
| 146 |
+
|
| 147 |
+
{/* Score Ring */}
|
| 148 |
+
<div className="relative w-12 h-12 flex items-center justify-center group cursor-help">
|
| 149 |
+
<svg className="w-full h-full transform -rotate-90">
|
| 150 |
+
<defs>
|
| 151 |
+
<linearGradient id="scoreGradient" x1="0%" y1="0%" x2="100%" y2="0%">
|
| 152 |
+
<stop offset="0%" stopColor={data.heat_score >= 80 ? '#ef4444' : data.heat_score >= 50 ? '#f59e0b' : '#3b82f6'} />
|
| 153 |
+
<stop offset="100%" stopColor={data.heat_score >= 80 ? '#f87171' : data.heat_score >= 50 ? '#fbbf24' : '#60a5fa'} />
|
| 154 |
+
</linearGradient>
|
| 155 |
+
</defs>
|
| 156 |
+
<circle cx="24" cy="24" r="20" stroke="#e2e8f0" strokeWidth="4" fill="none" />
|
| 157 |
+
<circle
|
| 158 |
+
cx="24" cy="24" r="20"
|
| 159 |
+
stroke="url(#scoreGradient)"
|
| 160 |
+
strokeWidth="4"
|
| 161 |
+
fill="none"
|
| 162 |
+
strokeDasharray={126}
|
| 163 |
+
strokeDashoffset={126 - (data.heat_score / 100) * 126}
|
| 164 |
+
className="transition-all duration-1000 ease-out"
|
| 165 |
+
strokeLinecap="round"
|
| 166 |
+
/>
|
| 167 |
+
</svg>
|
| 168 |
+
<span className={cn("absolute text-xs font-bold", getScoreColor(data.heat_score))}>
|
| 169 |
+
{data.heat_score}
|
| 170 |
</span>
|
| 171 |
+
</div>
|
| 172 |
</div>
|
| 173 |
</div>
|
|
|
|
|
|
|
| 174 |
|
| 175 |
+
{/* Content */}
|
| 176 |
+
<div className="flex-1 overflow-y-auto p-4 space-y-4 scrollbar-thin scrollbar-thumb-slate-200">
|
| 177 |
+
|
| 178 |
+
{/* Action Buttons */}
|
| 179 |
+
<div className="grid grid-cols-3 gap-2">
|
| 180 |
+
<button className="flex flex-col items-center justify-center gap-1.5 p-3 rounded-xl bg-white border border-slate-200 shadow-sm hover:shadow-md hover:border-indigo-200 hover:bg-indigo-50/30 transition-all group">
|
| 181 |
+
<PhoneCall className="w-4 h-4 text-slate-500 group-hover:text-indigo-600" />
|
| 182 |
+
<span className="text-[10px] font-semibold text-slate-600 group-hover:text-indigo-700">Call</span>
|
| 183 |
+
</button>
|
| 184 |
+
<button className="flex flex-col items-center justify-center gap-1.5 p-3 rounded-xl bg-white border border-slate-200 shadow-sm hover:shadow-md hover:border-indigo-200 hover:bg-indigo-50/30 transition-all group">
|
| 185 |
+
<Mail className="w-4 h-4 text-slate-500 group-hover:text-indigo-600" />
|
| 186 |
+
<span className="text-[10px] font-semibold text-slate-600 group-hover:text-indigo-700">Email</span>
|
| 187 |
+
</button>
|
| 188 |
+
<button className="flex flex-col items-center justify-center gap-1.5 p-3 rounded-xl bg-white border border-slate-200 shadow-sm hover:shadow-md hover:border-indigo-200 hover:bg-indigo-50/30 transition-all group">
|
| 189 |
+
<Archive className="w-4 h-4 text-slate-500 group-hover:text-indigo-600" />
|
| 190 |
+
<span className="text-[10px] font-semibold text-slate-600 group-hover:text-indigo-700">Archive</span>
|
| 191 |
+
</button>
|
| 192 |
+
</div>
|
| 193 |
+
|
| 194 |
+
{/* Profile Info */}
|
| 195 |
+
<div className="bg-white rounded-xl border border-slate-200 shadow-sm p-4 space-y-3">
|
| 196 |
+
<h3 className="text-[10px] font-bold text-slate-400 uppercase tracking-wider mb-2">Профиль клиента</h3>
|
| 197 |
+
<div className="space-y-2">
|
| 198 |
+
<div className="flex items-center justify-between p-2 bg-slate-50 rounded-lg border border-slate-100">
|
| 199 |
+
<div className="flex items-center gap-2">
|
| 200 |
+
<UserIcon className="w-3.5 h-3.5 text-slate-400" />
|
| 201 |
+
<span className="text-xs font-medium text-slate-600">Имя</span>
|
| 202 |
+
</div>
|
| 203 |
+
<span className="text-xs font-bold text-slate-900">{lead.name || 'Не указано'}</span>
|
| 204 |
+
</div>
|
| 205 |
+
|
| 206 |
+
<div className="flex items-center justify-between p-2 bg-slate-50 rounded-lg border border-slate-100">
|
| 207 |
+
<div className="flex items-center gap-2">
|
| 208 |
+
<MapPin className="w-3.5 h-3.5 text-slate-400" />
|
| 209 |
+
<span className="text-xs font-medium text-slate-600">Локация</span>
|
| 210 |
+
</div>
|
| 211 |
+
<span className="text-xs font-bold text-slate-900">{cleanValue(summary.location, 'Не определено')}</span>
|
| 212 |
+
</div>
|
| 213 |
+
|
| 214 |
+
<div className="flex items-center justify-between p-2 bg-slate-50 rounded-lg border border-slate-100">
|
| 215 |
+
<div className="flex items-center gap-2">
|
| 216 |
+
<Briefcase className="w-3.5 h-3.5 text-slate-400" />
|
| 217 |
+
<span className="text-xs font-medium text-slate-600">Сфера</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
</div>
|
| 219 |
+
<span className="text-xs font-bold text-slate-900">{cleanValue(summary.industry, 'Не определено')}</span>
|
| 220 |
+
</div>
|
| 221 |
+
</div>
|
| 222 |
+
</div>
|
| 223 |
+
|
| 224 |
+
{/* Key Metrics Grid */}
|
| 225 |
+
<div className="bg-white rounded-xl border border-slate-200 shadow-sm p-4 space-y-3">
|
| 226 |
+
<h3 className="text-[10px] font-bold text-slate-400 uppercase tracking-wider mb-2">Ключевые данные</h3>
|
| 227 |
+
<div className="grid grid-cols-2 gap-3">
|
| 228 |
+
<div className="p-2.5 bg-slate-50 rounded-lg border border-slate-100">
|
| 229 |
+
<div className="flex items-center gap-1.5 mb-1">
|
| 230 |
+
<Target className="w-3 h-3 text-indigo-500" />
|
| 231 |
+
<span className="text-[10px] font-medium text-slate-500">Намерение</span>
|
| 232 |
+
</div>
|
| 233 |
+
<p className="text-xs font-semibold text-slate-900 line-clamp-2 leading-tight" title={data.intent}>{data.intent}</p>
|
| 234 |
+
</div>
|
| 235 |
+
|
| 236 |
+
<div className="p-2.5 bg-slate-50 rounded-lg border border-slate-100">
|
| 237 |
+
<div className="flex items-center gap-1.5 mb-1">
|
| 238 |
+
<DollarSign className="w-3 h-3 text-emerald-500" />
|
| 239 |
+
<span className="text-[10px] font-medium text-slate-500">Бюджет</span>
|
| 240 |
+
</div>
|
| 241 |
+
<p className="text-xs font-semibold text-slate-900 leading-tight">{data.budget}</p>
|
| 242 |
+
</div>
|
| 243 |
+
|
| 244 |
+
<div className="p-2.5 bg-slate-50 rounded-lg border border-slate-100">
|
| 245 |
+
<div className="flex items-center gap-1.5 mb-1">
|
| 246 |
+
<UserIcon className="w-3 h-3 text-blue-500" />
|
| 247 |
+
<span className="text-[10px] font-medium text-slate-500">ЛПР</span>
|
| 248 |
+
</div>
|
| 249 |
+
<p className="text-xs font-semibold text-slate-900 leading-tight">{data.authority}</p>
|
| 250 |
+
</div>
|
| 251 |
+
|
| 252 |
+
<div className="p-2.5 bg-slate-50 rounded-lg border border-slate-100">
|
| 253 |
+
<div className="flex items-center gap-1.5 mb-1">
|
| 254 |
+
<Clock className="w-3 h-3 text-amber-500" />
|
| 255 |
+
<span className="text-[10px] font-medium text-slate-500">Сроки</span>
|
| 256 |
+
</div>
|
| 257 |
+
<p className="text-xs font-semibold text-slate-900 leading-tight">{data.timeline}</p>
|
| 258 |
+
</div>
|
| 259 |
+
</div>
|
| 260 |
+
</div>
|
| 261 |
+
|
| 262 |
+
{/* Psychotype */}
|
| 263 |
+
<div className={cn("p-4 rounded-xl border shadow-sm flex items-center gap-4 transition-all bg-white", psychotype.color.replace('text-', 'border-').replace('600', '100'))}>
|
| 264 |
+
<div className={cn("w-10 h-10 rounded-full flex items-center justify-center shadow-sm ring-2 ring-white", psychotype.bg, psychotype.color)}>
|
| 265 |
+
<psychotype.icon className="w-5 h-5" />
|
| 266 |
+
</div>
|
| 267 |
+
<div>
|
| 268 |
+
<span className="text-[10px] font-bold uppercase text-slate-400">Психотип</span>
|
| 269 |
+
<p className={cn("font-bold text-sm", psychotype.color)}>{psychotype.label}</p>
|
| 270 |
+
</div>
|
| 271 |
+
</div>
|
| 272 |
+
|
| 273 |
+
{/* Pain Points & Objections */}
|
| 274 |
+
<div className="space-y-3">
|
| 275 |
+
{data.pain_points.length > 0 && (
|
| 276 |
+
<div className="bg-white rounded-xl border border-slate-200 shadow-sm p-4">
|
| 277 |
+
<h3 className="text-[10px] font-bold text-slate-400 uppercase tracking-wider mb-3 flex items-center gap-2">
|
| 278 |
+
<AlertCircle className="w-3.5 h-3.5 text-red-500" />
|
| 279 |
+
Боли клиента
|
| 280 |
+
</h3>
|
| 281 |
+
<div className="flex flex-wrap gap-2">
|
| 282 |
+
{data.pain_points.map((point: string, i: number) => (
|
| 283 |
+
<span key={i} className="px-2.5 py-1.5 bg-red-50 text-red-700 text-[10px] font-semibold rounded-lg border border-red-100 leading-tight">
|
| 284 |
+
{point}
|
| 285 |
+
</span>
|
| 286 |
+
))}
|
| 287 |
+
</div>
|
| 288 |
+
</div>
|
| 289 |
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
|
| 291 |
+
{data.objections.length > 0 && (
|
| 292 |
+
<div className="bg-white rounded-xl border border-slate-200 shadow-sm p-4">
|
| 293 |
+
<h3 className="text-[10px] font-bold text-slate-400 uppercase tracking-wider mb-3 flex items-center gap-2">
|
| 294 |
+
<AlertTriangle className="w-3.5 h-3.5 text-amber-500" />
|
| 295 |
+
Возражения
|
| 296 |
+
</h3>
|
| 297 |
+
<div className="flex flex-wrap gap-2">
|
| 298 |
+
{data.objections.map((obj: string, i: number) => (
|
| 299 |
+
<span key={i} className="px-2.5 py-1.5 bg-amber-50 text-amber-700 text-[10px] font-semibold rounded-lg border border-amber-100 leading-tight">
|
| 300 |
+
{obj}
|
| 301 |
+
</span>
|
| 302 |
+
))}
|
| 303 |
+
</div>
|
| 304 |
+
</div>
|
| 305 |
+
)}
|
| 306 |
+
</div>
|
| 307 |
+
|
| 308 |
+
{/* Strategy Section */}
|
| 309 |
+
<div className="space-y-3">
|
| 310 |
+
{data.hidden_signals && (
|
| 311 |
+
<div className="bg-white rounded-xl border border-indigo-100 shadow-sm overflow-hidden">
|
|
|
|
| 312 |
<button
|
| 313 |
+
onClick={() => toggleSection('signals')}
|
| 314 |
+
className="w-full p-3 bg-indigo-50/30 flex items-center justify-between hover:bg-indigo-50 transition-colors"
|
|
|
|
| 315 |
>
|
| 316 |
+
<h4 className="text-[10px] font-bold text-indigo-700 uppercase flex items-center gap-2">
|
| 317 |
+
<MessageSquare className="w-3.5 h-3.5" />
|
| 318 |
+
Скрытые сигналы
|
| 319 |
+
</h4>
|
| 320 |
+
{expandedSection === 'signals' ? <ChevronUp className="w-3.5 h-3.5 text-indigo-400" /> : <ChevronDown className="w-3.5 h-3.5 text-indigo-400" />}
|
| 321 |
</button>
|
| 322 |
+
<AnimatePresence>
|
| 323 |
+
{(expandedSection === 'signals' || !expandedSection) && (
|
| 324 |
+
<motion.div
|
| 325 |
+
initial={{ height: 0, opacity: 0 }}
|
| 326 |
+
animate={{ height: 'auto', opacity: 1 }}
|
| 327 |
+
exit={{ height: 0, opacity: 0 }}
|
| 328 |
+
>
|
| 329 |
+
<div className="p-3 pt-0 relative group">
|
| 330 |
+
<p className="text-xs text-slate-600 leading-relaxed mt-2">{data.hidden_signals}</p>
|
| 331 |
+
<button
|
| 332 |
+
onClick={() => copyToClipboard(data.hidden_signals || '', 'Скрытые сигналы')}
|
| 333 |
+
className="absolute top-2 right-2 p-1.5 bg-white rounded-md shadow-sm border border-slate-100 opacity-0 group-hover:opacity-100 transition-opacity hover:text-indigo-600"
|
| 334 |
+
title="Копировать"
|
| 335 |
+
>
|
| 336 |
+
<Copy className="w-3 h-3" />
|
| 337 |
+
</button>
|
| 338 |
+
</div>
|
| 339 |
+
</motion.div>
|
| 340 |
+
)}
|
| 341 |
+
</AnimatePresence>
|
| 342 |
</div>
|
| 343 |
+
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 344 |
|
| 345 |
+
{data.recommendation && (
|
| 346 |
+
<div className="bg-white rounded-xl border border-emerald-100 shadow-sm overflow-hidden">
|
| 347 |
+
<button
|
| 348 |
+
onClick={() => toggleSection('recommendation')}
|
| 349 |
+
className="w-full p-3 bg-emerald-50/30 flex items-center justify-between hover:bg-emerald-50 transition-colors"
|
| 350 |
+
>
|
| 351 |
+
<h4 className="text-[10px] font-bold text-emerald-700 uppercase flex items-center gap-2">
|
| 352 |
+
<ThumbsUp className="w-3.5 h-3.5" />
|
| 353 |
+
Рекомендация
|
| 354 |
+
</h4>
|
| 355 |
+
{expandedSection === 'recommendation' ? <ChevronUp className="w-3.5 h-3.5 text-emerald-400" /> : <ChevronDown className="w-3.5 h-3.5 text-emerald-400" />}
|
| 356 |
+
</button>
|
| 357 |
+
<AnimatePresence>
|
| 358 |
+
{(expandedSection === 'recommendation' || !expandedSection) && (
|
| 359 |
+
<motion.div
|
| 360 |
+
initial={{ height: 0, opacity: 0 }}
|
| 361 |
+
animate={{ height: 'auto', opacity: 1 }}
|
| 362 |
+
exit={{ height: 0, opacity: 0 }}
|
| 363 |
+
>
|
| 364 |
+
<div className="p-3 pt-0 relative group">
|
| 365 |
+
<p className="text-xs text-slate-600 leading-relaxed mt-2">{data.recommendation}</p>
|
| 366 |
+
<button
|
| 367 |
+
onClick={() => copyToClipboard(data.recommendation || '', 'Рекомендация')}
|
| 368 |
+
className="absolute top-2 right-2 p-1.5 bg-white rounded-md shadow-sm border border-slate-100 opacity-0 group-hover:opacity-100 transition-opacity hover:text-emerald-600"
|
| 369 |
+
title="Копировать"
|
| 370 |
+
>
|
| 371 |
+
<Copy className="w-3 h-3" />
|
| 372 |
+
</button>
|
| 373 |
+
</div>
|
| 374 |
+
</motion.div>
|
| 375 |
+
)}
|
| 376 |
+
</AnimatePresence>
|
| 377 |
+
</div>
|
| 378 |
+
)}
|
| 379 |
+
</div>
|
| 380 |
|
| 381 |
+
{/* Actions */}
|
| 382 |
+
<div className="pt-2 mt-auto">
|
| 383 |
+
<button
|
| 384 |
+
onClick={onTakeover}
|
| 385 |
+
className="w-full py-3 bg-slate-900 text-white text-xs font-bold rounded-xl hover:bg-slate-800 transition-all shadow-lg shadow-slate-900/10 flex items-center justify-center gap-2 group"
|
| 386 |
+
>
|
| 387 |
+
<UserIcon className="w-4 h-4 group-hover:scale-110 transition-transform" />
|
| 388 |
+
Взять диалог на себя
|
| 389 |
+
</button>
|
| 390 |
+
</div>
|
| 391 |
+
|
| 392 |
+
</div>
|
| 393 |
+
</div>
|
| 394 |
)
|
| 395 |
}
|
| 396 |
|