Spaces:
Running
Running
axeronis commited on
Commit ·
8932582
1
Parent(s): 78f40f7
изайн: Светлая тема для аналитики и сайдбара, удаление всех эмодзи, исправление логотипов
Browse files- frontend/app/channels/page.tsx +9 -6
- frontend/app/dashboard/page.tsx +95 -85
- frontend/app/partners/page.tsx +36 -36
- frontend/app/settings/brain/page_old.tsx +16 -18
- frontend/app/settings/crm/page.tsx +50 -42
- frontend/components/ClientCard.tsx +56 -56
- frontend/components/Sidebar.tsx +57 -59
frontend/app/channels/page.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
|
| 5 |
import { useAuth } from '@/contexts/AuthContext'
|
| 6 |
import { useToast } from '@/contexts/ToastContext'
|
| 7 |
import { channelsApi } from '@/lib/api'
|
| 8 |
-
import { Send, CheckCircle, XCircle, AlertCircle, Loader2, ExternalLink, Copy, Check, Linkedin, QrCode } from 'lucide-react'
|
| 9 |
|
| 10 |
type Channel = 'telegram' | 'whatsapp' | 'linkedin'
|
| 11 |
|
|
@@ -374,7 +374,7 @@ function TelegramTab({
|
|
| 374 |
className="px-4 py-3 border border-slate-200 rounded-xl hover:bg-slate-50"
|
| 375 |
disabled={isProcessing}
|
| 376 |
>
|
| 377 |
-
{showToken ?
|
| 378 |
</button>
|
| 379 |
</div>
|
| 380 |
<p className="mt-2 text-xs text-slate-500">
|
|
@@ -443,7 +443,7 @@ function WhatsAppQRTab({
|
|
| 443 |
<div className="flex items-center justify-between p-4 bg-slate-50 rounded-xl">
|
| 444 |
<div className="flex items-center gap-3">
|
| 445 |
<div className="w-12 h-12 bg-emerald-50 rounded-xl flex items-center justify-center text-2xl">
|
| 446 |
-
|
| 447 |
</div>
|
| 448 |
<div>
|
| 449 |
<h3 className="font-bold text-slate-900">WhatsApp Business (QR)</h3>
|
|
@@ -491,7 +491,7 @@ function WhatsAppQRTab({
|
|
| 491 |
<div className="p-6 bg-gradient-to-br from-emerald-50 to-teal-50 border-2 border-emerald-200 rounded-2xl">
|
| 492 |
<div className="flex items-start gap-4">
|
| 493 |
<div className="w-12 h-12 bg-emerald-600 rounded-xl flex items-center justify-center flex-shrink-0">
|
| 494 |
-
<
|
| 495 |
</div>
|
| 496 |
<div className="flex-1">
|
| 497 |
<h3 className="text-lg font-bold text-slate-900 mb-2">Подключение WhatsApp через QR-код</h3>
|
|
@@ -530,7 +530,7 @@ function WhatsAppQRTab({
|
|
| 530 |
</>
|
| 531 |
) : (
|
| 532 |
<>
|
| 533 |
-
<
|
| 534 |
Генерировать QR-код
|
| 535 |
</>
|
| 536 |
)}
|
|
@@ -541,7 +541,10 @@ function WhatsAppQRTab({
|
|
| 541 |
|
| 542 |
{/* Инструкция */}
|
| 543 |
<div className="p-6 bg-blue-50 border-2 border-blue-200 rounded-2xl">
|
| 544 |
-
<h4 className="font-bold text-blue-900 mb-3
|
|
|
|
|
|
|
|
|
|
| 545 |
<ol className="list-decimal ml-5 space-y-2 text-sm text-blue-900">
|
| 546 |
<li>Нажмите "Генерировать QR-код"</li>
|
| 547 |
<li>Откройте WhatsApp на телефоне</li>
|
|
|
|
| 5 |
import { useAuth } from '@/contexts/AuthContext'
|
| 6 |
import { useToast } from '@/contexts/ToastContext'
|
| 7 |
import { channelsApi } from '@/lib/api'
|
| 8 |
+
import { Send, CheckCircle, XCircle, AlertCircle, Loader2, ExternalLink, Copy, Check, Linkedin, QrCode, Eye, EyeOff, Smartphone, Zap, BookOpen } from 'lucide-react'
|
| 9 |
|
| 10 |
type Channel = 'telegram' | 'whatsapp' | 'linkedin'
|
| 11 |
|
|
|
|
| 374 |
className="px-4 py-3 border border-slate-200 rounded-xl hover:bg-slate-50"
|
| 375 |
disabled={isProcessing}
|
| 376 |
>
|
| 377 |
+
{showToken ? <EyeOff className="w-5 h-5" /> : <Eye className="w-5 h-5" />}
|
| 378 |
</button>
|
| 379 |
</div>
|
| 380 |
<p className="mt-2 text-xs text-slate-500">
|
|
|
|
| 443 |
<div className="flex items-center justify-between p-4 bg-slate-50 rounded-xl">
|
| 444 |
<div className="flex items-center gap-3">
|
| 445 |
<div className="w-12 h-12 bg-emerald-50 rounded-xl flex items-center justify-center text-2xl">
|
| 446 |
+
<Smartphone className="w-6 h-6 text-emerald-600" />
|
| 447 |
</div>
|
| 448 |
<div>
|
| 449 |
<h3 className="font-bold text-slate-900">WhatsApp Business (QR)</h3>
|
|
|
|
| 491 |
<div className="p-6 bg-gradient-to-br from-emerald-50 to-teal-50 border-2 border-emerald-200 rounded-2xl">
|
| 492 |
<div className="flex items-start gap-4">
|
| 493 |
<div className="w-12 h-12 bg-emerald-600 rounded-xl flex items-center justify-center flex-shrink-0">
|
| 494 |
+
<Zap className="w-6 h-6 text-white" />
|
| 495 |
</div>
|
| 496 |
<div className="flex-1">
|
| 497 |
<h3 className="text-lg font-bold text-slate-900 mb-2">Подключение WhatsApp через QR-код</h3>
|
|
|
|
| 530 |
</>
|
| 531 |
) : (
|
| 532 |
<>
|
| 533 |
+
<QrCode className="w-6 h-6" />
|
| 534 |
Генерировать QR-код
|
| 535 |
</>
|
| 536 |
)}
|
|
|
|
| 541 |
|
| 542 |
{/* Инструкция */}
|
| 543 |
<div className="p-6 bg-blue-50 border-2 border-blue-200 rounded-2xl">
|
| 544 |
+
<h4 className="font-bold text-blue-900 mb-3 flex items-center gap-2">
|
| 545 |
+
<BookOpen className="w-5 h-5" />
|
| 546 |
+
Как это работает:
|
| 547 |
+
</h4>
|
| 548 |
<ol className="list-decimal ml-5 space-y-2 text-sm text-blue-900">
|
| 549 |
<li>Нажмите "Генерировать QR-код"</li>
|
| 550 |
<li>Откройте WhatsApp на телефоне</li>
|
frontend/app/dashboard/page.tsx
CHANGED
|
@@ -8,7 +8,8 @@ import {
|
|
| 8 |
} from 'recharts'
|
| 9 |
import {
|
| 10 |
TrendingUp, Users, Clock, DollarSign, Target, Zap,
|
| 11 |
-
AlertCircle, Loader2, ArrowUp, MessageSquare, Activity
|
|
|
|
| 12 |
} from 'lucide-react'
|
| 13 |
import { motion } from 'framer-motion'
|
| 14 |
|
|
@@ -55,12 +56,12 @@ interface DashboardData {
|
|
| 55 |
lead_value_over_time: LeadValueOverTime[]
|
| 56 |
}
|
| 57 |
|
| 58 |
-
// DISC Colors (
|
| 59 |
const DISC_COLORS = {
|
| 60 |
-
'Dominant': '#
|
| 61 |
-
'Influential': '#
|
| 62 |
-
'Steady': '#
|
| 63 |
-
'Conscientious': '#
|
| 64 |
'Unknown': '#9CA3AF' // Gray-400
|
| 65 |
}
|
| 66 |
|
|
@@ -137,10 +138,10 @@ export default function DashboardPage() {
|
|
| 137 |
|
| 138 |
if (authLoading || loading) {
|
| 139 |
return (
|
| 140 |
-
<div className="min-h-screen flex items-center justify-center bg-
|
| 141 |
<div className="text-center">
|
| 142 |
-
<Loader2 className="w-12 h-12 animate-spin text-indigo-
|
| 143 |
-
<p className="text-slate-
|
| 144 |
</div>
|
| 145 |
</div>
|
| 146 |
)
|
|
@@ -148,14 +149,14 @@ export default function DashboardPage() {
|
|
| 148 |
|
| 149 |
if (!user || error) {
|
| 150 |
return (
|
| 151 |
-
<div className="min-h-screen flex items-center justify-center bg-
|
| 152 |
-
<div className="text-center max-w-md p-8
|
| 153 |
<AlertCircle className="w-16 h-16 text-red-500 mx-auto mb-4" />
|
| 154 |
-
<h2 className="text-xl font-bold text-
|
| 155 |
-
<p className="text-slate-
|
| 156 |
<button
|
| 157 |
onClick={() => window.location.reload()}
|
| 158 |
-
className="px-6 py-2 bg-indigo-600 text-white rounded-xl hover:bg-indigo-
|
| 159 |
>
|
| 160 |
Обновить страницу
|
| 161 |
</button>
|
|
@@ -182,19 +183,23 @@ export default function DashboardPage() {
|
|
| 182 |
}
|
| 183 |
|
| 184 |
return (
|
| 185 |
-
<div className="min-h-screen bg-
|
| 186 |
-
{/* Background Effects */}
|
| 187 |
-
<div className="absolute
|
| 188 |
-
|
|
|
|
|
|
|
| 189 |
|
| 190 |
<div className="max-w-7xl mx-auto relative z-10">
|
| 191 |
{/* Header */}
|
| 192 |
<div className="mb-10">
|
| 193 |
-
<h1 className="text-3xl font-bold text-
|
| 194 |
-
<
|
|
|
|
|
|
|
| 195 |
Аналитика Продаж
|
| 196 |
</h1>
|
| 197 |
-
<p className="text-slate-
|
| 198 |
</div>
|
| 199 |
|
| 200 |
{/* Bento Grid */}
|
|
@@ -205,20 +210,20 @@ export default function DashboardPage() {
|
|
| 205 |
initial={{ opacity: 0, y: 20 }}
|
| 206 |
animate={{ opacity: 1, y: 0 }}
|
| 207 |
transition={{ duration: 0.5 }}
|
| 208 |
-
className="lg:col-span-2 relative overflow-hidden rounded-3xl border border-
|
| 209 |
>
|
| 210 |
-
<div className="absolute top-0 right-0 p-8 opacity-
|
| 211 |
-
<DollarSign className="w-32 h-32 text-indigo-
|
| 212 |
</div>
|
| 213 |
|
| 214 |
<div className="relative z-10 flex items-center justify-between mb-6">
|
| 215 |
<div>
|
| 216 |
-
<p className="text-indigo-
|
| 217 |
-
<h2 className="text-4xl font-bold text-
|
| 218 |
-
<p className="text-slate-
|
| 219 |
</div>
|
| 220 |
-
<div className="w-12 h-12 bg-indigo-
|
| 221 |
-
<DollarSign className="w-6 h-6 text-indigo-
|
| 222 |
</div>
|
| 223 |
</div>
|
| 224 |
|
|
@@ -227,26 +232,27 @@ export default function DashboardPage() {
|
|
| 227 |
<AreaChart data={data.lead_value_over_time}>
|
| 228 |
<defs>
|
| 229 |
<linearGradient id="colorValue" x1="0" y1="0" x2="0" y2="1">
|
| 230 |
-
<stop offset="5%" stopColor="#
|
| 231 |
-
<stop offset="95%" stopColor="#
|
| 232 |
</linearGradient>
|
| 233 |
</defs>
|
| 234 |
<XAxis
|
| 235 |
dataKey="date"
|
| 236 |
-
stroke="#
|
| 237 |
-
tick={{ fontSize: 12, fill: '#
|
| 238 |
tickFormatter={(value) => {
|
| 239 |
const date = new Date(value)
|
| 240 |
return `${date.getDate()}/${date.getMonth() + 1}`
|
| 241 |
}}
|
| 242 |
/>
|
| 243 |
-
<YAxis stroke="#
|
| 244 |
<Tooltip
|
| 245 |
contentStyle={{
|
| 246 |
-
backgroundColor: '#
|
| 247 |
-
border: '1px solid
|
| 248 |
borderRadius: '12px',
|
| 249 |
-
color: '#
|
|
|
|
| 250 |
}}
|
| 251 |
formatter={(value: any) => [formatCurrency(value), 'Ценность']}
|
| 252 |
labelFormatter={(value) => {
|
|
@@ -257,7 +263,7 @@ export default function DashboardPage() {
|
|
| 257 |
<Area
|
| 258 |
type="monotone"
|
| 259 |
dataKey="value"
|
| 260 |
-
stroke="#
|
| 261 |
strokeWidth={3}
|
| 262 |
fill="url(#colorValue)"
|
| 263 |
/>
|
|
@@ -306,22 +312,22 @@ export default function DashboardPage() {
|
|
| 306 |
initial={{ opacity: 0, y: 20 }}
|
| 307 |
animate={{ opacity: 1, y: 0 }}
|
| 308 |
transition={{ duration: 0.5, delay: i * 0.1 }}
|
| 309 |
-
className="bg-white
|
| 310 |
>
|
| 311 |
<div className="flex items-center justify-between mb-4">
|
| 312 |
-
<div className={`w-10 h-10 rounded-xl flex items-center justify-center bg-${kpi.color}-
|
| 313 |
-
<kpi.icon className={`w-5 h-5 text-${kpi.color}-
|
| 314 |
</div>
|
| 315 |
-
<div className={`px-2 py-1 rounded-full bg-${kpi.color}-
|
| 316 |
-
<span className={`text-${kpi.color}-
|
| 317 |
{kpi.title === "Конверсия" && <ArrowUp className="w-3 h-3" />}
|
| 318 |
{kpi.trend}
|
| 319 |
</span>
|
| 320 |
</div>
|
| 321 |
</div>
|
| 322 |
-
<p className="text-slate-
|
| 323 |
-
<h3 className="text-3xl font-bold text-
|
| 324 |
-
<p className="text-xs text-slate-
|
| 325 |
</motion.div>
|
| 326 |
))}
|
| 327 |
|
|
@@ -330,13 +336,13 @@ export default function DashboardPage() {
|
|
| 330 |
initial={{ opacity: 0, y: 20 }}
|
| 331 |
animate={{ opacity: 1, y: 0 }}
|
| 332 |
transition={{ duration: 0.5, delay: 0.2 }}
|
| 333 |
-
className="lg:col-span-2 bg-white
|
| 334 |
>
|
| 335 |
<div className="flex items-center gap-3 mb-6">
|
| 336 |
-
<div className="w-8 h-8 rounded-lg bg-orange-
|
| 337 |
-
<Target className="w-4 h-4 text-orange-
|
| 338 |
</div>
|
| 339 |
-
<h3 className="text-lg font-bold text-
|
| 340 |
</div>
|
| 341 |
<div className="h-64">
|
| 342 |
<ResponsiveContainer width="100%" height="100%">
|
|
@@ -350,27 +356,28 @@ export default function DashboardPage() {
|
|
| 350 |
<stop offset="100%" stopColor="#4f46e5" />
|
| 351 |
</linearGradient>
|
| 352 |
</defs>
|
| 353 |
-
<CartesianGrid strokeDasharray="3 3" stroke="#
|
| 354 |
<XAxis
|
| 355 |
dataKey="stage"
|
| 356 |
-
tick={{ fontSize: 12, fill: '#
|
| 357 |
-
stroke="#
|
| 358 |
axisLine={false}
|
| 359 |
tickLine={false}
|
| 360 |
/>
|
| 361 |
<YAxis
|
| 362 |
-
tick={{ fontSize: 12, fill: '#
|
| 363 |
-
stroke="#
|
| 364 |
axisLine={false}
|
| 365 |
tickLine={false}
|
| 366 |
/>
|
| 367 |
<Tooltip
|
| 368 |
-
cursor={{ fill: 'rgba(
|
| 369 |
contentStyle={{
|
| 370 |
-
backgroundColor: '#
|
| 371 |
-
border: '1px solid
|
| 372 |
borderRadius: '12px',
|
| 373 |
-
color: '#
|
|
|
|
| 374 |
}}
|
| 375 |
formatter={(value: any) => [value, 'Лиды']}
|
| 376 |
/>
|
|
@@ -390,13 +397,13 @@ export default function DashboardPage() {
|
|
| 390 |
initial={{ opacity: 0, y: 20 }}
|
| 391 |
animate={{ opacity: 1, y: 0 }}
|
| 392 |
transition={{ duration: 0.5, delay: 0.3 }}
|
| 393 |
-
className="lg:col-span-2 bg-white
|
| 394 |
>
|
| 395 |
<div className="flex items-center gap-3 mb-6">
|
| 396 |
-
<div className="w-8 h-8 rounded-lg bg-indigo-
|
| 397 |
-
<Users className="w-4 h-4 text-indigo-
|
| 398 |
</div>
|
| 399 |
-
<h3 className="text-lg font-bold text-
|
| 400 |
</div>
|
| 401 |
<div className="h-64">
|
| 402 |
<ResponsiveContainer width="100%" height="100%">
|
|
@@ -423,10 +430,11 @@ export default function DashboardPage() {
|
|
| 423 |
</Pie>
|
| 424 |
<Tooltip
|
| 425 |
contentStyle={{
|
| 426 |
-
backgroundColor: '#
|
| 427 |
-
border: '1px solid
|
| 428 |
borderRadius: '12px',
|
| 429 |
-
color: '#
|
|
|
|
| 430 |
}}
|
| 431 |
/>
|
| 432 |
<Legend
|
|
@@ -437,7 +445,7 @@ export default function DashboardPage() {
|
|
| 437 |
formatter={(value, entry: any) => {
|
| 438 |
const item = entry.payload
|
| 439 |
const russianName = PSYCHOTYPE_RUSSIAN[item.psychotype] || item.psychotype
|
| 440 |
-
return <span className="text-slate-
|
| 441 |
}}
|
| 442 |
/>
|
| 443 |
</PieChart>
|
|
@@ -450,29 +458,31 @@ export default function DashboardPage() {
|
|
| 450 |
initial={{ opacity: 0, y: 20 }}
|
| 451 |
animate={{ opacity: 1, y: 0 }}
|
| 452 |
transition={{ duration: 0.5, delay: 0.4 }}
|
| 453 |
-
className="bg-white
|
| 454 |
>
|
| 455 |
-
<h3 className="text-sm font-
|
| 456 |
<div className="space-y-6">
|
| 457 |
{[
|
| 458 |
-
{ label: "Горячие", count: data.metrics.hot_leads, color: "red", icon:
|
| 459 |
-
{ label: "Тёплые", count: data.metrics.warm_leads, color: "orange", icon:
|
| 460 |
-
{ label: "Холодные", count: data.metrics.cold_leads, color: "blue", icon:
|
| 461 |
].map((item, i) => (
|
| 462 |
<div key={i}>
|
| 463 |
<div className="flex items-center justify-between mb-2">
|
| 464 |
<div className="flex items-center gap-2">
|
| 465 |
-
<
|
| 466 |
-
|
|
|
|
|
|
|
| 467 |
</div>
|
| 468 |
-
<span className={`text-xl font-bold text-${item.color}-
|
| 469 |
</div>
|
| 470 |
-
<div className="w-full bg-
|
| 471 |
<motion.div
|
| 472 |
initial={{ width: 0 }}
|
| 473 |
animate={{ width: `${(item.count / data.metrics.total_leads * 100) || 0}%` }}
|
| 474 |
transition={{ duration: 1, delay: 0.5 + i * 0.1 }}
|
| 475 |
-
className={`bg-${item.color}-500 h-full rounded-full shadow-
|
| 476 |
/>
|
| 477 |
</div>
|
| 478 |
</div>
|
|
@@ -485,13 +495,13 @@ export default function DashboardPage() {
|
|
| 485 |
initial={{ opacity: 0, y: 20 }}
|
| 486 |
animate={{ opacity: 1, y: 0 }}
|
| 487 |
transition={{ duration: 0.5, delay: 0.5 }}
|
| 488 |
-
className="bg-white
|
| 489 |
>
|
| 490 |
<div className="flex items-center gap-3 mb-6">
|
| 491 |
-
<div className="w-8 h-8 rounded-lg bg-rose-
|
| 492 |
-
<AlertCircle className="w-4 h-4 text-rose-
|
| 493 |
</div>
|
| 494 |
-
<h3 className="text-lg font-bold text-
|
| 495 |
</div>
|
| 496 |
|
| 497 |
{data.top_objections.length > 0 ? (
|
|
@@ -499,14 +509,14 @@ export default function DashboardPage() {
|
|
| 499 |
{data.top_objections.slice(0, 5).map((objection, index) => (
|
| 500 |
<div key={index}>
|
| 501 |
<div className="flex items-center justify-between mb-2">
|
| 502 |
-
<p className="text-xs text-slate-
|
| 503 |
{objection.objection}
|
| 504 |
</p>
|
| 505 |
-
<span className="text-xs font-bold text-
|
| 506 |
{objection.percentage.toFixed(0)}%
|
| 507 |
</span>
|
| 508 |
</div>
|
| 509 |
-
<div className="w-full bg-
|
| 510 |
<motion.div
|
| 511 |
initial={{ width: 0 }}
|
| 512 |
animate={{ width: `${objection.percentage}%` }}
|
|
@@ -518,7 +528,7 @@ export default function DashboardPage() {
|
|
| 518 |
))}
|
| 519 |
</div>
|
| 520 |
) : (
|
| 521 |
-
<div className="h-full flex flex-col items-center justify-center text-slate-
|
| 522 |
<p>Нет данных</p>
|
| 523 |
</div>
|
| 524 |
)}
|
|
|
|
| 8 |
} from 'recharts'
|
| 9 |
import {
|
| 10 |
TrendingUp, Users, Clock, DollarSign, Target, Zap,
|
| 11 |
+
AlertCircle, Loader2, ArrowUp, MessageSquare, Activity,
|
| 12 |
+
Flame, Snowflake
|
| 13 |
} from 'lucide-react'
|
| 14 |
import { motion } from 'framer-motion'
|
| 15 |
|
|
|
|
| 56 |
lead_value_over_time: LeadValueOverTime[]
|
| 57 |
}
|
| 58 |
|
| 59 |
+
// DISC Colors (Light mode friendly)
|
| 60 |
const DISC_COLORS = {
|
| 61 |
+
'Dominant': '#EF4444', // Red-500
|
| 62 |
+
'Influential': '#F59E0B', // Amber-500
|
| 63 |
+
'Steady': '#10B981', // Emerald-500
|
| 64 |
+
'Conscientious': '#3B82F6', // Blue-500
|
| 65 |
'Unknown': '#9CA3AF' // Gray-400
|
| 66 |
}
|
| 67 |
|
|
|
|
| 138 |
|
| 139 |
if (authLoading || loading) {
|
| 140 |
return (
|
| 141 |
+
<div className="min-h-screen flex items-center justify-center bg-slate-50">
|
| 142 |
<div className="text-center">
|
| 143 |
+
<Loader2 className="w-12 h-12 animate-spin text-indigo-600 mx-auto mb-4" />
|
| 144 |
+
<p className="text-slate-500 font-medium">Загрузка аналитики...</p>
|
| 145 |
</div>
|
| 146 |
</div>
|
| 147 |
)
|
|
|
|
| 149 |
|
| 150 |
if (!user || error) {
|
| 151 |
return (
|
| 152 |
+
<div className="min-h-screen flex items-center justify-center bg-slate-50">
|
| 153 |
+
<div className="text-center max-w-md p-8 bg-white rounded-2xl border border-slate-200 shadow-xl">
|
| 154 |
<AlertCircle className="w-16 h-16 text-red-500 mx-auto mb-4" />
|
| 155 |
+
<h2 className="text-xl font-bold text-slate-900 mb-2">Ошибка загрузки</h2>
|
| 156 |
+
<p className="text-slate-500 mb-6">{error || 'Пользователь не авторизован'}</p>
|
| 157 |
<button
|
| 158 |
onClick={() => window.location.reload()}
|
| 159 |
+
className="px-6 py-2 bg-indigo-600 text-white rounded-xl hover:bg-indigo-700 transition-colors shadow-lg shadow-indigo-500/20"
|
| 160 |
>
|
| 161 |
Обновить страницу
|
| 162 |
</button>
|
|
|
|
| 183 |
}
|
| 184 |
|
| 185 |
return (
|
| 186 |
+
<div className="min-h-screen bg-slate-50 font-['Inter'] relative overflow-hidden p-4 md:p-8">
|
| 187 |
+
{/* Background Effects - Subtle for Light Mode */}
|
| 188 |
+
<div className="absolute top-0 left-0 w-full h-full overflow-hidden pointer-events-none z-0">
|
| 189 |
+
<div className="absolute -top-[20%] -left-[20%] w-[140%] h-[50%] bg-indigo-100/40 blur-[100px] rounded-full"></div>
|
| 190 |
+
<div className="absolute top-[20%] right-[10%] w-[40%] h-[40%] bg-blue-100/40 blur-[100px] rounded-full"></div>
|
| 191 |
+
</div>
|
| 192 |
|
| 193 |
<div className="max-w-7xl mx-auto relative z-10">
|
| 194 |
{/* Header */}
|
| 195 |
<div className="mb-10">
|
| 196 |
+
<h1 className="text-3xl font-bold text-slate-900 mb-2 flex items-center gap-3">
|
| 197 |
+
<div className="p-2 bg-indigo-600 rounded-xl shadow-lg shadow-indigo-500/20">
|
| 198 |
+
<Activity className="w-6 h-6 text-white" />
|
| 199 |
+
</div>
|
| 200 |
Аналитика Продаж
|
| 201 |
</h1>
|
| 202 |
+
<p className="text-slate-500">Обзор эффективности вашего AI-отдела продаж</p>
|
| 203 |
</div>
|
| 204 |
|
| 205 |
{/* Bento Grid */}
|
|
|
|
| 210 |
initial={{ opacity: 0, y: 20 }}
|
| 211 |
animate={{ opacity: 1, y: 0 }}
|
| 212 |
transition={{ duration: 0.5 }}
|
| 213 |
+
className="lg:col-span-2 relative overflow-hidden rounded-3xl border border-slate-200 bg-white p-6 shadow-sm hover:shadow-md transition-shadow"
|
| 214 |
>
|
| 215 |
+
<div className="absolute top-0 right-0 p-8 opacity-5">
|
| 216 |
+
<DollarSign className="w-32 h-32 text-indigo-600 -rotate-12" />
|
| 217 |
</div>
|
| 218 |
|
| 219 |
<div className="relative z-10 flex items-center justify-between mb-6">
|
| 220 |
<div>
|
| 221 |
+
<p className="text-indigo-600 text-sm font-bold uppercase tracking-wide mb-1">Объем Пайплайна</p>
|
| 222 |
+
<h2 className="text-4xl font-bold text-slate-900">{formatCurrency(data.metrics.pipeline_value)}</h2>
|
| 223 |
+
<p className="text-slate-500 text-xs mt-1">Потенциальная выручка</p>
|
| 224 |
</div>
|
| 225 |
+
<div className="w-12 h-12 bg-indigo-50 rounded-xl flex items-center justify-center border border-indigo-100">
|
| 226 |
+
<DollarSign className="w-6 h-6 text-indigo-600" />
|
| 227 |
</div>
|
| 228 |
</div>
|
| 229 |
|
|
|
|
| 232 |
<AreaChart data={data.lead_value_over_time}>
|
| 233 |
<defs>
|
| 234 |
<linearGradient id="colorValue" x1="0" y1="0" x2="0" y2="1">
|
| 235 |
+
<stop offset="5%" stopColor="#4f46e5" stopOpacity={0.2} />
|
| 236 |
+
<stop offset="95%" stopColor="#4f46e5" stopOpacity={0} />
|
| 237 |
</linearGradient>
|
| 238 |
</defs>
|
| 239 |
<XAxis
|
| 240 |
dataKey="date"
|
| 241 |
+
stroke="#cbd5e1"
|
| 242 |
+
tick={{ fontSize: 12, fill: '#64748b' }}
|
| 243 |
tickFormatter={(value) => {
|
| 244 |
const date = new Date(value)
|
| 245 |
return `${date.getDate()}/${date.getMonth() + 1}`
|
| 246 |
}}
|
| 247 |
/>
|
| 248 |
+
<YAxis stroke="#cbd5e1" tick={{ fontSize: 12, fill: '#64748b' }} />
|
| 249 |
<Tooltip
|
| 250 |
contentStyle={{
|
| 251 |
+
backgroundColor: '#fff',
|
| 252 |
+
border: '1px solid #e2e8f0',
|
| 253 |
borderRadius: '12px',
|
| 254 |
+
color: '#0f172a',
|
| 255 |
+
boxShadow: '0 4px 6px -1px rgb(0 0 0 / 0.1)'
|
| 256 |
}}
|
| 257 |
formatter={(value: any) => [formatCurrency(value), 'Ценность']}
|
| 258 |
labelFormatter={(value) => {
|
|
|
|
| 263 |
<Area
|
| 264 |
type="monotone"
|
| 265 |
dataKey="value"
|
| 266 |
+
stroke="#4f46e5"
|
| 267 |
strokeWidth={3}
|
| 268 |
fill="url(#colorValue)"
|
| 269 |
/>
|
|
|
|
| 312 |
initial={{ opacity: 0, y: 20 }}
|
| 313 |
animate={{ opacity: 1, y: 0 }}
|
| 314 |
transition={{ duration: 0.5, delay: i * 0.1 }}
|
| 315 |
+
className="bg-white border border-slate-200 rounded-3xl p-6 shadow-sm hover:shadow-md transition-all hover:-translate-y-1"
|
| 316 |
>
|
| 317 |
<div className="flex items-center justify-between mb-4">
|
| 318 |
+
<div className={`w-10 h-10 rounded-xl flex items-center justify-center bg-${kpi.color}-50 border border-${kpi.color}-100`}>
|
| 319 |
+
<kpi.icon className={`w-5 h-5 text-${kpi.color}-600`} />
|
| 320 |
</div>
|
| 321 |
+
<div className={`px-2 py-1 rounded-full bg-${kpi.color}-50 border border-${kpi.color}-100`}>
|
| 322 |
+
<span className={`text-${kpi.color}-600 text-xs font-bold flex items-center gap-1`}>
|
| 323 |
{kpi.title === "Конверсия" && <ArrowUp className="w-3 h-3" />}
|
| 324 |
{kpi.trend}
|
| 325 |
</span>
|
| 326 |
</div>
|
| 327 |
</div>
|
| 328 |
+
<p className="text-slate-500 text-sm font-medium mb-1">{kpi.title}</p>
|
| 329 |
+
<h3 className="text-3xl font-bold text-slate-900">{kpi.value}</h3>
|
| 330 |
+
<p className="text-xs text-slate-400 mt-2">{kpi.sub}</p>
|
| 331 |
</motion.div>
|
| 332 |
))}
|
| 333 |
|
|
|
|
| 336 |
initial={{ opacity: 0, y: 20 }}
|
| 337 |
animate={{ opacity: 1, y: 0 }}
|
| 338 |
transition={{ duration: 0.5, delay: 0.2 }}
|
| 339 |
+
className="lg:col-span-2 bg-white border border-slate-200 rounded-3xl p-6 shadow-sm"
|
| 340 |
>
|
| 341 |
<div className="flex items-center gap-3 mb-6">
|
| 342 |
+
<div className="w-8 h-8 rounded-lg bg-orange-50 flex items-center justify-center border border-orange-100">
|
| 343 |
+
<Target className="w-4 h-4 text-orange-600" />
|
| 344 |
</div>
|
| 345 |
+
<h3 className="text-lg font-bold text-slate-900">Воронка Продаж</h3>
|
| 346 |
</div>
|
| 347 |
<div className="h-64">
|
| 348 |
<ResponsiveContainer width="100%" height="100%">
|
|
|
|
| 356 |
<stop offset="100%" stopColor="#4f46e5" />
|
| 357 |
</linearGradient>
|
| 358 |
</defs>
|
| 359 |
+
<CartesianGrid strokeDasharray="3 3" stroke="#e2e8f0" vertical={false} />
|
| 360 |
<XAxis
|
| 361 |
dataKey="stage"
|
| 362 |
+
tick={{ fontSize: 12, fill: '#64748b' }}
|
| 363 |
+
stroke="#cbd5e1"
|
| 364 |
axisLine={false}
|
| 365 |
tickLine={false}
|
| 366 |
/>
|
| 367 |
<YAxis
|
| 368 |
+
tick={{ fontSize: 12, fill: '#64748b' }}
|
| 369 |
+
stroke="#cbd5e1"
|
| 370 |
axisLine={false}
|
| 371 |
tickLine={false}
|
| 372 |
/>
|
| 373 |
<Tooltip
|
| 374 |
+
cursor={{ fill: 'rgba(0,0,0,0.05)' }}
|
| 375 |
contentStyle={{
|
| 376 |
+
backgroundColor: '#fff',
|
| 377 |
+
border: '1px solid #e2e8f0',
|
| 378 |
borderRadius: '12px',
|
| 379 |
+
color: '#0f172a',
|
| 380 |
+
boxShadow: '0 4px 6px -1px rgb(0 0 0 / 0.1)'
|
| 381 |
}}
|
| 382 |
formatter={(value: any) => [value, 'Лиды']}
|
| 383 |
/>
|
|
|
|
| 397 |
initial={{ opacity: 0, y: 20 }}
|
| 398 |
animate={{ opacity: 1, y: 0 }}
|
| 399 |
transition={{ duration: 0.5, delay: 0.3 }}
|
| 400 |
+
className="lg:col-span-2 bg-white border border-slate-200 rounded-3xl p-6 shadow-sm"
|
| 401 |
>
|
| 402 |
<div className="flex items-center gap-3 mb-6">
|
| 403 |
+
<div className="w-8 h-8 rounded-lg bg-indigo-50 flex items-center justify-center border border-indigo-100">
|
| 404 |
+
<Users className="w-4 h-4 text-indigo-600" />
|
| 405 |
</div>
|
| 406 |
+
<h3 className="text-lg font-bold text-slate-900">Психотипы (DISC)</h3>
|
| 407 |
</div>
|
| 408 |
<div className="h-64">
|
| 409 |
<ResponsiveContainer width="100%" height="100%">
|
|
|
|
| 430 |
</Pie>
|
| 431 |
<Tooltip
|
| 432 |
contentStyle={{
|
| 433 |
+
backgroundColor: '#fff',
|
| 434 |
+
border: '1px solid #e2e8f0',
|
| 435 |
borderRadius: '12px',
|
| 436 |
+
color: '#0f172a',
|
| 437 |
+
boxShadow: '0 4px 6px -1px rgb(0 0 0 / 0.1)'
|
| 438 |
}}
|
| 439 |
/>
|
| 440 |
<Legend
|
|
|
|
| 445 |
formatter={(value, entry: any) => {
|
| 446 |
const item = entry.payload
|
| 447 |
const russianName = PSYCHOTYPE_RUSSIAN[item.psychotype] || item.psychotype
|
| 448 |
+
return <span className="text-slate-600 ml-2">{russianName}</span>
|
| 449 |
}}
|
| 450 |
/>
|
| 451 |
</PieChart>
|
|
|
|
| 458 |
initial={{ opacity: 0, y: 20 }}
|
| 459 |
animate={{ opacity: 1, y: 0 }}
|
| 460 |
transition={{ duration: 0.5, delay: 0.4 }}
|
| 461 |
+
className="bg-white border border-slate-200 rounded-3xl p-6 shadow-sm"
|
| 462 |
>
|
| 463 |
+
<h3 className="text-sm font-bold text-slate-500 uppercase tracking-wider mb-6">Температура Лидов</h3>
|
| 464 |
<div className="space-y-6">
|
| 465 |
{[
|
| 466 |
+
{ label: "Горячие", count: data.metrics.hot_leads, color: "red", icon: Flame },
|
| 467 |
+
{ label: "Тёплые", count: data.metrics.warm_leads, color: "orange", icon: Zap },
|
| 468 |
+
{ label: "Холодные", count: data.metrics.cold_leads, color: "blue", icon: Snowflake }
|
| 469 |
].map((item, i) => (
|
| 470 |
<div key={i}>
|
| 471 |
<div className="flex items-center justify-between mb-2">
|
| 472 |
<div className="flex items-center gap-2">
|
| 473 |
+
<div className={`p-1.5 rounded-lg bg-${item.color}-50`}>
|
| 474 |
+
<item.icon className={`w-4 h-4 text-${item.color}-500`} />
|
| 475 |
+
</div>
|
| 476 |
+
<span className="text-slate-700 text-sm font-medium">{item.label}</span>
|
| 477 |
</div>
|
| 478 |
+
<span className={`text-xl font-bold text-${item.color}-600`}>{item.count}</span>
|
| 479 |
</div>
|
| 480 |
+
<div className="w-full bg-slate-100 rounded-full h-1.5 overflow-hidden">
|
| 481 |
<motion.div
|
| 482 |
initial={{ width: 0 }}
|
| 483 |
animate={{ width: `${(item.count / data.metrics.total_leads * 100) || 0}%` }}
|
| 484 |
transition={{ duration: 1, delay: 0.5 + i * 0.1 }}
|
| 485 |
+
className={`bg-${item.color}-500 h-full rounded-full shadow-sm`}
|
| 486 |
/>
|
| 487 |
</div>
|
| 488 |
</div>
|
|
|
|
| 495 |
initial={{ opacity: 0, y: 20 }}
|
| 496 |
animate={{ opacity: 1, y: 0 }}
|
| 497 |
transition={{ duration: 0.5, delay: 0.5 }}
|
| 498 |
+
className="bg-white border border-slate-200 rounded-3xl p-6 shadow-sm"
|
| 499 |
>
|
| 500 |
<div className="flex items-center gap-3 mb-6">
|
| 501 |
+
<div className="w-8 h-8 rounded-lg bg-rose-50 flex items-center justify-center border border-rose-100">
|
| 502 |
+
<AlertCircle className="w-4 h-4 text-rose-500" />
|
| 503 |
</div>
|
| 504 |
+
<h3 className="text-lg font-bold text-slate-900">Топ Возражений</h3>
|
| 505 |
</div>
|
| 506 |
|
| 507 |
{data.top_objections.length > 0 ? (
|
|
|
|
| 509 |
{data.top_objections.slice(0, 5).map((objection, index) => (
|
| 510 |
<div key={index}>
|
| 511 |
<div className="flex items-center justify-between mb-2">
|
| 512 |
+
<p className="text-xs text-slate-600 font-medium truncate flex-1 pr-4">
|
| 513 |
{objection.objection}
|
| 514 |
</p>
|
| 515 |
+
<span className="text-xs font-bold text-slate-700 bg-slate-100 px-2 py-0.5 rounded-full">
|
| 516 |
{objection.percentage.toFixed(0)}%
|
| 517 |
</span>
|
| 518 |
</div>
|
| 519 |
+
<div className="w-full bg-slate-100 rounded-full h-1.5 overflow-hidden">
|
| 520 |
<motion.div
|
| 521 |
initial={{ width: 0 }}
|
| 522 |
animate={{ width: `${objection.percentage}%` }}
|
|
|
|
| 528 |
))}
|
| 529 |
</div>
|
| 530 |
) : (
|
| 531 |
+
<div className="h-full flex flex-col items-center justify-center text-slate-400">
|
| 532 |
<p>Нет данных</p>
|
| 533 |
</div>
|
| 534 |
)}
|
frontend/app/partners/page.tsx
CHANGED
|
@@ -26,11 +26,11 @@ export default function PartnersPage() {
|
|
| 26 |
const [partnerData, setPartnerData] = useState<any>(null)
|
| 27 |
const [isLoadingStatus, setIsLoadingStatus] = useState(true)
|
| 28 |
const [isPurchasing, setIsPurchasing] = useState(false)
|
| 29 |
-
|
| 30 |
// Fetch franchise status on mount
|
| 31 |
useEffect(() => {
|
| 32 |
if (!user) return
|
| 33 |
-
|
| 34 |
const fetchStatus = async () => {
|
| 35 |
try {
|
| 36 |
const data = await billingApi.getFranchiseStatus()
|
|
@@ -42,50 +42,50 @@ export default function PartnersPage() {
|
|
| 42 |
setIsLoadingStatus(false)
|
| 43 |
}
|
| 44 |
}
|
| 45 |
-
|
| 46 |
fetchStatus()
|
| 47 |
}, [user])
|
| 48 |
-
|
| 49 |
const buyMutation = useMutation({
|
| 50 |
mutationFn: billingApi.buyFranchise,
|
| 51 |
onSuccess: () => {
|
| 52 |
-
alert('
|
| 53 |
window.location.reload()
|
| 54 |
},
|
| 55 |
onError: (error: any) => {
|
| 56 |
-
alert(`
|
| 57 |
}
|
| 58 |
})
|
| 59 |
-
|
| 60 |
const handlePurchaseFranchise = async () => {
|
| 61 |
if (!confirm('Подтвердите покупку франшизы за $500')) {
|
| 62 |
return
|
| 63 |
}
|
| 64 |
-
|
| 65 |
setIsPurchasing(true)
|
| 66 |
-
|
| 67 |
try {
|
| 68 |
const data = await billingApi.buyFranchise()
|
| 69 |
-
|
| 70 |
if (data.success) {
|
| 71 |
-
alert(`
|
| 72 |
setFranchiseStatus('ACTIVE')
|
| 73 |
window.location.reload()
|
| 74 |
} else {
|
| 75 |
-
alert(`
|
| 76 |
}
|
| 77 |
} catch (error: any) {
|
| 78 |
console.error('Purchase error:', error)
|
| 79 |
-
alert(`
|
| 80 |
} finally {
|
| 81 |
setIsPurchasing(false)
|
| 82 |
}
|
| 83 |
}
|
| 84 |
-
|
| 85 |
-
const referralLink = partnerData?.referral_code
|
| 86 |
? `http://microfunnel.ai?ref=${partnerData.referral_code}`
|
| 87 |
: `http://microfunnel.ai?ref=${MOCK_PARTNER_DATA.referral_code}`
|
| 88 |
-
|
| 89 |
const handleCopy = () => {
|
| 90 |
navigator.clipboard.writeText(referralLink)
|
| 91 |
setCopied(true)
|
|
@@ -101,7 +101,7 @@ export default function PartnersPage() {
|
|
| 101 |
</div>
|
| 102 |
)
|
| 103 |
}
|
| 104 |
-
|
| 105 |
// State A: LOCKED (PENDING) - Show Paywall
|
| 106 |
if (franchiseStatus === 'PENDING') {
|
| 107 |
return (
|
|
@@ -122,7 +122,7 @@ export default function PartnersPage() {
|
|
| 122 |
<p className="text-xl text-indigo-100 font-medium">Получите готовый бизнес под ключ</p>
|
| 123 |
</div>
|
| 124 |
</div>
|
| 125 |
-
|
| 126 |
{/* Content */}
|
| 127 |
<div className="p-8">
|
| 128 |
{/* Price */}
|
|
@@ -133,7 +133,7 @@ export default function PartnersPage() {
|
|
| 133 |
</div>
|
| 134 |
<p className="text-sm text-slate-500 mt-2">Без ежемесячных платежей</p>
|
| 135 |
</div>
|
| 136 |
-
|
| 137 |
{/* Benefits */}
|
| 138 |
<div className="space-y-4 mb-8">
|
| 139 |
<div className="flex items-start gap-3">
|
|
@@ -145,7 +145,7 @@ export default function PartnersPage() {
|
|
| 145 |
<p className="text-sm text-slate-600">$100/мес с каждого клиента (тариф Start $199)</p>
|
| 146 |
</div>
|
| 147 |
</div>
|
| 148 |
-
|
| 149 |
<div className="flex items-start gap-3">
|
| 150 |
<div className="w-6 h-6 bg-emerald-100 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5">
|
| 151 |
<Check className="w-4 h-4 text-emerald-600" />
|
|
@@ -155,7 +155,7 @@ export default function PartnersPage() {
|
|
| 155 |
<p className="text-sm text-slate-600">Автоматическое отслеживание клиентов</p>
|
| 156 |
</div>
|
| 157 |
</div>
|
| 158 |
-
|
| 159 |
<div className="flex items-start gap-3">
|
| 160 |
<div className="w-6 h-6 bg-emerald-100 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5">
|
| 161 |
<Check className="w-4 h-4 text-emerald-600" />
|
|
@@ -165,7 +165,7 @@ export default function PartnersPage() {
|
|
| 165 |
<p className="text-sm text-slate-600">Аналитика, баланс, статистика клиентов</p>
|
| 166 |
</div>
|
| 167 |
</div>
|
| 168 |
-
|
| 169 |
<div className="flex items-start gap-3">
|
| 170 |
<div className="w-6 h-6 bg-emerald-100 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5">
|
| 171 |
<Check className="w-4 h-4 text-emerald-600" />
|
|
@@ -175,7 +175,7 @@ export default function PartnersPage() {
|
|
| 175 |
<p className="text-sm text-slate-600">Получайте комиссию каждый месяц автоматически</p>
|
| 176 |
</div>
|
| 177 |
</div>
|
| 178 |
-
|
| 179 |
<div className="flex items-start gap-3">
|
| 180 |
<div className="w-6 h-6 bg-emerald-100 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5">
|
| 181 |
<Check className="w-4 h-4 text-emerald-600" />
|
|
@@ -186,7 +186,7 @@ export default function PartnersPage() {
|
|
| 186 |
</div>
|
| 187 |
</div>
|
| 188 |
</div>
|
| 189 |
-
|
| 190 |
{/* Revenue Projection */}
|
| 191 |
<div className="bg-gradient-to-br from-indigo-50 to-purple-50 rounded-2xl p-6 mb-8 border border-indigo-100">
|
| 192 |
<div className="flex items-center gap-2 mb-4">
|
|
@@ -208,7 +208,7 @@ export default function PartnersPage() {
|
|
| 208 |
</div>
|
| 209 |
</div>
|
| 210 |
</div>
|
| 211 |
-
|
| 212 |
{/* CTA Button */}
|
| 213 |
<button
|
| 214 |
onClick={handlePurchaseFranchise}
|
|
@@ -227,22 +227,22 @@ export default function PartnersPage() {
|
|
| 227 |
</>
|
| 228 |
)}
|
| 229 |
</button>
|
| 230 |
-
|
| 231 |
<p className="text-center text-xs text-slate-500 mt-4">
|
| 232 |
Безопасная оплата • Мгновенная активация
|
| 233 |
</p>
|
| 234 |
</div>
|
| 235 |
</div>
|
| 236 |
-
|
| 237 |
{/* Trust Badge */}
|
| 238 |
<div className="text-center mt-6 text-sm text-slate-600">
|
| 239 |
-
<p>
|
| 240 |
</div>
|
| 241 |
</div>
|
| 242 |
</div>
|
| 243 |
)
|
| 244 |
}
|
| 245 |
-
|
| 246 |
// BANNED state
|
| 247 |
if (franchiseStatus === 'BANNED') {
|
| 248 |
return (
|
|
@@ -259,7 +259,7 @@ export default function PartnersPage() {
|
|
| 259 |
</div>
|
| 260 |
)
|
| 261 |
}
|
| 262 |
-
|
| 263 |
// State B: UNLOCKED (ACTIVE) - Show existing dashboard
|
| 264 |
const displayData = partnerData || MOCK_PARTNER_DATA
|
| 265 |
|
|
@@ -335,7 +335,7 @@ export default function PartnersPage() {
|
|
| 335 |
<p className="text-slate-600 text-sm mb-4">
|
| 336 |
Поделитесь этой ссылкой с потенциальными клиентами. Вы будете получать 50% комиссии от всех их подписок.
|
| 337 |
</p>
|
| 338 |
-
|
| 339 |
{/* Code Snippet Style Input */}
|
| 340 |
<div className="relative">
|
| 341 |
<div className="flex items-center gap-2 bg-slate-900 rounded-xl p-4 border border-slate-800">
|
|
@@ -365,7 +365,7 @@ export default function PartnersPage() {
|
|
| 365 |
{/* Commission Breakdown */}
|
| 366 |
<div className="bg-white rounded-2xl border border-gray-200 shadow-sm p-6 mb-8">
|
| 367 |
<h2 className="text-lg font-bold text-slate-900 mb-4">Структура комиссии</h2>
|
| 368 |
-
|
| 369 |
<div className="space-y-3">
|
| 370 |
<div className="flex justify-between items-center p-4 bg-emerald-50 rounded-xl border border-emerald-100">
|
| 371 |
<div>
|
|
@@ -394,20 +394,20 @@ export default function PartnersPage() {
|
|
| 394 |
{/* Revenue Projection */}
|
| 395 |
<div className="bg-gradient-to-br from-indigo-600 to-purple-600 rounded-2xl shadow-lg p-8 text-white">
|
| 396 |
<h2 className="text-2xl font-bold mb-6">Прогноз дохода</h2>
|
| 397 |
-
|
| 398 |
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
| 399 |
<div className="bg-white/10 backdrop-blur rounded-xl p-4 border border-white/20">
|
| 400 |
<p className="text-indigo-100 text-xs mb-2 font-medium">10 клиентов</p>
|
| 401 |
<p className="text-3xl font-bold">$1,000/мес</p>
|
| 402 |
<p className="text-indigo-100 text-xs mt-2">Пассивный доход</p>
|
| 403 |
</div>
|
| 404 |
-
|
| 405 |
<div className="bg-white/10 backdrop-blur rounded-xl p-4 border border-white/20">
|
| 406 |
<p className="text-indigo-100 text-xs mb-2 font-medium">50 клиентов</p>
|
| 407 |
<p className="text-3xl font-bold">$5,000/мес</p>
|
| 408 |
<p className="text-indigo-100 text-xs mt-2">Этап масштабирования</p>
|
| 409 |
</div>
|
| 410 |
-
|
| 411 |
<div className="bg-white/10 backdrop-blur rounded-xl p-4 border border-white/20">
|
| 412 |
<p className="text-indigo-100 text-xs mb-2 font-medium">100 клиентов</p>
|
| 413 |
<p className="text-3xl font-bold">$10,000/мес</p>
|
|
@@ -417,7 +417,7 @@ export default function PartnersPage() {
|
|
| 417 |
|
| 418 |
<div className="mt-6 p-4 bg-white/10 backdrop-blur rounded-xl border border-white/20">
|
| 419 |
<p className="text-sm leading-relaxed">
|
| 420 |
-
|
| 421 |
вы зарабатываете <strong>${displayData.monthly_recurring?.toLocaleString() || '0'}/месяц</strong> повторяющегося дохода.
|
| 422 |
Добавьте еще {Math.max(0, 50 - (displayData.active_clients || 0))} клиентов для достижения уровня $5K/мес!
|
| 423 |
</p>
|
|
|
|
| 26 |
const [partnerData, setPartnerData] = useState<any>(null)
|
| 27 |
const [isLoadingStatus, setIsLoadingStatus] = useState(true)
|
| 28 |
const [isPurchasing, setIsPurchasing] = useState(false)
|
| 29 |
+
|
| 30 |
// Fetch franchise status on mount
|
| 31 |
useEffect(() => {
|
| 32 |
if (!user) return
|
| 33 |
+
|
| 34 |
const fetchStatus = async () => {
|
| 35 |
try {
|
| 36 |
const data = await billingApi.getFranchiseStatus()
|
|
|
|
| 42 |
setIsLoadingStatus(false)
|
| 43 |
}
|
| 44 |
}
|
| 45 |
+
|
| 46 |
fetchStatus()
|
| 47 |
}, [user])
|
| 48 |
+
|
| 49 |
const buyMutation = useMutation({
|
| 50 |
mutationFn: billingApi.buyFranchise,
|
| 51 |
onSuccess: () => {
|
| 52 |
+
alert('Поздравляем! Франшиза успешно приобретена!')
|
| 53 |
window.location.reload()
|
| 54 |
},
|
| 55 |
onError: (error: any) => {
|
| 56 |
+
alert(`Ошибка: ${error.response?.data?.detail || error.message}`)
|
| 57 |
}
|
| 58 |
})
|
| 59 |
+
|
| 60 |
const handlePurchaseFranchise = async () => {
|
| 61 |
if (!confirm('Подтвердите покупку франшизы за $500')) {
|
| 62 |
return
|
| 63 |
}
|
| 64 |
+
|
| 65 |
setIsPurchasing(true)
|
| 66 |
+
|
| 67 |
try {
|
| 68 |
const data = await billingApi.buyFranchise()
|
| 69 |
+
|
| 70 |
if (data.success) {
|
| 71 |
+
alert(`${data.message}`)
|
| 72 |
setFranchiseStatus('ACTIVE')
|
| 73 |
window.location.reload()
|
| 74 |
} else {
|
| 75 |
+
alert(`Ошибка: ${data.detail || 'Не удалось купить франшизу'}`)
|
| 76 |
}
|
| 77 |
} catch (error: any) {
|
| 78 |
console.error('Purchase error:', error)
|
| 79 |
+
alert(`${error.response?.data?.detail || 'Ошибка подключения к серверу'}`)
|
| 80 |
} finally {
|
| 81 |
setIsPurchasing(false)
|
| 82 |
}
|
| 83 |
}
|
| 84 |
+
|
| 85 |
+
const referralLink = partnerData?.referral_code
|
| 86 |
? `http://microfunnel.ai?ref=${partnerData.referral_code}`
|
| 87 |
: `http://microfunnel.ai?ref=${MOCK_PARTNER_DATA.referral_code}`
|
| 88 |
+
|
| 89 |
const handleCopy = () => {
|
| 90 |
navigator.clipboard.writeText(referralLink)
|
| 91 |
setCopied(true)
|
|
|
|
| 101 |
</div>
|
| 102 |
)
|
| 103 |
}
|
| 104 |
+
|
| 105 |
// State A: LOCKED (PENDING) - Show Paywall
|
| 106 |
if (franchiseStatus === 'PENDING') {
|
| 107 |
return (
|
|
|
|
| 122 |
<p className="text-xl text-indigo-100 font-medium">Получите готовый бизнес под ключ</p>
|
| 123 |
</div>
|
| 124 |
</div>
|
| 125 |
+
|
| 126 |
{/* Content */}
|
| 127 |
<div className="p-8">
|
| 128 |
{/* Price */}
|
|
|
|
| 133 |
</div>
|
| 134 |
<p className="text-sm text-slate-500 mt-2">Без ежемесячных платежей</p>
|
| 135 |
</div>
|
| 136 |
+
|
| 137 |
{/* Benefits */}
|
| 138 |
<div className="space-y-4 mb-8">
|
| 139 |
<div className="flex items-start gap-3">
|
|
|
|
| 145 |
<p className="text-sm text-slate-600">$100/мес с каждого клиента (тариф Start $199)</p>
|
| 146 |
</div>
|
| 147 |
</div>
|
| 148 |
+
|
| 149 |
<div className="flex items-start gap-3">
|
| 150 |
<div className="w-6 h-6 bg-emerald-100 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5">
|
| 151 |
<Check className="w-4 h-4 text-emerald-600" />
|
|
|
|
| 155 |
<p className="text-sm text-slate-600">Автоматическое отслеживание клиентов</p>
|
| 156 |
</div>
|
| 157 |
</div>
|
| 158 |
+
|
| 159 |
<div className="flex items-start gap-3">
|
| 160 |
<div className="w-6 h-6 bg-emerald-100 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5">
|
| 161 |
<Check className="w-4 h-4 text-emerald-600" />
|
|
|
|
| 165 |
<p className="text-sm text-slate-600">Аналитика, баланс, статистика клиентов</p>
|
| 166 |
</div>
|
| 167 |
</div>
|
| 168 |
+
|
| 169 |
<div className="flex items-start gap-3">
|
| 170 |
<div className="w-6 h-6 bg-emerald-100 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5">
|
| 171 |
<Check className="w-4 h-4 text-emerald-600" />
|
|
|
|
| 175 |
<p className="text-sm text-slate-600">Получайте комиссию каждый месяц автоматически</p>
|
| 176 |
</div>
|
| 177 |
</div>
|
| 178 |
+
|
| 179 |
<div className="flex items-start gap-3">
|
| 180 |
<div className="w-6 h-6 bg-emerald-100 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5">
|
| 181 |
<Check className="w-4 h-4 text-emerald-600" />
|
|
|
|
| 186 |
</div>
|
| 187 |
</div>
|
| 188 |
</div>
|
| 189 |
+
|
| 190 |
{/* Revenue Projection */}
|
| 191 |
<div className="bg-gradient-to-br from-indigo-50 to-purple-50 rounded-2xl p-6 mb-8 border border-indigo-100">
|
| 192 |
<div className="flex items-center gap-2 mb-4">
|
|
|
|
| 208 |
</div>
|
| 209 |
</div>
|
| 210 |
</div>
|
| 211 |
+
|
| 212 |
{/* CTA Button */}
|
| 213 |
<button
|
| 214 |
onClick={handlePurchaseFranchise}
|
|
|
|
| 227 |
</>
|
| 228 |
)}
|
| 229 |
</button>
|
| 230 |
+
|
| 231 |
<p className="text-center text-xs text-slate-500 mt-4">
|
| 232 |
Безопасная оплата • Мгновенная активация
|
| 233 |
</p>
|
| 234 |
</div>
|
| 235 |
</div>
|
| 236 |
+
|
| 237 |
{/* Trust Badge */}
|
| 238 |
<div className="text-center mt-6 text-sm text-slate-600">
|
| 239 |
+
<p>Защищенный платеж • Гарантия возврата 30 дней</p>
|
| 240 |
</div>
|
| 241 |
</div>
|
| 242 |
</div>
|
| 243 |
)
|
| 244 |
}
|
| 245 |
+
|
| 246 |
// BANNED state
|
| 247 |
if (franchiseStatus === 'BANNED') {
|
| 248 |
return (
|
|
|
|
| 259 |
</div>
|
| 260 |
)
|
| 261 |
}
|
| 262 |
+
|
| 263 |
// State B: UNLOCKED (ACTIVE) - Show existing dashboard
|
| 264 |
const displayData = partnerData || MOCK_PARTNER_DATA
|
| 265 |
|
|
|
|
| 335 |
<p className="text-slate-600 text-sm mb-4">
|
| 336 |
Поделитесь этой ссылкой с потенциальными клиентами. Вы будете получать 50% комиссии от всех их подписок.
|
| 337 |
</p>
|
| 338 |
+
|
| 339 |
{/* Code Snippet Style Input */}
|
| 340 |
<div className="relative">
|
| 341 |
<div className="flex items-center gap-2 bg-slate-900 rounded-xl p-4 border border-slate-800">
|
|
|
|
| 365 |
{/* Commission Breakdown */}
|
| 366 |
<div className="bg-white rounded-2xl border border-gray-200 shadow-sm p-6 mb-8">
|
| 367 |
<h2 className="text-lg font-bold text-slate-900 mb-4">Структура комиссии</h2>
|
| 368 |
+
|
| 369 |
<div className="space-y-3">
|
| 370 |
<div className="flex justify-between items-center p-4 bg-emerald-50 rounded-xl border border-emerald-100">
|
| 371 |
<div>
|
|
|
|
| 394 |
{/* Revenue Projection */}
|
| 395 |
<div className="bg-gradient-to-br from-indigo-600 to-purple-600 rounded-2xl shadow-lg p-8 text-white">
|
| 396 |
<h2 className="text-2xl font-bold mb-6">Прогноз дохода</h2>
|
| 397 |
+
|
| 398 |
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
| 399 |
<div className="bg-white/10 backdrop-blur rounded-xl p-4 border border-white/20">
|
| 400 |
<p className="text-indigo-100 text-xs mb-2 font-medium">10 клиентов</p>
|
| 401 |
<p className="text-3xl font-bold">$1,000/мес</p>
|
| 402 |
<p className="text-indigo-100 text-xs mt-2">Пассивный доход</p>
|
| 403 |
</div>
|
| 404 |
+
|
| 405 |
<div className="bg-white/10 backdrop-blur rounded-xl p-4 border border-white/20">
|
| 406 |
<p className="text-indigo-100 text-xs mb-2 font-medium">50 клиентов</p>
|
| 407 |
<p className="text-3xl font-bold">$5,000/мес</p>
|
| 408 |
<p className="text-indigo-100 text-xs mt-2">Этап масштабирования</p>
|
| 409 |
</div>
|
| 410 |
+
|
| 411 |
<div className="bg-white/10 backdrop-blur rounded-xl p-4 border border-white/20">
|
| 412 |
<p className="text-indigo-100 text-xs mb-2 font-medium">100 клиентов</p>
|
| 413 |
<p className="text-3xl font-bold">$10,000/мес</p>
|
|
|
|
| 417 |
|
| 418 |
<div className="mt-6 p-4 bg-white/10 backdrop-blur rounded-xl border border-white/20">
|
| 419 |
<p className="text-sm leading-relaxed">
|
| 420 |
+
<strong>Текущая траектория:</strong> С {displayData.active_clients || 0} активными клиентами,
|
| 421 |
вы зарабатываете <strong>${displayData.monthly_recurring?.toLocaleString() || '0'}/месяц</strong> повторяющегося дохода.
|
| 422 |
Добавьте еще {Math.max(0, 50 - (displayData.active_clients || 0))} клиентов для достижения уровня $5K/мес!
|
| 423 |
</p>
|
frontend/app/settings/brain/page_old.tsx
CHANGED
|
@@ -30,7 +30,7 @@ export default function BrainSettingsPage() {
|
|
| 30 |
const [loading, setLoading] = useState(true)
|
| 31 |
const [saving, setSaving] = useState(false)
|
| 32 |
const [newField, setNewField] = useState('')
|
| 33 |
-
|
| 34 |
const [settings, setSettings] = useState<AISettings>({
|
| 35 |
business_description: '',
|
| 36 |
selling_style: 'Consultative',
|
|
@@ -44,14 +44,14 @@ export default function BrainSettingsPage() {
|
|
| 44 |
|
| 45 |
const fetchSettings = async () => {
|
| 46 |
if (!user?.tenant_id) return
|
| 47 |
-
|
| 48 |
try {
|
| 49 |
const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/v1/tenants/${user.tenant_id}`, {
|
| 50 |
headers: {
|
| 51 |
'Authorization': `Bearer ${localStorage.getItem('access_token')}`
|
| 52 |
}
|
| 53 |
})
|
| 54 |
-
|
| 55 |
if (response.ok) {
|
| 56 |
const data = await response.json()
|
| 57 |
if (data.ai_settings) {
|
|
@@ -67,7 +67,7 @@ export default function BrainSettingsPage() {
|
|
| 67 |
|
| 68 |
const handleSave = async () => {
|
| 69 |
if (!user?.tenant_id) return
|
| 70 |
-
|
| 71 |
setSaving(true)
|
| 72 |
try {
|
| 73 |
const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/v1/tenants/${user.tenant_id}`, {
|
|
@@ -78,15 +78,15 @@ export default function BrainSettingsPage() {
|
|
| 78 |
},
|
| 79 |
body: JSON.stringify({ ai_settings: settings })
|
| 80 |
})
|
| 81 |
-
|
| 82 |
if (response.ok) {
|
| 83 |
-
alert('
|
| 84 |
} else {
|
| 85 |
-
alert('
|
| 86 |
}
|
| 87 |
} catch (error) {
|
| 88 |
console.error('Failed to save AI settings:', error)
|
| 89 |
-
alert('
|
| 90 |
} finally {
|
| 91 |
setSaving(false)
|
| 92 |
}
|
|
@@ -98,7 +98,7 @@ export default function BrainSettingsPage() {
|
|
| 98 |
alert('Это поле уже добавлено')
|
| 99 |
return
|
| 100 |
}
|
| 101 |
-
|
| 102 |
setSettings({
|
| 103 |
...settings,
|
| 104 |
custom_fields: [...settings.custom_fields, newField.trim()]
|
|
@@ -187,15 +187,13 @@ export default function BrainSettingsPage() {
|
|
| 187 |
<button
|
| 188 |
key={style.value}
|
| 189 |
onClick={() => setSettings({ ...settings, selling_style: style.value as any })}
|
| 190 |
-
className={`p-4 rounded-lg border-2 transition-all duration-200 text-left ${
|
| 191 |
-
settings.selling_style === style.value
|
| 192 |
? 'border-indigo-600 bg-indigo-50'
|
| 193 |
: 'border-gray-200 hover:border-indigo-300 bg-white'
|
| 194 |
-
|
| 195 |
>
|
| 196 |
-
<h3 className={`font-bold mb-1 ${
|
| 197 |
-
|
| 198 |
-
}`}>
|
| 199 |
{style.label}
|
| 200 |
</h3>
|
| 201 |
<p className="text-xs text-slate-600">{style.description}</p>
|
|
@@ -213,7 +211,7 @@ export default function BrainSettingsPage() {
|
|
| 213 |
<p className="text-sm text-slate-600 mb-4">
|
| 214 |
Укажите какую информацию AI должен собирать о клиентах в процессе разговора
|
| 215 |
</p>
|
| 216 |
-
|
| 217 |
{/* Existing Fields */}
|
| 218 |
<div className="flex flex-wrap gap-2 mb-4">
|
| 219 |
{settings.custom_fields.map((field) => (
|
|
@@ -250,9 +248,9 @@ export default function BrainSettingsPage() {
|
|
| 250 |
Добавить
|
| 251 |
</button>
|
| 252 |
</div>
|
| 253 |
-
|
| 254 |
<p className="text-xs text-slate-500 mt-3">
|
| 255 |
-
|
| 256 |
</p>
|
| 257 |
</div>
|
| 258 |
|
|
|
|
| 30 |
const [loading, setLoading] = useState(true)
|
| 31 |
const [saving, setSaving] = useState(false)
|
| 32 |
const [newField, setNewField] = useState('')
|
| 33 |
+
|
| 34 |
const [settings, setSettings] = useState<AISettings>({
|
| 35 |
business_description: '',
|
| 36 |
selling_style: 'Consultative',
|
|
|
|
| 44 |
|
| 45 |
const fetchSettings = async () => {
|
| 46 |
if (!user?.tenant_id) return
|
| 47 |
+
|
| 48 |
try {
|
| 49 |
const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/v1/tenants/${user.tenant_id}`, {
|
| 50 |
headers: {
|
| 51 |
'Authorization': `Bearer ${localStorage.getItem('access_token')}`
|
| 52 |
}
|
| 53 |
})
|
| 54 |
+
|
| 55 |
if (response.ok) {
|
| 56 |
const data = await response.json()
|
| 57 |
if (data.ai_settings) {
|
|
|
|
| 67 |
|
| 68 |
const handleSave = async () => {
|
| 69 |
if (!user?.tenant_id) return
|
| 70 |
+
|
| 71 |
setSaving(true)
|
| 72 |
try {
|
| 73 |
const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/v1/tenants/${user.tenant_id}`, {
|
|
|
|
| 78 |
},
|
| 79 |
body: JSON.stringify({ ai_settings: settings })
|
| 80 |
})
|
| 81 |
+
|
| 82 |
if (response.ok) {
|
| 83 |
+
alert('Настройки AI Brain сохранены!')
|
| 84 |
} else {
|
| 85 |
+
alert('Ошибка сохранения настроек')
|
| 86 |
}
|
| 87 |
} catch (error) {
|
| 88 |
console.error('Failed to save AI settings:', error)
|
| 89 |
+
alert('Ошибка сохранения настроек')
|
| 90 |
} finally {
|
| 91 |
setSaving(false)
|
| 92 |
}
|
|
|
|
| 98 |
alert('Это поле уже добавлено')
|
| 99 |
return
|
| 100 |
}
|
| 101 |
+
|
| 102 |
setSettings({
|
| 103 |
...settings,
|
| 104 |
custom_fields: [...settings.custom_fields, newField.trim()]
|
|
|
|
| 187 |
<button
|
| 188 |
key={style.value}
|
| 189 |
onClick={() => setSettings({ ...settings, selling_style: style.value as any })}
|
| 190 |
+
className={`p-4 rounded-lg border-2 transition-all duration-200 text-left ${settings.selling_style === style.value
|
|
|
|
| 191 |
? 'border-indigo-600 bg-indigo-50'
|
| 192 |
: 'border-gray-200 hover:border-indigo-300 bg-white'
|
| 193 |
+
}`}
|
| 194 |
>
|
| 195 |
+
<h3 className={`font-bold mb-1 ${settings.selling_style === style.value ? 'text-indigo-900' : 'text-slate-900'
|
| 196 |
+
}`}>
|
|
|
|
| 197 |
{style.label}
|
| 198 |
</h3>
|
| 199 |
<p className="text-xs text-slate-600">{style.description}</p>
|
|
|
|
| 211 |
<p className="text-sm text-slate-600 mb-4">
|
| 212 |
Укажите какую информацию AI должен собирать о клиентах в процессе разговора
|
| 213 |
</p>
|
| 214 |
+
|
| 215 |
{/* Existing Fields */}
|
| 216 |
<div className="flex flex-wrap gap-2 mb-4">
|
| 217 |
{settings.custom_fields.map((field) => (
|
|
|
|
| 248 |
Добавить
|
| 249 |
</button>
|
| 250 |
</div>
|
| 251 |
+
|
| 252 |
<p className="text-xs text-slate-500 mt-3">
|
| 253 |
+
AI будет естественно интегрировать эти вопросы в диалог, не делая его похожим на допрос
|
| 254 |
</p>
|
| 255 |
</div>
|
| 256 |
|
frontend/app/settings/crm/page.tsx
CHANGED
|
@@ -2,9 +2,10 @@
|
|
| 2 |
|
| 3 |
import { useEffect, useState } from 'react'
|
| 4 |
import { useAuth } from '@/contexts/AuthContext'
|
| 5 |
-
import {
|
| 6 |
-
Save, Loader2, AlertCircle, CheckCircle2, Plus, Trash2,
|
| 7 |
-
RefreshCw, Settings, Database, Zap, ChevronDown, Eye, EyeOff
|
|
|
|
| 8 |
} from 'lucide-react'
|
| 9 |
|
| 10 |
interface CRMIntegration {
|
|
@@ -24,13 +25,13 @@ interface CRMIntegration {
|
|
| 24 |
}
|
| 25 |
|
| 26 |
const CRM_TYPES = [
|
| 27 |
-
{ value: 'amocrm', label: 'amoCRM'
|
| 28 |
-
{ value: 'bitrix24', label: 'Bitrix24'
|
| 29 |
-
{ value: 'hubspot', label: 'HubSpot'
|
| 30 |
-
{ value: 'pipedrive', label: 'Pipedrive'
|
| 31 |
-
{ value: 'salesforce', label: 'Salesforce'
|
| 32 |
-
{ value: 'zoho', label: 'Zoho CRM'
|
| 33 |
-
{ value: 'custom_webhook', label: 'Custom Webhook'
|
| 34 |
]
|
| 35 |
|
| 36 |
const LEAD_STATUSES = [
|
|
@@ -49,7 +50,7 @@ export default function CRMSettingsPage() {
|
|
| 49 |
const [showAddForm, setShowAddForm] = useState(false)
|
| 50 |
const [successMessage, setSuccessMessage] = useState('')
|
| 51 |
const [errorMessage, setErrorMessage] = useState('')
|
| 52 |
-
const [showTokens, setShowTokens] = useState<{[key: string]: boolean}>({})
|
| 53 |
|
| 54 |
// New integration form
|
| 55 |
const [newIntegration, setNewIntegration] = useState({
|
|
@@ -196,7 +197,8 @@ export default function CRMSettingsPage() {
|
|
| 196 |
}
|
| 197 |
|
| 198 |
const getCRMIcon = (type: string) => {
|
| 199 |
-
|
|
|
|
| 200 |
}
|
| 201 |
|
| 202 |
const getCRMLabel = (type: string) => {
|
|
@@ -212,7 +214,7 @@ export default function CRMSettingsPage() {
|
|
| 212 |
}
|
| 213 |
|
| 214 |
return (
|
| 215 |
-
<div className="min-h-screen bg-
|
| 216 |
<div className="max-w-6xl mx-auto p-8">
|
| 217 |
{/* Header */}
|
| 218 |
<div className="mb-8">
|
|
@@ -228,7 +230,7 @@ export default function CRMSettingsPage() {
|
|
| 228 |
</div>
|
| 229 |
<button
|
| 230 |
onClick={() => setShowAddForm(!showAddForm)}
|
| 231 |
-
className="flex items-center gap-2 px-4 py-2 bg-indigo-600 text-white rounded-
|
| 232 |
>
|
| 233 |
<Plus className="w-4 h-4" />
|
| 234 |
Добавить интеграцию
|
|
@@ -238,14 +240,14 @@ export default function CRMSettingsPage() {
|
|
| 238 |
|
| 239 |
{/* Success/Error Messages */}
|
| 240 |
{successMessage && (
|
| 241 |
-
<div className="mb-6 p-4 bg-green-50 border border-green-200 rounded-
|
| 242 |
<CheckCircle2 className="w-5 h-5 text-green-600" />
|
| 243 |
<p className="text-green-800">{successMessage}</p>
|
| 244 |
</div>
|
| 245 |
)}
|
| 246 |
|
| 247 |
{errorMessage && (
|
| 248 |
-
<div className="mb-6 p-4 bg-red-50 border border-red-200 rounded-
|
| 249 |
<AlertCircle className="w-5 h-5 text-red-600" />
|
| 250 |
<p className="text-red-800">{errorMessage}</p>
|
| 251 |
</div>
|
|
@@ -255,24 +257,27 @@ export default function CRMSettingsPage() {
|
|
| 255 |
{showAddForm && (
|
| 256 |
<div className="mb-8 bg-white rounded-xl shadow-lg p-6 border border-slate-200">
|
| 257 |
<h2 className="text-xl font-bold text-slate-900 mb-6">Новая интеграция</h2>
|
| 258 |
-
|
| 259 |
<div className="space-y-6">
|
| 260 |
{/* CRM Type */}
|
| 261 |
<div>
|
| 262 |
<label className="block text-sm font-semibold text-slate-700 mb-2">
|
| 263 |
Тип CRM системы
|
| 264 |
</label>
|
| 265 |
-
<
|
| 266 |
-
value={newIntegration.crm_type}
|
| 267 |
-
onChange={(e) => setNewIntegration({ ...newIntegration, crm_type: e.target.value })}
|
| 268 |
-
className="w-full px-4 py-3 border border-slate-200 rounded-xl focus:ring-2 focus:ring-indigo-500 focus:border-transparent"
|
| 269 |
-
>
|
| 270 |
{CRM_TYPES.map(type => (
|
| 271 |
-
<
|
| 272 |
-
{type.
|
| 273 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
))}
|
| 275 |
-
</
|
| 276 |
</div>
|
| 277 |
|
| 278 |
{/* Integration Name */}
|
|
@@ -290,7 +295,7 @@ export default function CRMSettingsPage() {
|
|
| 290 |
</div>
|
| 291 |
|
| 292 |
{/* API URL (for amoCRM, HubSpot, etc.) */}
|
| 293 |
-
{['
|
| 294 |
<div>
|
| 295 |
<label className="block text-sm font-semibold text-slate-700 mb-2">
|
| 296 |
API URL
|
|
@@ -301,8 +306,8 @@ export default function CRMSettingsPage() {
|
|
| 301 |
onChange={(e) => setNewIntegration({ ...newIntegration, api_url: e.target.value })}
|
| 302 |
placeholder={
|
| 303 |
newIntegration.crm_type === 'amocrm' ? 'https://yourcompany.amocrm.ru' :
|
| 304 |
-
|
| 305 |
-
|
| 306 |
}
|
| 307 |
className="w-full px-4 py-3 border border-slate-200 rounded-xl focus:ring-2 focus:ring-indigo-500 focus:border-transparent"
|
| 308 |
/>
|
|
@@ -345,7 +350,7 @@ export default function CRMSettingsPage() {
|
|
| 345 |
value={newIntegration.webhook_url}
|
| 346 |
onChange={(e) => setNewIntegration({ ...newIntegration, webhook_url: e.target.value })}
|
| 347 |
placeholder={
|
| 348 |
-
newIntegration.crm_type === 'bitrix24'
|
| 349 |
? 'https://yourcompany.bitrix24.ru/rest/1/abc123xyz/'
|
| 350 |
: 'https://your-crm.com/api/webhook'
|
| 351 |
}
|
|
@@ -400,14 +405,18 @@ export default function CRMSettingsPage() {
|
|
| 400 |
<label className="block text-sm font-medium text-slate-700 mb-2">
|
| 401 |
Интервал синхронизации (минуты)
|
| 402 |
</label>
|
| 403 |
-
<
|
| 404 |
-
type="number"
|
| 405 |
-
min="5"
|
| 406 |
-
max="1440"
|
| 407 |
value={newIntegration.sync_interval_minutes}
|
| 408 |
onChange={(e) => setNewIntegration({ ...newIntegration, sync_interval_minutes: parseInt(e.target.value) })}
|
| 409 |
className="w-full px-4 py-3 border border-slate-200 rounded-xl focus:ring-2 focus:ring-indigo-500 focus:border-transparent"
|
| 410 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 411 |
</div>
|
| 412 |
|
| 413 |
{/* Sync Statuses */}
|
|
@@ -497,20 +506,19 @@ export default function CRMSettingsPage() {
|
|
| 497 |
<div key={integration.id} className="bg-white rounded-xl shadow-lg p-6 border border-slate-200">
|
| 498 |
<div className="flex items-start justify-between mb-4">
|
| 499 |
<div className="flex items-center gap-3">
|
| 500 |
-
<div className="
|
| 501 |
<div>
|
| 502 |
<h3 className="text-lg font-bold text-slate-900">{integration.integration_name}</h3>
|
| 503 |
<p className="text-sm text-slate-600">{getCRMLabel(integration.crm_type)}</p>
|
| 504 |
</div>
|
| 505 |
</div>
|
| 506 |
<div className="flex items-center gap-2">
|
| 507 |
-
<span className={`px-3 py-1 rounded-full text-xs font-medium ${
|
| 508 |
-
integration.status === 'active' ? 'bg-green-100 text-green-700' :
|
| 509 |
integration.status === 'paused' ? 'bg-yellow-100 text-yellow-700' :
|
| 510 |
-
|
| 511 |
-
|
| 512 |
{integration.status === 'active' ? 'Активна' :
|
| 513 |
-
|
| 514 |
</span>
|
| 515 |
<button
|
| 516 |
onClick={() => handleDeleteIntegration(integration.id)}
|
|
@@ -534,7 +542,7 @@ export default function CRMSettingsPage() {
|
|
| 534 |
<div className="bg-slate-50 rounded-lg p-3">
|
| 535 |
<p className="text-xs text-slate-600 mb-1">Последняя синхр.</p>
|
| 536 |
<p className="text-sm font-medium text-slate-700">
|
| 537 |
-
{integration.last_sync_at
|
| 538 |
? new Date(integration.last_sync_at).toLocaleString('ru-RU')
|
| 539 |
: 'Не было'
|
| 540 |
}
|
|
|
|
| 2 |
|
| 3 |
import { useEffect, useState } from 'react'
|
| 4 |
import { useAuth } from '@/contexts/AuthContext'
|
| 5 |
+
import {
|
| 6 |
+
Save, Loader2, AlertCircle, CheckCircle2, Plus, Trash2,
|
| 7 |
+
RefreshCw, Settings, Database, Zap, ChevronDown, Eye, EyeOff,
|
| 8 |
+
Webhook
|
| 9 |
} from 'lucide-react'
|
| 10 |
|
| 11 |
interface CRMIntegration {
|
|
|
|
| 25 |
}
|
| 26 |
|
| 27 |
const CRM_TYPES = [
|
| 28 |
+
{ value: 'amocrm', label: 'amoCRM' },
|
| 29 |
+
{ value: 'bitrix24', label: 'Bitrix24' },
|
| 30 |
+
{ value: 'hubspot', label: 'HubSpot' },
|
| 31 |
+
{ value: 'pipedrive', label: 'Pipedrive' },
|
| 32 |
+
{ value: 'salesforce', label: 'Salesforce' },
|
| 33 |
+
{ value: 'zoho', label: 'Zoho CRM' },
|
| 34 |
+
{ value: 'custom_webhook', label: 'Custom Webhook' }
|
| 35 |
]
|
| 36 |
|
| 37 |
const LEAD_STATUSES = [
|
|
|
|
| 50 |
const [showAddForm, setShowAddForm] = useState(false)
|
| 51 |
const [successMessage, setSuccessMessage] = useState('')
|
| 52 |
const [errorMessage, setErrorMessage] = useState('')
|
| 53 |
+
const [showTokens, setShowTokens] = useState<{ [key: string]: boolean }>({})
|
| 54 |
|
| 55 |
// New integration form
|
| 56 |
const [newIntegration, setNewIntegration] = useState({
|
|
|
|
| 197 |
}
|
| 198 |
|
| 199 |
const getCRMIcon = (type: string) => {
|
| 200 |
+
if (type === 'custom_webhook') return <Webhook className="w-8 h-8 text-indigo-600" />
|
| 201 |
+
return <Database className="w-8 h-8 text-indigo-600" />
|
| 202 |
}
|
| 203 |
|
| 204 |
const getCRMLabel = (type: string) => {
|
|
|
|
| 214 |
}
|
| 215 |
|
| 216 |
return (
|
| 217 |
+
<div className="min-h-screen bg-slate-50">
|
| 218 |
<div className="max-w-6xl mx-auto p-8">
|
| 219 |
{/* Header */}
|
| 220 |
<div className="mb-8">
|
|
|
|
| 230 |
</div>
|
| 231 |
<button
|
| 232 |
onClick={() => setShowAddForm(!showAddForm)}
|
| 233 |
+
className="flex items-center gap-2 px-4 py-2 bg-indigo-600 text-white rounded-xl hover:bg-indigo-700 transition-colors shadow-lg shadow-indigo-500/20"
|
| 234 |
>
|
| 235 |
<Plus className="w-4 h-4" />
|
| 236 |
Добавить интеграцию
|
|
|
|
| 240 |
|
| 241 |
{/* Success/Error Messages */}
|
| 242 |
{successMessage && (
|
| 243 |
+
<div className="mb-6 p-4 bg-green-50 border border-green-200 rounded-xl flex items-center gap-3">
|
| 244 |
<CheckCircle2 className="w-5 h-5 text-green-600" />
|
| 245 |
<p className="text-green-800">{successMessage}</p>
|
| 246 |
</div>
|
| 247 |
)}
|
| 248 |
|
| 249 |
{errorMessage && (
|
| 250 |
+
<div className="mb-6 p-4 bg-red-50 border border-red-200 rounded-xl flex items-center gap-3">
|
| 251 |
<AlertCircle className="w-5 h-5 text-red-600" />
|
| 252 |
<p className="text-red-800">{errorMessage}</p>
|
| 253 |
</div>
|
|
|
|
| 257 |
{showAddForm && (
|
| 258 |
<div className="mb-8 bg-white rounded-xl shadow-lg p-6 border border-slate-200">
|
| 259 |
<h2 className="text-xl font-bold text-slate-900 mb-6">Новая интеграция</h2>
|
| 260 |
+
|
| 261 |
<div className="space-y-6">
|
| 262 |
{/* CRM Type */}
|
| 263 |
<div>
|
| 264 |
<label className="block text-sm font-semibold text-slate-700 mb-2">
|
| 265 |
Тип CRM системы
|
| 266 |
</label>
|
| 267 |
+
<div className="grid grid-cols-2 md:grid-cols-3 gap-3">
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
{CRM_TYPES.map(type => (
|
| 269 |
+
<button
|
| 270 |
+
key={type.value}
|
| 271 |
+
onClick={() => setNewIntegration({ ...newIntegration, crm_type: type.value })}
|
| 272 |
+
className={`p-3 rounded-xl border text-left transition-all ${newIntegration.crm_type === type.value
|
| 273 |
+
? 'border-indigo-600 bg-indigo-50 ring-2 ring-indigo-500/20'
|
| 274 |
+
: 'border-slate-200 hover:border-indigo-300 hover:bg-slate-50'
|
| 275 |
+
}`}
|
| 276 |
+
>
|
| 277 |
+
<div className="font-medium text-slate-900">{type.label}</div>
|
| 278 |
+
</button>
|
| 279 |
))}
|
| 280 |
+
</div>
|
| 281 |
</div>
|
| 282 |
|
| 283 |
{/* Integration Name */}
|
|
|
|
| 295 |
</div>
|
| 296 |
|
| 297 |
{/* API URL (for amoCRM, HubSpot, etc.) */}
|
| 298 |
+
{!['custom_webhook'].includes(newIntegration.crm_type) && (
|
| 299 |
<div>
|
| 300 |
<label className="block text-sm font-semibold text-slate-700 mb-2">
|
| 301 |
API URL
|
|
|
|
| 306 |
onChange={(e) => setNewIntegration({ ...newIntegration, api_url: e.target.value })}
|
| 307 |
placeholder={
|
| 308 |
newIntegration.crm_type === 'amocrm' ? 'https://yourcompany.amocrm.ru' :
|
| 309 |
+
newIntegration.crm_type === 'hubspot' ? 'https://api.hubapi.com' :
|
| 310 |
+
'https://yourinstance.salesforce.com'
|
| 311 |
}
|
| 312 |
className="w-full px-4 py-3 border border-slate-200 rounded-xl focus:ring-2 focus:ring-indigo-500 focus:border-transparent"
|
| 313 |
/>
|
|
|
|
| 350 |
value={newIntegration.webhook_url}
|
| 351 |
onChange={(e) => setNewIntegration({ ...newIntegration, webhook_url: e.target.value })}
|
| 352 |
placeholder={
|
| 353 |
+
newIntegration.crm_type === 'bitrix24'
|
| 354 |
? 'https://yourcompany.bitrix24.ru/rest/1/abc123xyz/'
|
| 355 |
: 'https://your-crm.com/api/webhook'
|
| 356 |
}
|
|
|
|
| 405 |
<label className="block text-sm font-medium text-slate-700 mb-2">
|
| 406 |
Интервал синхронизации (минуты)
|
| 407 |
</label>
|
| 408 |
+
<select
|
|
|
|
|
|
|
|
|
|
| 409 |
value={newIntegration.sync_interval_minutes}
|
| 410 |
onChange={(e) => setNewIntegration({ ...newIntegration, sync_interval_minutes: parseInt(e.target.value) })}
|
| 411 |
className="w-full px-4 py-3 border border-slate-200 rounded-xl focus:ring-2 focus:ring-indigo-500 focus:border-transparent"
|
| 412 |
+
>
|
| 413 |
+
<option value={5}>5 минут</option>
|
| 414 |
+
<option value={15}>15 минут</option>
|
| 415 |
+
<option value={30}>30 минут</option>
|
| 416 |
+
<option value={60}>1 час</option>
|
| 417 |
+
<option value={360}>6 часов</option>
|
| 418 |
+
<option value={1440}>24 часа</option>
|
| 419 |
+
</select>
|
| 420 |
</div>
|
| 421 |
|
| 422 |
{/* Sync Statuses */}
|
|
|
|
| 506 |
<div key={integration.id} className="bg-white rounded-xl shadow-lg p-6 border border-slate-200">
|
| 507 |
<div className="flex items-start justify-between mb-4">
|
| 508 |
<div className="flex items-center gap-3">
|
| 509 |
+
<div className="p-2 bg-indigo-50 rounded-lg border border-indigo-100">{getCRMIcon(integration.crm_type)}</div>
|
| 510 |
<div>
|
| 511 |
<h3 className="text-lg font-bold text-slate-900">{integration.integration_name}</h3>
|
| 512 |
<p className="text-sm text-slate-600">{getCRMLabel(integration.crm_type)}</p>
|
| 513 |
</div>
|
| 514 |
</div>
|
| 515 |
<div className="flex items-center gap-2">
|
| 516 |
+
<span className={`px-3 py-1 rounded-full text-xs font-medium ${integration.status === 'active' ? 'bg-green-100 text-green-700' :
|
|
|
|
| 517 |
integration.status === 'paused' ? 'bg-yellow-100 text-yellow-700' :
|
| 518 |
+
'bg-red-100 text-red-700'
|
| 519 |
+
}`}>
|
| 520 |
{integration.status === 'active' ? 'Активна' :
|
| 521 |
+
integration.status === 'paused' ? 'Приостановлена' : 'Ошибка'}
|
| 522 |
</span>
|
| 523 |
<button
|
| 524 |
onClick={() => handleDeleteIntegration(integration.id)}
|
|
|
|
| 542 |
<div className="bg-slate-50 rounded-lg p-3">
|
| 543 |
<p className="text-xs text-slate-600 mb-1">Последняя синхр.</p>
|
| 544 |
<p className="text-sm font-medium text-slate-700">
|
| 545 |
+
{integration.last_sync_at
|
| 546 |
? new Date(integration.last_sync_at).toLocaleString('ru-RU')
|
| 547 |
: 'Не было'
|
| 548 |
}
|
frontend/components/ClientCard.tsx
CHANGED
|
@@ -19,14 +19,14 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 19 |
const toast = useToast()
|
| 20 |
// Parse AI Summary JSON - The Golden 11 Fields
|
| 21 |
const summary = lead.ai_summary_json || {}
|
| 22 |
-
|
| 23 |
// FIXED: Use lead.id as key for state (per-lead state tracking)
|
| 24 |
const [analyzingLeads, setAnalyzingLeads] = useState<Set<string>>(new Set())
|
| 25 |
const [syncingLeads, setSyncingLeads] = useState<Set<string>>(new Set())
|
| 26 |
-
|
| 27 |
const isManualAnalyzing = analyzingLeads.has(lead.id)
|
| 28 |
const isSyncingCRM = syncingLeads.has(lead.id)
|
| 29 |
-
|
| 30 |
// Проверка на ошибки в данных
|
| 31 |
const isErrorValue = (value: any): boolean => {
|
| 32 |
if (!value || typeof value !== 'string') return false
|
|
@@ -42,13 +42,13 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 42 |
]
|
| 43 |
return errorPatterns.some(pattern => value.toLowerCase().includes(pattern))
|
| 44 |
}
|
| 45 |
-
|
| 46 |
// Очистка значения от ошибок
|
| 47 |
const cleanValue = (value: any, fallback: string): string => {
|
| 48 |
if (!value || isErrorValue(value)) return fallback
|
| 49 |
return value
|
| 50 |
}
|
| 51 |
-
|
| 52 |
// Extract all 11 fields with fallbacks и очисткой от ошибок
|
| 53 |
const golden11 = {
|
| 54 |
// Hard Data (4 fields)
|
|
@@ -57,7 +57,7 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 57 |
authority: cleanValue(summary.authority || lead.authority, 'Неизвестно'),
|
| 58 |
timeline: cleanValue(summary.timeline || lead.timeline, 'Не указаны'),
|
| 59 |
// Soft Data (3 fields)
|
| 60 |
-
pain_points: Array.isArray(summary.pain_points)
|
| 61 |
? summary.pain_points.filter((p: string) => !isErrorValue(p))
|
| 62 |
: [],
|
| 63 |
objections: Array.isArray(summary.objections)
|
|
@@ -83,7 +83,7 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 83 |
}
|
| 84 |
return map[lower] || { label: psychotype, color: 'bg-gray-100 text-gray-700 border-gray-200' }
|
| 85 |
}
|
| 86 |
-
|
| 87 |
// Get psychotype badge color (removed, now in localizePsychotype)
|
| 88 |
const psychotypeData = localizePsychotype(golden11.psychotype)
|
| 89 |
|
|
@@ -101,49 +101,49 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 101 |
// Backend uses: hot >= 70, warm >= 40, cold >= 20
|
| 102 |
const getScoreColor = (score: number) => {
|
| 103 |
if (score >= 70) return { // FIXED: was 80, now matches backend
|
| 104 |
-
text: 'text-emerald-600',
|
| 105 |
-
stroke: 'stroke-emerald-500',
|
| 106 |
bg: 'bg-emerald-50',
|
| 107 |
glow: 'shadow-emerald-200',
|
| 108 |
-
label: 'Горячий
|
| 109 |
}
|
| 110 |
if (score >= 40) return { // FIXED: was 50, now matches backend
|
| 111 |
-
text: 'text-amber-600',
|
| 112 |
-
stroke: 'stroke-amber-500',
|
| 113 |
bg: 'bg-amber-50',
|
| 114 |
glow: 'shadow-amber-200',
|
| 115 |
-
label: 'Тёплый
|
| 116 |
}
|
| 117 |
-
if (score >= 20) return {
|
| 118 |
-
text: 'text-blue-600',
|
| 119 |
-
stroke: 'stroke-blue-500',
|
| 120 |
bg: 'bg-blue-50',
|
| 121 |
glow: 'shadow-blue-200',
|
| 122 |
-
label: 'Холодный
|
| 123 |
}
|
| 124 |
-
return {
|
| 125 |
-
text: 'text-slate-500',
|
| 126 |
-
stroke: 'stroke-slate-400',
|
| 127 |
bg: 'bg-slate-50',
|
| 128 |
glow: 'shadow-slate-200',
|
| 129 |
-
label: 'Нет данных
|
| 130 |
}
|
| 131 |
}
|
| 132 |
|
| 133 |
const scoreColors = getScoreColor(scorePercentage)
|
| 134 |
|
| 135 |
// 11th field: Heat Score (displayed in donut chart)
|
| 136 |
-
|
| 137 |
// Manual analysis trigger - PER-LEAD STATE TRACKING
|
| 138 |
const handleManualAnalysis = async () => {
|
| 139 |
// Add this lead to analyzing set
|
| 140 |
setAnalyzingLeads(prev => new Set(prev).add(lead.id))
|
| 141 |
-
|
| 142 |
toast.info(
|
| 143 |
'Анализ запущен',
|
| 144 |
`Обновление AI саммари для ${lead.name || 'клиента'}...`
|
| 145 |
)
|
| 146 |
-
|
| 147 |
try {
|
| 148 |
const token = localStorage.getItem('auth_token')
|
| 149 |
if (!token) {
|
|
@@ -212,11 +212,11 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 212 |
toast.error('Ошибка', 'tenant_id не найден')
|
| 213 |
return
|
| 214 |
}
|
| 215 |
-
|
| 216 |
// Add this lead to syncing set
|
| 217 |
setSyncingLeads(prev => new Set(prev).add(lead.id))
|
| 218 |
toast.info('Синхронизация...', 'Отправка данных в CRM системы')
|
| 219 |
-
|
| 220 |
try {
|
| 221 |
const token = localStorage.getItem('auth_token')
|
| 222 |
if (!token) {
|
|
@@ -321,7 +321,7 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 321 |
<Brain className="w-5 h-5 text-indigo-600" />
|
| 322 |
Анализ ИИ
|
| 323 |
</h2>
|
| 324 |
-
|
| 325 |
{/* Индикатор состояния данных */}
|
| 326 |
{scorePercentage === 0 ? (
|
| 327 |
<span className="inline-flex items-center gap-1.5 px-2.5 py-1 bg-amber-50 border border-amber-200 rounded-full text-xs font-semibold text-amber-700">
|
|
@@ -335,7 +335,7 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 335 |
</span>
|
| 336 |
)}
|
| 337 |
</div>
|
| 338 |
-
|
| 339 |
<button
|
| 340 |
onClick={handleManualAnalysis}
|
| 341 |
disabled={isManualAnalyzing} // FIXED: Only disable for THIS lead, not global
|
|
@@ -355,14 +355,14 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 355 |
)}
|
| 356 |
</button>
|
| 357 |
</div>
|
| 358 |
-
|
| 359 |
{/* Подсказка */}
|
| 360 |
{!isManualAnalyzing && (
|
| 361 |
<p className="text-xs text-slate-500">
|
| 362 |
Нажмите "Обновить" для получения свежего анализа
|
| 363 |
</p>
|
| 364 |
)}
|
| 365 |
-
|
| 366 |
{/* Индикатор анализа */}
|
| 367 |
{isManualAnalyzing && (
|
| 368 |
<div className="mt-3 flex items-center gap-2 px-3 py-2 bg-indigo-50 border border-indigo-200 rounded-lg">
|
|
@@ -373,7 +373,7 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 373 |
</div>
|
| 374 |
)}
|
| 375 |
</div>
|
| 376 |
-
|
| 377 |
<div className="flex flex-col items-center">
|
| 378 |
{/* Score Header with Donut Chart - FIXED SVG VIEWBOX */}
|
| 379 |
<div className="relative w-48 h-48 mb-6">
|
|
@@ -382,13 +382,13 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 382 |
"absolute inset-0 rounded-full opacity-30 blur-2xl animate-pulse",
|
| 383 |
scoreColors.bg
|
| 384 |
)} />
|
| 385 |
-
|
| 386 |
{/* Внешнее кольцо с тенью */}
|
| 387 |
<div className={cn(
|
| 388 |
"absolute inset-3 rounded-full shadow-2xl",
|
| 389 |
scoreColors.glow
|
| 390 |
)} />
|
| 391 |
-
|
| 392 |
{/* PERFECTLY ALIGNED: viewBox matches w-48 (192px) */}
|
| 393 |
<svg className="w-48 h-48 transform -rotate-90 relative z-10" viewBox="0 0 192 192">
|
| 394 |
{/* Фоновый круг */}
|
|
@@ -417,7 +417,7 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 417 |
}}
|
| 418 |
/>
|
| 419 |
</svg>
|
| 420 |
-
|
| 421 |
{/* Центральный контент - БЕЗ перекрытия */}
|
| 422 |
<div className="absolute inset-0 flex flex-col items-center justify-center pointer-events-none">
|
| 423 |
<div className="flex flex-col items-center gap-2">
|
|
@@ -443,11 +443,11 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 443 |
</div>
|
| 444 |
</div>
|
| 445 |
</div>
|
| 446 |
-
|
| 447 |
<h3 className="text-xl font-bold text-slate-900 mb-1">
|
| 448 |
{lead.name || 'Без имени'}
|
| 449 |
</h3>
|
| 450 |
-
|
| 451 |
{/* Psychotype Badge - Улучшенный */}
|
| 452 |
<div className="flex items-center gap-2 mt-2">
|
| 453 |
<span className={cn(
|
|
@@ -474,13 +474,13 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 474 |
</div>
|
| 475 |
<p className="text-xs font-bold text-emerald-700 uppercase tracking-wide">Бюджет</p>
|
| 476 |
</div>
|
| 477 |
-
<p className={cn("text-sm font-bold mt-2",
|
| 478 |
golden11.budget === 'Не определен' ? 'text-slate-400' : 'text-slate-900'
|
| 479 |
)}>
|
| 480 |
{golden11.budget === 'Не определен' ? '—' : golden11.budget}
|
| 481 |
</p>
|
| 482 |
</div>
|
| 483 |
-
|
| 484 |
{/* ЛПР */}
|
| 485 |
<div className="bg-gradient-to-br from-white to-blue-50 rounded-xl p-4 border-2 border-blue-100 shadow-sm hover:shadow-md transition-all">
|
| 486 |
<div className="flex items-center gap-2 mb-2">
|
|
@@ -489,13 +489,13 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 489 |
</div>
|
| 490 |
<p className="text-xs font-bold text-blue-700 uppercase tracking-wide">ЛПР</p>
|
| 491 |
</div>
|
| 492 |
-
<p className={cn("text-sm font-bold mt-2",
|
| 493 |
golden11.authority === 'Неизвестно' ? 'text-slate-400' : 'text-slate-900'
|
| 494 |
)}>
|
| 495 |
{golden11.authority === 'Неизвестно' ? '—' : golden11.authority}
|
| 496 |
</p>
|
| 497 |
</div>
|
| 498 |
-
|
| 499 |
{/* СРОКИ */}
|
| 500 |
<div className="bg-gradient-to-br from-white to-indigo-50 rounded-xl p-4 border-2 border-indigo-100 shadow-sm hover:shadow-md transition-all">
|
| 501 |
<div className="flex items-center gap-2 mb-2">
|
|
@@ -504,13 +504,13 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 504 |
</div>
|
| 505 |
<p className="text-xs font-bold text-indigo-700 uppercase tracking-wide">Сроки</p>
|
| 506 |
</div>
|
| 507 |
-
<p className={cn("text-sm font-bold mt-2",
|
| 508 |
golden11.timeline === 'Не указаны' ? 'text-slate-400' : 'text-slate-900'
|
| 509 |
)}>
|
| 510 |
{golden11.timeline === 'Не указаны' ? '—' : golden11.timeline}
|
| 511 |
</p>
|
| 512 |
</div>
|
| 513 |
-
|
| 514 |
{/* ЦЕЛЬ */}
|
| 515 |
<div className="bg-gradient-to-br from-white to-orange-50 rounded-xl p-4 border-2 border-orange-100 shadow-sm hover:shadow-md transition-all">
|
| 516 |
<div className="flex items-center gap-2 mb-2">
|
|
@@ -519,7 +519,7 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 519 |
</div>
|
| 520 |
<p className="text-xs font-bold text-orange-700 uppercase tracking-wide">Цель</p>
|
| 521 |
</div>
|
| 522 |
-
<p className={cn("text-sm font-bold mt-2",
|
| 523 |
golden11.intent === 'Не определено' ? 'text-slate-400' : 'text-slate-900'
|
| 524 |
)}>
|
| 525 |
{golden11.intent === 'Не определено' ? '—' : golden11.intent}
|
|
@@ -527,14 +527,14 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 527 |
</div>
|
| 528 |
</div>
|
| 529 |
</div>
|
| 530 |
-
|
| 531 |
{/* Психология - Премиальный дизайн */}
|
| 532 |
<div>
|
| 533 |
<h3 className="font-bold text-slate-700 mb-4 text-sm uppercase tracking-wider flex items-center gap-2">
|
| 534 |
<Brain className="w-4 h-4 text-purple-600" />
|
| 535 |
Психология клиента
|
| 536 |
</h3>
|
| 537 |
-
|
| 538 |
{/* Боли - Красный акцент */}
|
| 539 |
{golden11.pain_points.length > 0 ? (
|
| 540 |
<div className="bg-gradient-to-br from-red-50 to-orange-50 rounded-xl p-4 mb-3 border-2 border-red-100 shadow-sm">
|
|
@@ -566,7 +566,7 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 566 |
<p className="text-sm text-slate-400 italic">Не выявлено</p>
|
| 567 |
</div>
|
| 568 |
)}
|
| 569 |
-
|
| 570 |
{/* Возражения - Жёлтый акцент */}
|
| 571 |
{golden11.objections.length > 0 ? (
|
| 572 |
<div className="bg-gradient-to-br from-amber-50 to-yellow-50 rounded-xl p-4 border-2 border-amber-100 shadow-sm">
|
|
@@ -609,7 +609,7 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 609 |
<Lightbulb className="w-4 h-4 text-amber-600" />
|
| 610 |
Стратегия продаж
|
| 611 |
</h3>
|
| 612 |
-
|
| 613 |
{/* Скрытые сигналы */}
|
| 614 |
{golden11.hidden_signals ? (
|
| 615 |
<div className="bg-gradient-to-br from-blue-50 to-indigo-50 rounded-xl p-5 mb-3 border-2 border-blue-200 shadow-md">
|
|
@@ -618,7 +618,7 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 618 |
<Lightbulb className="w-5 h-5 text-blue-700" />
|
| 619 |
</div>
|
| 620 |
<div className="flex-1">
|
| 621 |
-
<span className="text-sm font-bold text-blue-900 uppercase tracking-wide block mb-2">
|
| 622 |
<p className="text-sm text-blue-900 leading-relaxed">{golden11.hidden_signals}</p>
|
| 623 |
</div>
|
| 624 |
</div>
|
|
@@ -630,13 +630,13 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 630 |
<Lightbulb className="w-5 h-5 text-slate-400" />
|
| 631 |
</div>
|
| 632 |
<div className="flex-1">
|
| 633 |
-
<span className="text-sm font-bold text-slate-500 uppercase tracking-wide block mb-2">
|
| 634 |
<p className="text-sm text-slate-400 italic">Нет данных для анализа</p>
|
| 635 |
</div>
|
| 636 |
</div>
|
| 637 |
</div>
|
| 638 |
)}
|
| 639 |
-
|
| 640 |
{/* Рекомендация */}
|
| 641 |
{golden11.recommendation ? (
|
| 642 |
<div className="bg-gradient-to-br from-emerald-50 to-green-50 rounded-xl p-5 mb-3 border-2 border-emerald-200 shadow-md">
|
|
@@ -645,7 +645,7 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 645 |
<CheckCircle2 className="w-5 h-5 text-emerald-700" />
|
| 646 |
</div>
|
| 647 |
<div className="flex-1">
|
| 648 |
-
<span className="text-sm font-bold text-emerald-900 uppercase tracking-wide block mb-2">
|
| 649 |
<p className="text-sm text-emerald-900 leading-relaxed font-medium">{golden11.recommendation}</p>
|
| 650 |
</div>
|
| 651 |
</div>
|
|
@@ -657,13 +657,13 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 657 |
<CheckCircle2 className="w-5 h-5 text-slate-400" />
|
| 658 |
</div>
|
| 659 |
<div className="flex-1">
|
| 660 |
-
<span className="text-sm font-bold text-slate-500 uppercase tracking-wide block mb-2">
|
| 661 |
<p className="text-sm text-slate-400 italic">Нужен анализ диалога</p>
|
| 662 |
</div>
|
| 663 |
</div>
|
| 664 |
</div>
|
| 665 |
)}
|
| 666 |
-
|
| 667 |
{/* Черновик ответа - Премиальный дизайн */}
|
| 668 |
{golden11.draft_reply ? (
|
| 669 |
<div className="bg-gradient-to-br from-indigo-50 to-purple-50 rounded-xl p-5 border-2 border-indigo-200 shadow-md">
|
|
@@ -672,7 +672,7 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 672 |
<Phone className="w-5 h-5 text-indigo-700" />
|
| 673 |
</div>
|
| 674 |
<div className="flex-1">
|
| 675 |
-
<span className="text-sm font-bold text-indigo-900 uppercase tracking-wide block mb-3">
|
| 676 |
<div className="bg-white/80 backdrop-blur-sm rounded-lg p-4 border border-indigo-100">
|
| 677 |
<p className="text-sm text-slate-800 leading-relaxed">{golden11.draft_reply}</p>
|
| 678 |
</div>
|
|
@@ -686,7 +686,7 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 686 |
// Визуальная обратная связь
|
| 687 |
const button = document.activeElement as HTMLButtonElement
|
| 688 |
const originalText = button.innerHTML
|
| 689 |
-
button.innerHTML = '<span class="flex items-center gap-2">
|
| 690 |
button.classList.add('bg-emerald-600')
|
| 691 |
setTimeout(() => {
|
| 692 |
button.innerHTML = originalText
|
|
@@ -708,7 +708,7 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
|
|
| 708 |
<Phone className="w-5 h-5 text-slate-400" />
|
| 709 |
</div>
|
| 710 |
<div className="flex-1">
|
| 711 |
-
<span className="text-sm font-bold text-slate-500 uppercase tracking-wide block mb-2">
|
| 712 |
<p className="text-sm text-slate-400 italic">Будет сгенерирован после анализа</p>
|
| 713 |
</div>
|
| 714 |
</div>
|
|
|
|
| 19 |
const toast = useToast()
|
| 20 |
// Parse AI Summary JSON - The Golden 11 Fields
|
| 21 |
const summary = lead.ai_summary_json || {}
|
| 22 |
+
|
| 23 |
// FIXED: Use lead.id as key for state (per-lead state tracking)
|
| 24 |
const [analyzingLeads, setAnalyzingLeads] = useState<Set<string>>(new Set())
|
| 25 |
const [syncingLeads, setSyncingLeads] = useState<Set<string>>(new Set())
|
| 26 |
+
|
| 27 |
const isManualAnalyzing = analyzingLeads.has(lead.id)
|
| 28 |
const isSyncingCRM = syncingLeads.has(lead.id)
|
| 29 |
+
|
| 30 |
// Проверка на ошибки в данных
|
| 31 |
const isErrorValue = (value: any): boolean => {
|
| 32 |
if (!value || typeof value !== 'string') return false
|
|
|
|
| 42 |
]
|
| 43 |
return errorPatterns.some(pattern => value.toLowerCase().includes(pattern))
|
| 44 |
}
|
| 45 |
+
|
| 46 |
// Очистка значения от ошибок
|
| 47 |
const cleanValue = (value: any, fallback: string): string => {
|
| 48 |
if (!value || isErrorValue(value)) return fallback
|
| 49 |
return value
|
| 50 |
}
|
| 51 |
+
|
| 52 |
// Extract all 11 fields with fallbacks и очисткой от ошибок
|
| 53 |
const golden11 = {
|
| 54 |
// Hard Data (4 fields)
|
|
|
|
| 57 |
authority: cleanValue(summary.authority || lead.authority, 'Неизвестно'),
|
| 58 |
timeline: cleanValue(summary.timeline || lead.timeline, 'Не указаны'),
|
| 59 |
// Soft Data (3 fields)
|
| 60 |
+
pain_points: Array.isArray(summary.pain_points)
|
| 61 |
? summary.pain_points.filter((p: string) => !isErrorValue(p))
|
| 62 |
: [],
|
| 63 |
objections: Array.isArray(summary.objections)
|
|
|
|
| 83 |
}
|
| 84 |
return map[lower] || { label: psychotype, color: 'bg-gray-100 text-gray-700 border-gray-200' }
|
| 85 |
}
|
| 86 |
+
|
| 87 |
// Get psychotype badge color (removed, now in localizePsychotype)
|
| 88 |
const psychotypeData = localizePsychotype(golden11.psychotype)
|
| 89 |
|
|
|
|
| 101 |
// Backend uses: hot >= 70, warm >= 40, cold >= 20
|
| 102 |
const getScoreColor = (score: number) => {
|
| 103 |
if (score >= 70) return { // FIXED: was 80, now matches backend
|
| 104 |
+
text: 'text-emerald-600',
|
| 105 |
+
stroke: 'stroke-emerald-500',
|
| 106 |
bg: 'bg-emerald-50',
|
| 107 |
glow: 'shadow-emerald-200',
|
| 108 |
+
label: 'Горячий'
|
| 109 |
}
|
| 110 |
if (score >= 40) return { // FIXED: was 50, now matches backend
|
| 111 |
+
text: 'text-amber-600',
|
| 112 |
+
stroke: 'stroke-amber-500',
|
| 113 |
bg: 'bg-amber-50',
|
| 114 |
glow: 'shadow-amber-200',
|
| 115 |
+
label: 'Тёплый'
|
| 116 |
}
|
| 117 |
+
if (score >= 20) return {
|
| 118 |
+
text: 'text-blue-600',
|
| 119 |
+
stroke: 'stroke-blue-500',
|
| 120 |
bg: 'bg-blue-50',
|
| 121 |
glow: 'shadow-blue-200',
|
| 122 |
+
label: 'Холодный'
|
| 123 |
}
|
| 124 |
+
return {
|
| 125 |
+
text: 'text-slate-500',
|
| 126 |
+
stroke: 'stroke-slate-400',
|
| 127 |
bg: 'bg-slate-50',
|
| 128 |
glow: 'shadow-slate-200',
|
| 129 |
+
label: 'Нет данных'
|
| 130 |
}
|
| 131 |
}
|
| 132 |
|
| 133 |
const scoreColors = getScoreColor(scorePercentage)
|
| 134 |
|
| 135 |
// 11th field: Heat Score (displayed in donut chart)
|
| 136 |
+
|
| 137 |
// Manual analysis trigger - PER-LEAD STATE TRACKING
|
| 138 |
const handleManualAnalysis = async () => {
|
| 139 |
// Add this lead to analyzing set
|
| 140 |
setAnalyzingLeads(prev => new Set(prev).add(lead.id))
|
| 141 |
+
|
| 142 |
toast.info(
|
| 143 |
'Анализ запущен',
|
| 144 |
`Обновление AI саммари для ${lead.name || 'клиента'}...`
|
| 145 |
)
|
| 146 |
+
|
| 147 |
try {
|
| 148 |
const token = localStorage.getItem('auth_token')
|
| 149 |
if (!token) {
|
|
|
|
| 212 |
toast.error('Ошибка', 'tenant_id не найден')
|
| 213 |
return
|
| 214 |
}
|
| 215 |
+
|
| 216 |
// Add this lead to syncing set
|
| 217 |
setSyncingLeads(prev => new Set(prev).add(lead.id))
|
| 218 |
toast.info('Синхронизация...', 'Отправка данных в CRM системы')
|
| 219 |
+
|
| 220 |
try {
|
| 221 |
const token = localStorage.getItem('auth_token')
|
| 222 |
if (!token) {
|
|
|
|
| 321 |
<Brain className="w-5 h-5 text-indigo-600" />
|
| 322 |
Анализ ИИ
|
| 323 |
</h2>
|
| 324 |
+
|
| 325 |
{/* Индикатор состояния данных */}
|
| 326 |
{scorePercentage === 0 ? (
|
| 327 |
<span className="inline-flex items-center gap-1.5 px-2.5 py-1 bg-amber-50 border border-amber-200 rounded-full text-xs font-semibold text-amber-700">
|
|
|
|
| 335 |
</span>
|
| 336 |
)}
|
| 337 |
</div>
|
| 338 |
+
|
| 339 |
<button
|
| 340 |
onClick={handleManualAnalysis}
|
| 341 |
disabled={isManualAnalyzing} // FIXED: Only disable for THIS lead, not global
|
|
|
|
| 355 |
)}
|
| 356 |
</button>
|
| 357 |
</div>
|
| 358 |
+
|
| 359 |
{/* Подсказка */}
|
| 360 |
{!isManualAnalyzing && (
|
| 361 |
<p className="text-xs text-slate-500">
|
| 362 |
Нажмите "Обновить" для получения свежего анализа
|
| 363 |
</p>
|
| 364 |
)}
|
| 365 |
+
|
| 366 |
{/* Индикатор анализа */}
|
| 367 |
{isManualAnalyzing && (
|
| 368 |
<div className="mt-3 flex items-center gap-2 px-3 py-2 bg-indigo-50 border border-indigo-200 rounded-lg">
|
|
|
|
| 373 |
</div>
|
| 374 |
)}
|
| 375 |
</div>
|
| 376 |
+
|
| 377 |
<div className="flex flex-col items-center">
|
| 378 |
{/* Score Header with Donut Chart - FIXED SVG VIEWBOX */}
|
| 379 |
<div className="relative w-48 h-48 mb-6">
|
|
|
|
| 382 |
"absolute inset-0 rounded-full opacity-30 blur-2xl animate-pulse",
|
| 383 |
scoreColors.bg
|
| 384 |
)} />
|
| 385 |
+
|
| 386 |
{/* Внешнее кольцо с тенью */}
|
| 387 |
<div className={cn(
|
| 388 |
"absolute inset-3 rounded-full shadow-2xl",
|
| 389 |
scoreColors.glow
|
| 390 |
)} />
|
| 391 |
+
|
| 392 |
{/* PERFECTLY ALIGNED: viewBox matches w-48 (192px) */}
|
| 393 |
<svg className="w-48 h-48 transform -rotate-90 relative z-10" viewBox="0 0 192 192">
|
| 394 |
{/* Фоновый круг */}
|
|
|
|
| 417 |
}}
|
| 418 |
/>
|
| 419 |
</svg>
|
| 420 |
+
|
| 421 |
{/* Центральный контент - БЕЗ перекрытия */}
|
| 422 |
<div className="absolute inset-0 flex flex-col items-center justify-center pointer-events-none">
|
| 423 |
<div className="flex flex-col items-center gap-2">
|
|
|
|
| 443 |
</div>
|
| 444 |
</div>
|
| 445 |
</div>
|
| 446 |
+
|
| 447 |
<h3 className="text-xl font-bold text-slate-900 mb-1">
|
| 448 |
{lead.name || 'Без имени'}
|
| 449 |
</h3>
|
| 450 |
+
|
| 451 |
{/* Psychotype Badge - Улучшенный */}
|
| 452 |
<div className="flex items-center gap-2 mt-2">
|
| 453 |
<span className={cn(
|
|
|
|
| 474 |
</div>
|
| 475 |
<p className="text-xs font-bold text-emerald-700 uppercase tracking-wide">Бюджет</p>
|
| 476 |
</div>
|
| 477 |
+
<p className={cn("text-sm font-bold mt-2",
|
| 478 |
golden11.budget === 'Не определен' ? 'text-slate-400' : 'text-slate-900'
|
| 479 |
)}>
|
| 480 |
{golden11.budget === 'Не определен' ? '—' : golden11.budget}
|
| 481 |
</p>
|
| 482 |
</div>
|
| 483 |
+
|
| 484 |
{/* ЛПР */}
|
| 485 |
<div className="bg-gradient-to-br from-white to-blue-50 rounded-xl p-4 border-2 border-blue-100 shadow-sm hover:shadow-md transition-all">
|
| 486 |
<div className="flex items-center gap-2 mb-2">
|
|
|
|
| 489 |
</div>
|
| 490 |
<p className="text-xs font-bold text-blue-700 uppercase tracking-wide">ЛПР</p>
|
| 491 |
</div>
|
| 492 |
+
<p className={cn("text-sm font-bold mt-2",
|
| 493 |
golden11.authority === 'Неизвестно' ? 'text-slate-400' : 'text-slate-900'
|
| 494 |
)}>
|
| 495 |
{golden11.authority === 'Неизвестно' ? '—' : golden11.authority}
|
| 496 |
</p>
|
| 497 |
</div>
|
| 498 |
+
|
| 499 |
{/* СРОКИ */}
|
| 500 |
<div className="bg-gradient-to-br from-white to-indigo-50 rounded-xl p-4 border-2 border-indigo-100 shadow-sm hover:shadow-md transition-all">
|
| 501 |
<div className="flex items-center gap-2 mb-2">
|
|
|
|
| 504 |
</div>
|
| 505 |
<p className="text-xs font-bold text-indigo-700 uppercase tracking-wide">Сроки</p>
|
| 506 |
</div>
|
| 507 |
+
<p className={cn("text-sm font-bold mt-2",
|
| 508 |
golden11.timeline === 'Не указаны' ? 'text-slate-400' : 'text-slate-900'
|
| 509 |
)}>
|
| 510 |
{golden11.timeline === 'Не указаны' ? '—' : golden11.timeline}
|
| 511 |
</p>
|
| 512 |
</div>
|
| 513 |
+
|
| 514 |
{/* ЦЕЛЬ */}
|
| 515 |
<div className="bg-gradient-to-br from-white to-orange-50 rounded-xl p-4 border-2 border-orange-100 shadow-sm hover:shadow-md transition-all">
|
| 516 |
<div className="flex items-center gap-2 mb-2">
|
|
|
|
| 519 |
</div>
|
| 520 |
<p className="text-xs font-bold text-orange-700 uppercase tracking-wide">Цель</p>
|
| 521 |
</div>
|
| 522 |
+
<p className={cn("text-sm font-bold mt-2",
|
| 523 |
golden11.intent === 'Не определено' ? 'text-slate-400' : 'text-slate-900'
|
| 524 |
)}>
|
| 525 |
{golden11.intent === 'Не определено' ? '—' : golden11.intent}
|
|
|
|
| 527 |
</div>
|
| 528 |
</div>
|
| 529 |
</div>
|
| 530 |
+
|
| 531 |
{/* Психология - Премиальный дизайн */}
|
| 532 |
<div>
|
| 533 |
<h3 className="font-bold text-slate-700 mb-4 text-sm uppercase tracking-wider flex items-center gap-2">
|
| 534 |
<Brain className="w-4 h-4 text-purple-600" />
|
| 535 |
Психология клиента
|
| 536 |
</h3>
|
| 537 |
+
|
| 538 |
{/* Боли - Красный акцент */}
|
| 539 |
{golden11.pain_points.length > 0 ? (
|
| 540 |
<div className="bg-gradient-to-br from-red-50 to-orange-50 rounded-xl p-4 mb-3 border-2 border-red-100 shadow-sm">
|
|
|
|
| 566 |
<p className="text-sm text-slate-400 italic">Не выявлено</p>
|
| 567 |
</div>
|
| 568 |
)}
|
| 569 |
+
|
| 570 |
{/* Возражения - Жёлтый акцент */}
|
| 571 |
{golden11.objections.length > 0 ? (
|
| 572 |
<div className="bg-gradient-to-br from-amber-50 to-yellow-50 rounded-xl p-4 border-2 border-amber-100 shadow-sm">
|
|
|
|
| 609 |
<Lightbulb className="w-4 h-4 text-amber-600" />
|
| 610 |
Стратегия продаж
|
| 611 |
</h3>
|
| 612 |
+
|
| 613 |
{/* Скрытые сигналы */}
|
| 614 |
{golden11.hidden_signals ? (
|
| 615 |
<div className="bg-gradient-to-br from-blue-50 to-indigo-50 rounded-xl p-5 mb-3 border-2 border-blue-200 shadow-md">
|
|
|
|
| 618 |
<Lightbulb className="w-5 h-5 text-blue-700" />
|
| 619 |
</div>
|
| 620 |
<div className="flex-1">
|
| 621 |
+
<span className="text-sm font-bold text-blue-900 uppercase tracking-wide block mb-2">Скрытые сигналы</span>
|
| 622 |
<p className="text-sm text-blue-900 leading-relaxed">{golden11.hidden_signals}</p>
|
| 623 |
</div>
|
| 624 |
</div>
|
|
|
|
| 630 |
<Lightbulb className="w-5 h-5 text-slate-400" />
|
| 631 |
</div>
|
| 632 |
<div className="flex-1">
|
| 633 |
+
<span className="text-sm font-bold text-slate-500 uppercase tracking-wide block mb-2">Скрытые сигналы</span>
|
| 634 |
<p className="text-sm text-slate-400 italic">Нет данных для анализа</p>
|
| 635 |
</div>
|
| 636 |
</div>
|
| 637 |
</div>
|
| 638 |
)}
|
| 639 |
+
|
| 640 |
{/* Рекомендация */}
|
| 641 |
{golden11.recommendation ? (
|
| 642 |
<div className="bg-gradient-to-br from-emerald-50 to-green-50 rounded-xl p-5 mb-3 border-2 border-emerald-200 shadow-md">
|
|
|
|
| 645 |
<CheckCircle2 className="w-5 h-5 text-emerald-700" />
|
| 646 |
</div>
|
| 647 |
<div className="flex-1">
|
| 648 |
+
<span className="text-sm font-bold text-emerald-900 uppercase tracking-wide block mb-2">Рекомендация</span>
|
| 649 |
<p className="text-sm text-emerald-900 leading-relaxed font-medium">{golden11.recommendation}</p>
|
| 650 |
</div>
|
| 651 |
</div>
|
|
|
|
| 657 |
<CheckCircle2 className="w-5 h-5 text-slate-400" />
|
| 658 |
</div>
|
| 659 |
<div className="flex-1">
|
| 660 |
+
<span className="text-sm font-bold text-slate-500 uppercase tracking-wide block mb-2">Рекомендация</span>
|
| 661 |
<p className="text-sm text-slate-400 italic">Нужен анализ диалога</p>
|
| 662 |
</div>
|
| 663 |
</div>
|
| 664 |
</div>
|
| 665 |
)}
|
| 666 |
+
|
| 667 |
{/* Черновик ответа - Премиальный дизайн */}
|
| 668 |
{golden11.draft_reply ? (
|
| 669 |
<div className="bg-gradient-to-br from-indigo-50 to-purple-50 rounded-xl p-5 border-2 border-indigo-200 shadow-md">
|
|
|
|
| 672 |
<Phone className="w-5 h-5 text-indigo-700" />
|
| 673 |
</div>
|
| 674 |
<div className="flex-1">
|
| 675 |
+
<span className="text-sm font-bold text-indigo-900 uppercase tracking-wide block mb-3">Черновик ответа</span>
|
| 676 |
<div className="bg-white/80 backdrop-blur-sm rounded-lg p-4 border border-indigo-100">
|
| 677 |
<p className="text-sm text-slate-800 leading-relaxed">{golden11.draft_reply}</p>
|
| 678 |
</div>
|
|
|
|
| 686 |
// Визуальная обратная связь
|
| 687 |
const button = document.activeElement as HTMLButtonElement
|
| 688 |
const originalText = button.innerHTML
|
| 689 |
+
button.innerHTML = '<span class="flex items-center gap-2">Скопировано!</span>'
|
| 690 |
button.classList.add('bg-emerald-600')
|
| 691 |
setTimeout(() => {
|
| 692 |
button.innerHTML = originalText
|
|
|
|
| 708 |
<Phone className="w-5 h-5 text-slate-400" />
|
| 709 |
</div>
|
| 710 |
<div className="flex-1">
|
| 711 |
+
<span className="text-sm font-bold text-slate-500 uppercase tracking-wide block mb-2">Черновик ответа</span>
|
| 712 |
<p className="text-sm text-slate-400 italic">Будет сгенерирован после анализа</p>
|
| 713 |
</div>
|
| 714 |
</div>
|
frontend/components/Sidebar.tsx
CHANGED
|
@@ -68,28 +68,26 @@ export function Sidebar() {
|
|
| 68 |
initial="hidden"
|
| 69 |
animate="visible"
|
| 70 |
variants={sidebarVariants}
|
| 71 |
-
className="w-72 bg-
|
| 72 |
>
|
| 73 |
-
{/* Background Glow Effect */}
|
| 74 |
<div className="absolute top-0 left-0 w-full h-full overflow-hidden pointer-events-none z-0">
|
| 75 |
-
<div className="absolute -top-[20%] -left-[20%] w-[140%] h-[50%] bg-indigo-
|
| 76 |
-
<div className="absolute bottom-0 right-0 w-[80%] h-[40%] bg-purple-900/20 blur-[80px] rounded-full animate-pulse-slow delay-1000"></div>
|
| 77 |
</div>
|
| 78 |
|
| 79 |
{/* Logo Section */}
|
| 80 |
-
<div className="p-6 border-b border-slate-
|
| 81 |
<Link href="/dashboard" className="flex items-center gap-3 group">
|
| 82 |
<div className="relative">
|
| 83 |
-
<div className="
|
| 84 |
-
|
| 85 |
-
<img src="/logo.jpg" alt="MicroFunnel Logo" className="w-full h-full object-cover" />
|
| 86 |
</div>
|
| 87 |
</div>
|
| 88 |
<div>
|
| 89 |
-
<h1 className="text-lg font-bold text-
|
| 90 |
MicroFunnel
|
| 91 |
</h1>
|
| 92 |
-
<p className="text-[10px] text-slate-
|
| 93 |
</div>
|
| 94 |
</Link>
|
| 95 |
</div>
|
|
@@ -99,16 +97,16 @@ export function Sidebar() {
|
|
| 99 |
<nav className="flex-1 overflow-y-auto p-4 space-y-6 relative z-10">
|
| 100 |
{[1, 2, 3].map((i) => (
|
| 101 |
<div key={i}>
|
| 102 |
-
<div className="h-3 w-20 bg-slate-
|
| 103 |
<div className="space-y-2">
|
| 104 |
-
<div className="h-10 bg-slate-
|
| 105 |
-
<div className="h-10 bg-slate-
|
| 106 |
</div>
|
| 107 |
</div>
|
| 108 |
))}
|
| 109 |
</nav>
|
| 110 |
) : (
|
| 111 |
-
<nav className="flex-1 overflow-y-auto p-4 space-y-8 relative z-10 scrollbar-thin scrollbar-thumb-slate-
|
| 112 |
{/* WORKSPACE Group */}
|
| 113 |
<motion.div variants={itemVariants}>
|
| 114 |
<div className="text-[11px] font-bold text-slate-500 uppercase tracking-widest mb-3 px-3 flex items-center gap-2">
|
|
@@ -122,20 +120,20 @@ export function Sidebar() {
|
|
| 122 |
className={cn(
|
| 123 |
"group flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 font-medium text-sm border border-transparent relative overflow-hidden",
|
| 124 |
isActive('/dashboard')
|
| 125 |
-
? "bg-indigo-
|
| 126 |
-
: "text-slate-
|
| 127 |
)}
|
| 128 |
>
|
| 129 |
{isActive('/dashboard') && (
|
| 130 |
<motion.div
|
| 131 |
layoutId="activeTab"
|
| 132 |
-
className="absolute inset-0 bg-indigo-
|
| 133 |
transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
|
| 134 |
/>
|
| 135 |
)}
|
| 136 |
-
<LayoutDashboard className={cn("w-5 h-5 transition-colors relative z-10", isActive('/dashboard') ? "text-indigo-
|
| 137 |
<span className="flex-1 relative z-10">Дашборд</span>
|
| 138 |
-
{isActive('/dashboard') && <div className="w-1.5 h-1.5 rounded-full bg-indigo-
|
| 139 |
</Link>
|
| 140 |
)}
|
| 141 |
<Link
|
|
@@ -143,20 +141,20 @@ export function Sidebar() {
|
|
| 143 |
className={cn(
|
| 144 |
"group flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 font-medium text-sm border border-transparent relative overflow-hidden",
|
| 145 |
isActive('/chats')
|
| 146 |
-
? "bg-indigo-
|
| 147 |
-
: "text-slate-
|
| 148 |
)}
|
| 149 |
>
|
| 150 |
{isActive('/chats') && (
|
| 151 |
<motion.div
|
| 152 |
layoutId="activeTab"
|
| 153 |
-
className="absolute inset-0 bg-indigo-
|
| 154 |
transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
|
| 155 |
/>
|
| 156 |
)}
|
| 157 |
-
<MessageSquare className={cn("w-5 h-5 transition-colors relative z-10", isActive('/chats') ? "text-indigo-
|
| 158 |
<span className="flex-1 relative z-10">Чаты</span>
|
| 159 |
-
{isActive('/chats') && <div className="w-1.5 h-1.5 rounded-full bg-indigo-
|
| 160 |
</Link>
|
| 161 |
</div>
|
| 162 |
</motion.div>
|
|
@@ -174,18 +172,18 @@ export function Sidebar() {
|
|
| 174 |
className={cn(
|
| 175 |
"group flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 font-medium text-sm border border-transparent relative overflow-hidden",
|
| 176 |
isActive('/knowledge')
|
| 177 |
-
? "bg-indigo-
|
| 178 |
-
: "text-slate-
|
| 179 |
)}
|
| 180 |
>
|
| 181 |
{isActive('/knowledge') && (
|
| 182 |
<motion.div
|
| 183 |
layoutId="activeTab"
|
| 184 |
-
className="absolute inset-0 bg-indigo-
|
| 185 |
transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
|
| 186 |
/>
|
| 187 |
)}
|
| 188 |
-
<Database className={cn("w-5 h-5 transition-colors relative z-10", isActive('/knowledge') ? "text-indigo-
|
| 189 |
<span className="flex-1 relative z-10">База Знаний</span>
|
| 190 |
</Link>
|
| 191 |
<Link
|
|
@@ -193,18 +191,18 @@ export function Sidebar() {
|
|
| 193 |
className={cn(
|
| 194 |
"group flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 font-medium text-sm border border-transparent relative overflow-hidden",
|
| 195 |
isActive('/settings/brain')
|
| 196 |
-
? "bg-indigo-
|
| 197 |
-
: "text-slate-
|
| 198 |
)}
|
| 199 |
>
|
| 200 |
{isActive('/settings/brain') && (
|
| 201 |
<motion.div
|
| 202 |
layoutId="activeTab"
|
| 203 |
-
className="absolute inset-0 bg-indigo-
|
| 204 |
transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
|
| 205 |
/>
|
| 206 |
)}
|
| 207 |
-
<Brain className={cn("w-5 h-5 transition-colors relative z-10", isActive('/settings/brain') ? "text-indigo-
|
| 208 |
<span className="flex-1 relative z-10">AI Мозг</span>
|
| 209 |
</Link>
|
| 210 |
<Link
|
|
@@ -212,18 +210,18 @@ export function Sidebar() {
|
|
| 212 |
className={cn(
|
| 213 |
"group flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 font-medium text-sm border border-transparent relative overflow-hidden",
|
| 214 |
isActive('/settings/playbook')
|
| 215 |
-
? "bg-indigo-
|
| 216 |
-
: "text-slate-
|
| 217 |
)}
|
| 218 |
>
|
| 219 |
{isActive('/settings/playbook') && (
|
| 220 |
<motion.div
|
| 221 |
layoutId="activeTab"
|
| 222 |
-
className="absolute inset-0 bg-indigo-
|
| 223 |
transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
|
| 224 |
/>
|
| 225 |
)}
|
| 226 |
-
<Zap className={cn("w-5 h-5 transition-colors relative z-10", isActive('/settings/playbook') ? "text-indigo-
|
| 227 |
<span className="flex-1 relative z-10">Сценарии</span>
|
| 228 |
</Link>
|
| 229 |
</div>
|
|
@@ -243,18 +241,18 @@ export function Sidebar() {
|
|
| 243 |
className={cn(
|
| 244 |
"group flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 font-medium text-sm border border-transparent relative overflow-hidden",
|
| 245 |
isActive('/channels')
|
| 246 |
-
? "bg-indigo-
|
| 247 |
-
: "text-slate-
|
| 248 |
)}
|
| 249 |
>
|
| 250 |
{isActive('/channels') && (
|
| 251 |
<motion.div
|
| 252 |
layoutId="activeTab"
|
| 253 |
-
className="absolute inset-0 bg-indigo-
|
| 254 |
transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
|
| 255 |
/>
|
| 256 |
)}
|
| 257 |
-
<Send className={cn("w-5 h-5 transition-colors relative z-10", isActive('/channels') ? "text-indigo-
|
| 258 |
<span className="flex-1 relative z-10">Каналы</span>
|
| 259 |
</Link>
|
| 260 |
<Link
|
|
@@ -262,18 +260,18 @@ export function Sidebar() {
|
|
| 262 |
className={cn(
|
| 263 |
"group flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 font-medium text-sm border border-transparent relative overflow-hidden",
|
| 264 |
isActive('/settings/crm')
|
| 265 |
-
? "bg-indigo-
|
| 266 |
-
: "text-slate-
|
| 267 |
)}
|
| 268 |
>
|
| 269 |
{isActive('/settings/crm') && (
|
| 270 |
<motion.div
|
| 271 |
layoutId="activeTab"
|
| 272 |
-
className="absolute inset-0 bg-indigo-
|
| 273 |
transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
|
| 274 |
/>
|
| 275 |
)}
|
| 276 |
-
<Plug className={cn("w-5 h-5 transition-colors relative z-10", isActive('/settings/crm') ? "text-indigo-
|
| 277 |
<span className="flex-1 relative z-10">CRM Интеграция</span>
|
| 278 |
</Link>
|
| 279 |
</div>
|
|
@@ -293,18 +291,18 @@ export function Sidebar() {
|
|
| 293 |
className={cn(
|
| 294 |
"group flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 font-medium text-sm border border-transparent relative overflow-hidden",
|
| 295 |
isActive('/settings/team')
|
| 296 |
-
? "bg-indigo-
|
| 297 |
-
: "text-slate-
|
| 298 |
)}
|
| 299 |
>
|
| 300 |
{isActive('/settings/team') && (
|
| 301 |
<motion.div
|
| 302 |
layoutId="activeTab"
|
| 303 |
-
className="absolute inset-0 bg-indigo-
|
| 304 |
transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
|
| 305 |
/>
|
| 306 |
)}
|
| 307 |
-
<Users className={cn("w-5 h-5 transition-colors relative z-10", isActive('/settings/team') ? "text-indigo-
|
| 308 |
<span className="flex-1 relative z-10">Команда</span>
|
| 309 |
</Link>
|
| 310 |
</div>
|
|
@@ -314,20 +312,20 @@ export function Sidebar() {
|
|
| 314 |
)}
|
| 315 |
|
| 316 |
{/* Bottom Section */}
|
| 317 |
-
<div className="mt-auto border-t border-slate-
|
| 318 |
{/* Partner Program Link */}
|
| 319 |
{user?.role === 'OWNER' && (
|
| 320 |
-
<div className="p-4 border-b border-slate-
|
| 321 |
<Link
|
| 322 |
href="/settings/partner"
|
| 323 |
-
className="flex items-center gap-3 px-3 py-3 rounded-xl bg-gradient-to-r from-amber-
|
| 324 |
>
|
| 325 |
<div className="absolute inset-0 bg-white/20 translate-x-[-100%] group-hover:translate-x-[100%] transition-transform duration-700" />
|
| 326 |
<DollarSign className="w-5 h-5 text-amber-100" />
|
| 327 |
-
<span className="flex-1
|
| 328 |
Партнерская программа
|
| 329 |
</span>
|
| 330 |
-
<ChevronRight className="w-4 h-4 text-amber-
|
| 331 |
</Link>
|
| 332 |
</div>
|
| 333 |
)}
|
|
@@ -335,7 +333,7 @@ export function Sidebar() {
|
|
| 335 |
{/* User Profile Card or Sign In Fallback */}
|
| 336 |
{user ? (
|
| 337 |
<div className="p-4">
|
| 338 |
-
<div className="flex items-center gap-3 px-3 py-2.5 rounded-xl bg-
|
| 339 |
{/* Avatar with Initials */}
|
| 340 |
<div className={cn(
|
| 341 |
"w-10 h-10 rounded-full flex items-center justify-center text-white font-bold text-sm shadow-inner transition-transform group-hover:scale-105",
|
|
@@ -346,15 +344,15 @@ export function Sidebar() {
|
|
| 346 |
|
| 347 |
{/* User Info */}
|
| 348 |
<div className="flex-1 min-w-0">
|
| 349 |
-
<p className="text-sm font-semibold text-
|
| 350 |
{user.full_name || user.email}
|
| 351 |
</p>
|
| 352 |
<div className="flex items-center gap-1.5">
|
| 353 |
<span className={cn(
|
| 354 |
"px-1.5 py-0.5 rounded text-[10px] font-bold uppercase tracking-wide",
|
| 355 |
user.role === 'OWNER'
|
| 356 |
-
? "bg-indigo-
|
| 357 |
-
: "bg-slate-
|
| 358 |
)}>
|
| 359 |
{user.role === 'OWNER' ? 'Владелец' : 'Менеджер'}
|
| 360 |
</span>
|
|
@@ -364,7 +362,7 @@ export function Sidebar() {
|
|
| 364 |
{/* Logout Button */}
|
| 365 |
<button
|
| 366 |
onClick={logout}
|
| 367 |
-
className="p-2 rounded-lg text-slate-400 hover:text-red-
|
| 368 |
title="Выйти"
|
| 369 |
>
|
| 370 |
<LogOut className="w-5 h-5" />
|
|
@@ -376,7 +374,7 @@ export function Sidebar() {
|
|
| 376 |
<div className="p-4">
|
| 377 |
<Link
|
| 378 |
href="/login"
|
| 379 |
-
className="flex items-center justify-center gap-2 px-4 py-3 rounded-xl bg-indigo-600 hover:bg-indigo-700 text-white transition-all duration-200 font-bold text-sm shadow-lg shadow-indigo-
|
| 380 |
>
|
| 381 |
<LogOut className="w-5 h-5" />
|
| 382 |
Войти в систему
|
|
|
|
| 68 |
initial="hidden"
|
| 69 |
animate="visible"
|
| 70 |
variants={sidebarVariants}
|
| 71 |
+
className="w-72 bg-white border-r border-slate-200 flex flex-col font-['Inter'] relative overflow-hidden shrink-0 h-screen sticky top-0"
|
| 72 |
>
|
| 73 |
+
{/* Background Glow Effect - Subtle for Light Mode */}
|
| 74 |
<div className="absolute top-0 left-0 w-full h-full overflow-hidden pointer-events-none z-0">
|
| 75 |
+
<div className="absolute -top-[20%] -left-[20%] w-[140%] h-[50%] bg-indigo-50/50 blur-[100px] rounded-full"></div>
|
|
|
|
| 76 |
</div>
|
| 77 |
|
| 78 |
{/* Logo Section */}
|
| 79 |
+
<div className="p-6 border-b border-slate-100 relative z-10">
|
| 80 |
<Link href="/dashboard" className="flex items-center gap-3 group">
|
| 81 |
<div className="relative">
|
| 82 |
+
<div className="w-10 h-10 rounded-xl flex items-center justify-center relative z-10 group-hover:scale-105 transition-transform duration-300 overflow-hidden">
|
| 83 |
+
<img src="/logo-symbol-transparent.png?v=3" alt="MicroFunnel Logo" className="w-full h-full object-contain" />
|
|
|
|
| 84 |
</div>
|
| 85 |
</div>
|
| 86 |
<div>
|
| 87 |
+
<h1 className="text-lg font-bold text-slate-900 tracking-tight group-hover:text-indigo-600 transition-colors">
|
| 88 |
MicroFunnel
|
| 89 |
</h1>
|
| 90 |
+
<p className="text-[10px] text-slate-500 font-medium uppercase tracking-wider">AI Sales Platform</p>
|
| 91 |
</div>
|
| 92 |
</Link>
|
| 93 |
</div>
|
|
|
|
| 97 |
<nav className="flex-1 overflow-y-auto p-4 space-y-6 relative z-10">
|
| 98 |
{[1, 2, 3].map((i) => (
|
| 99 |
<div key={i}>
|
| 100 |
+
<div className="h-3 w-20 bg-slate-200 rounded mb-3 animate-pulse" />
|
| 101 |
<div className="space-y-2">
|
| 102 |
+
<div className="h-10 bg-slate-100 rounded-xl animate-pulse" />
|
| 103 |
+
<div className="h-10 bg-slate-100 rounded-xl animate-pulse" />
|
| 104 |
</div>
|
| 105 |
</div>
|
| 106 |
))}
|
| 107 |
</nav>
|
| 108 |
) : (
|
| 109 |
+
<nav className="flex-1 overflow-y-auto p-4 space-y-8 relative z-10 scrollbar-thin scrollbar-thumb-slate-200 scrollbar-track-transparent">
|
| 110 |
{/* WORKSPACE Group */}
|
| 111 |
<motion.div variants={itemVariants}>
|
| 112 |
<div className="text-[11px] font-bold text-slate-500 uppercase tracking-widest mb-3 px-3 flex items-center gap-2">
|
|
|
|
| 120 |
className={cn(
|
| 121 |
"group flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 font-medium text-sm border border-transparent relative overflow-hidden",
|
| 122 |
isActive('/dashboard')
|
| 123 |
+
? "bg-indigo-50 text-indigo-600 border-indigo-200 shadow-sm"
|
| 124 |
+
: "text-slate-600 hover:text-slate-900 hover:bg-slate-50"
|
| 125 |
)}
|
| 126 |
>
|
| 127 |
{isActive('/dashboard') && (
|
| 128 |
<motion.div
|
| 129 |
layoutId="activeTab"
|
| 130 |
+
className="absolute inset-0 bg-indigo-50 rounded-xl"
|
| 131 |
transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
|
| 132 |
/>
|
| 133 |
)}
|
| 134 |
+
<LayoutDashboard className={cn("w-5 h-5 transition-colors relative z-10", isActive('/dashboard') ? "text-indigo-600" : "text-slate-500 group-hover:text-slate-700")} />
|
| 135 |
<span className="flex-1 relative z-10">Дашборд</span>
|
| 136 |
+
{isActive('/dashboard') && <div className="w-1.5 h-1.5 rounded-full bg-indigo-600 shadow-[0_0_8px_rgba(79,70,229,0.5)] relative z-10"></div>}
|
| 137 |
</Link>
|
| 138 |
)}
|
| 139 |
<Link
|
|
|
|
| 141 |
className={cn(
|
| 142 |
"group flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 font-medium text-sm border border-transparent relative overflow-hidden",
|
| 143 |
isActive('/chats')
|
| 144 |
+
? "bg-indigo-50 text-indigo-600 border-indigo-200 shadow-sm"
|
| 145 |
+
: "text-slate-600 hover:text-slate-900 hover:bg-slate-50"
|
| 146 |
)}
|
| 147 |
>
|
| 148 |
{isActive('/chats') && (
|
| 149 |
<motion.div
|
| 150 |
layoutId="activeTab"
|
| 151 |
+
className="absolute inset-0 bg-indigo-50 rounded-xl"
|
| 152 |
transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
|
| 153 |
/>
|
| 154 |
)}
|
| 155 |
+
<MessageSquare className={cn("w-5 h-5 transition-colors relative z-10", isActive('/chats') ? "text-indigo-600" : "text-slate-500 group-hover:text-slate-700")} />
|
| 156 |
<span className="flex-1 relative z-10">Чаты</span>
|
| 157 |
+
{isActive('/chats') && <div className="w-1.5 h-1.5 rounded-full bg-indigo-600 shadow-[0_0_8px_rgba(79,70,229,0.5)] relative z-10"></div>}
|
| 158 |
</Link>
|
| 159 |
</div>
|
| 160 |
</motion.div>
|
|
|
|
| 172 |
className={cn(
|
| 173 |
"group flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 font-medium text-sm border border-transparent relative overflow-hidden",
|
| 174 |
isActive('/knowledge')
|
| 175 |
+
? "bg-indigo-50 text-indigo-600 border-indigo-200 shadow-sm"
|
| 176 |
+
: "text-slate-600 hover:text-slate-900 hover:bg-slate-50"
|
| 177 |
)}
|
| 178 |
>
|
| 179 |
{isActive('/knowledge') && (
|
| 180 |
<motion.div
|
| 181 |
layoutId="activeTab"
|
| 182 |
+
className="absolute inset-0 bg-indigo-50 rounded-xl"
|
| 183 |
transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
|
| 184 |
/>
|
| 185 |
)}
|
| 186 |
+
<Database className={cn("w-5 h-5 transition-colors relative z-10", isActive('/knowledge') ? "text-indigo-600" : "text-slate-500 group-hover:text-slate-700")} />
|
| 187 |
<span className="flex-1 relative z-10">База Знаний</span>
|
| 188 |
</Link>
|
| 189 |
<Link
|
|
|
|
| 191 |
className={cn(
|
| 192 |
"group flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 font-medium text-sm border border-transparent relative overflow-hidden",
|
| 193 |
isActive('/settings/brain')
|
| 194 |
+
? "bg-indigo-50 text-indigo-600 border-indigo-200 shadow-sm"
|
| 195 |
+
: "text-slate-600 hover:text-slate-900 hover:bg-slate-50"
|
| 196 |
)}
|
| 197 |
>
|
| 198 |
{isActive('/settings/brain') && (
|
| 199 |
<motion.div
|
| 200 |
layoutId="activeTab"
|
| 201 |
+
className="absolute inset-0 bg-indigo-50 rounded-xl"
|
| 202 |
transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
|
| 203 |
/>
|
| 204 |
)}
|
| 205 |
+
<Brain className={cn("w-5 h-5 transition-colors relative z-10", isActive('/settings/brain') ? "text-indigo-600" : "text-slate-500 group-hover:text-slate-700")} />
|
| 206 |
<span className="flex-1 relative z-10">AI Мозг</span>
|
| 207 |
</Link>
|
| 208 |
<Link
|
|
|
|
| 210 |
className={cn(
|
| 211 |
"group flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 font-medium text-sm border border-transparent relative overflow-hidden",
|
| 212 |
isActive('/settings/playbook')
|
| 213 |
+
? "bg-indigo-50 text-indigo-600 border-indigo-200 shadow-sm"
|
| 214 |
+
: "text-slate-600 hover:text-slate-900 hover:bg-slate-50"
|
| 215 |
)}
|
| 216 |
>
|
| 217 |
{isActive('/settings/playbook') && (
|
| 218 |
<motion.div
|
| 219 |
layoutId="activeTab"
|
| 220 |
+
className="absolute inset-0 bg-indigo-50 rounded-xl"
|
| 221 |
transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
|
| 222 |
/>
|
| 223 |
)}
|
| 224 |
+
<Zap className={cn("w-5 h-5 transition-colors relative z-10", isActive('/settings/playbook') ? "text-indigo-600" : "text-slate-500 group-hover:text-slate-700")} />
|
| 225 |
<span className="flex-1 relative z-10">Сценарии</span>
|
| 226 |
</Link>
|
| 227 |
</div>
|
|
|
|
| 241 |
className={cn(
|
| 242 |
"group flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 font-medium text-sm border border-transparent relative overflow-hidden",
|
| 243 |
isActive('/channels')
|
| 244 |
+
? "bg-indigo-50 text-indigo-600 border-indigo-200 shadow-sm"
|
| 245 |
+
: "text-slate-600 hover:text-slate-900 hover:bg-slate-50"
|
| 246 |
)}
|
| 247 |
>
|
| 248 |
{isActive('/channels') && (
|
| 249 |
<motion.div
|
| 250 |
layoutId="activeTab"
|
| 251 |
+
className="absolute inset-0 bg-indigo-50 rounded-xl"
|
| 252 |
transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
|
| 253 |
/>
|
| 254 |
)}
|
| 255 |
+
<Send className={cn("w-5 h-5 transition-colors relative z-10", isActive('/channels') ? "text-indigo-600" : "text-slate-500 group-hover:text-slate-700")} />
|
| 256 |
<span className="flex-1 relative z-10">Каналы</span>
|
| 257 |
</Link>
|
| 258 |
<Link
|
|
|
|
| 260 |
className={cn(
|
| 261 |
"group flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 font-medium text-sm border border-transparent relative overflow-hidden",
|
| 262 |
isActive('/settings/crm')
|
| 263 |
+
? "bg-indigo-50 text-indigo-600 border-indigo-200 shadow-sm"
|
| 264 |
+
: "text-slate-600 hover:text-slate-900 hover:bg-slate-50"
|
| 265 |
)}
|
| 266 |
>
|
| 267 |
{isActive('/settings/crm') && (
|
| 268 |
<motion.div
|
| 269 |
layoutId="activeTab"
|
| 270 |
+
className="absolute inset-0 bg-indigo-50 rounded-xl"
|
| 271 |
transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
|
| 272 |
/>
|
| 273 |
)}
|
| 274 |
+
<Plug className={cn("w-5 h-5 transition-colors relative z-10", isActive('/settings/crm') ? "text-indigo-600" : "text-slate-500 group-hover:text-slate-700")} />
|
| 275 |
<span className="flex-1 relative z-10">CRM Интеграция</span>
|
| 276 |
</Link>
|
| 277 |
</div>
|
|
|
|
| 291 |
className={cn(
|
| 292 |
"group flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 font-medium text-sm border border-transparent relative overflow-hidden",
|
| 293 |
isActive('/settings/team')
|
| 294 |
+
? "bg-indigo-50 text-indigo-600 border-indigo-200 shadow-sm"
|
| 295 |
+
: "text-slate-600 hover:text-slate-900 hover:bg-slate-50"
|
| 296 |
)}
|
| 297 |
>
|
| 298 |
{isActive('/settings/team') && (
|
| 299 |
<motion.div
|
| 300 |
layoutId="activeTab"
|
| 301 |
+
className="absolute inset-0 bg-indigo-50 rounded-xl"
|
| 302 |
transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
|
| 303 |
/>
|
| 304 |
)}
|
| 305 |
+
<Users className={cn("w-5 h-5 transition-colors relative z-10", isActive('/settings/team') ? "text-indigo-600" : "text-slate-500 group-hover:text-slate-700")} />
|
| 306 |
<span className="flex-1 relative z-10">Команда</span>
|
| 307 |
</Link>
|
| 308 |
</div>
|
|
|
|
| 312 |
)}
|
| 313 |
|
| 314 |
{/* Bottom Section */}
|
| 315 |
+
<div className="mt-auto border-t border-slate-200 relative z-10 bg-slate-50/50 backdrop-blur-sm">
|
| 316 |
{/* Partner Program Link */}
|
| 317 |
{user?.role === 'OWNER' && (
|
| 318 |
+
<div className="p-4 border-b border-slate-200">
|
| 319 |
<Link
|
| 320 |
href="/settings/partner"
|
| 321 |
+
className="flex items-center gap-3 px-3 py-3 rounded-xl bg-gradient-to-r from-amber-500 to-orange-500 hover:from-amber-600 hover:to-orange-600 text-white transition-all duration-200 shadow-lg shadow-amber-500/20 font-medium text-sm group border border-white/10 relative overflow-hidden"
|
| 322 |
>
|
| 323 |
<div className="absolute inset-0 bg-white/20 translate-x-[-100%] group-hover:translate-x-[100%] transition-transform duration-700" />
|
| 324 |
<DollarSign className="w-5 h-5 text-amber-100" />
|
| 325 |
+
<span className="flex-1 font-bold">
|
| 326 |
Партнерская программа
|
| 327 |
</span>
|
| 328 |
+
<ChevronRight className="w-4 h-4 text-amber-100 group-hover:translate-x-0.5 transition-transform" />
|
| 329 |
</Link>
|
| 330 |
</div>
|
| 331 |
)}
|
|
|
|
| 333 |
{/* User Profile Card or Sign In Fallback */}
|
| 334 |
{user ? (
|
| 335 |
<div className="p-4">
|
| 336 |
+
<div className="flex items-center gap-3 px-3 py-2.5 rounded-xl bg-white hover:bg-slate-50 transition-colors border border-slate-200 group shadow-sm">
|
| 337 |
{/* Avatar with Initials */}
|
| 338 |
<div className={cn(
|
| 339 |
"w-10 h-10 rounded-full flex items-center justify-center text-white font-bold text-sm shadow-inner transition-transform group-hover:scale-105",
|
|
|
|
| 344 |
|
| 345 |
{/* User Info */}
|
| 346 |
<div className="flex-1 min-w-0">
|
| 347 |
+
<p className="text-sm font-semibold text-slate-900 truncate group-hover:text-indigo-600 transition-colors">
|
| 348 |
{user.full_name || user.email}
|
| 349 |
</p>
|
| 350 |
<div className="flex items-center gap-1.5">
|
| 351 |
<span className={cn(
|
| 352 |
"px-1.5 py-0.5 rounded text-[10px] font-bold uppercase tracking-wide",
|
| 353 |
user.role === 'OWNER'
|
| 354 |
+
? "bg-indigo-50 text-indigo-600 border border-indigo-200"
|
| 355 |
+
: "bg-slate-100 text-slate-500 border border-slate-200"
|
| 356 |
)}>
|
| 357 |
{user.role === 'OWNER' ? 'Владелец' : 'Менеджер'}
|
| 358 |
</span>
|
|
|
|
| 362 |
{/* Logout Button */}
|
| 363 |
<button
|
| 364 |
onClick={logout}
|
| 365 |
+
className="p-2 rounded-lg text-slate-400 hover:text-red-600 hover:bg-red-50 transition-all duration-200"
|
| 366 |
title="Выйти"
|
| 367 |
>
|
| 368 |
<LogOut className="w-5 h-5" />
|
|
|
|
| 374 |
<div className="p-4">
|
| 375 |
<Link
|
| 376 |
href="/login"
|
| 377 |
+
className="flex items-center justify-center gap-2 px-4 py-3 rounded-xl bg-indigo-600 hover:bg-indigo-700 text-white transition-all duration-200 font-bold text-sm shadow-lg shadow-indigo-500/20"
|
| 378 |
>
|
| 379 |
<LogOut className="w-5 h-5" />
|
| 380 |
Войти в систему
|