Spaces:
Sleeping

axeronis commited on
Commit
66a0f3d
·
1 Parent(s): 3612601

feat: restore persistent desktop AI summary and implement right-side overlay for tablets/phones

Browse files
frontend/app/chats/page.tsx CHANGED
@@ -293,28 +293,14 @@ function ChatsContent() {
293
  )}
294
  </div>
295
 
296
- {/* Right Column: Client Intelligence (Tablet/Desktop Sidebar) */}
297
- <AnimatePresence>
298
- {isSummaryOpen && selectedLead && (
299
- <motion.div
300
- initial={{ x: '100%', opacity: 0 }}
301
- animate={{ x: 0, opacity: 1 }}
302
- exit={{ x: '100%', opacity: 0 }}
303
- transition={{ type: 'spring', damping: 30, stiffness: 300 }}
304
- className={cn(
305
- "hidden md:block h-full border-l border-white/10 bg-background z-20 overflow-y-auto custom-scrollbar relative shrink-0",
306
- // Desktop: Fixed width
307
- "md:w-[320px] lg:w-[360px] xl:w-[400px]"
308
- )}
309
- >
310
- {/* Desktop Close Icon (Optional, since we have the Brain toggle, but good for UX) */}
311
- <button
312
- onClick={() => setIsSummaryOpen(false)}
313
- className="absolute top-4 right-4 z-30 p-2 hover:bg-white/5 rounded-full text-slate-500 hover:text-white transition-all xl:hidden"
314
- >
315
- <X className="w-4 h-4" />
316
- </button>
317
-
318
  <ClientCard
319
  lead={selectedLead}
320
  onTakeover={() => { }}
@@ -323,51 +309,66 @@ function ChatsContent() {
323
  conversationId={conversation?.id}
324
  tenantId={user.tenant_id}
325
  />
326
- </motion.div>
327
- )}
328
- </AnimatePresence>
329
-
330
- {/* Mobile Drawer for AI Summary (< 768px) */}
331
- <AnimatePresence>
332
- {isSummaryOpen && selectedLead && (
333
- <div className="md:hidden">
334
- {/* Backdrop */}
335
- <motion.div
336
- initial={{ opacity: 0 }}
337
- animate={{ opacity: 1 }}
338
- exit={{ opacity: 0 }}
339
- onClick={() => setIsSummaryOpen(false)}
340
- className="fixed inset-0 top-[128px] bottom-14 bg-black/40 backdrop-blur-[2px] z-30"
341
- />
342
 
343
- <motion.div
344
- drag="x"
345
- dragConstraints={{ left: 0, right: 300 }}
346
- dragElastic={0.05}
347
- onDragEnd={(_, info) => {
348
- if (info.offset.x > 80 || info.velocity.x > 300) {
349
- setIsSummaryOpen(false)
350
- }
351
- }}
352
- initial={{ x: '100%', opacity: 0 }}
353
- animate={{ x: 0, opacity: 1 }}
354
- exit={{ x: '100%', opacity: 0 }}
355
- transition={{ type: 'spring', damping: 25, stiffness: 200 }}
356
- className="fixed (right-0) top-[128px] bottom-14 right-0 w-[92%] sm:w-96 bg-[#050510]/95 backdrop-blur-2xl border-l border-white/10 z-30 flex flex-col shadow-[0_0_50px_rgba(0,0,0,0.5)] rounded-l-[24px] overflow-hidden"
357
- >
358
- <div className="flex-1 min-h-0">
359
- <ClientCard
360
- lead={selectedLead}
361
- onTakeover={() => { }}
362
- isAnalyzing={selectedLead.processing_status === 'analyzing'}
363
- onRefresh={handleRefresh}
364
- tenantId={user.tenant_id}
365
- />
366
- </div>
367
- </motion.div>
368
- </div>
369
- )}
370
- </AnimatePresence>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
371
  </div>
372
  )
373
  }
 
293
  )}
294
  </div>
295
 
296
+ {/* Right Column: AI Intelligence (Persistent on Desktop lg+, Overlay on Mobile/Tablet <lg) */}
297
+ <div className="flex shrink-0">
298
+ {/* 1. PERSISTENT DESKTOP SIDEBAR (lg and above) */}
299
+ <div className={cn(
300
+ "hidden lg:block h-full border-l border-white/10 bg-background overflow-y-auto custom-scrollbar relative",
301
+ "w-[320px] xl:w-[380px]"
302
+ )}>
303
+ {selectedLead ? (
 
 
 
 
 
 
 
 
 
 
 
 
 
 
304
  <ClientCard
305
  lead={selectedLead}
306
  onTakeover={() => { }}
 
309
  conversationId={conversation?.id}
310
  tenantId={user.tenant_id}
311
  />
312
+ ) : (
313
+ <div className="h-full flex items-center justify-center text-slate-600 text-sm">
314
+ Нет данных
315
+ </div>
316
+ )}
317
+ </div>
 
 
 
 
 
 
 
 
 
 
318
 
319
+ {/* 2. OVERLAY FOR TABLET/MOBILE (< lg) */}
320
+ <AnimatePresence>
321
+ {isSummaryOpen && selectedLead && (
322
+ <div className="lg:hidden">
323
+ {/* Backdrop */}
324
+ <motion.div
325
+ initial={{ opacity: 0 }}
326
+ animate={{ opacity: 1 }}
327
+ exit={{ opacity: 0 }}
328
+ onClick={() => setIsSummaryOpen(false)}
329
+ className="fixed inset-0 top-[128px] bottom-14 bg-black/50 backdrop-blur-sm z-40"
330
+ />
331
+
332
+ <motion.div
333
+ drag="x"
334
+ dragConstraints={{ left: 0, right: 300 }}
335
+ dragElastic={0.05}
336
+ onDragEnd={(_, info) => {
337
+ if (info.offset.x > 80 || info.velocity.x > 300) {
338
+ setIsSummaryOpen(false)
339
+ }
340
+ }}
341
+ initial={{ x: '100%', opacity: 0 }}
342
+ animate={{ x: 0, opacity: 1 }}
343
+ exit={{ x: '100%', opacity: 0 }}
344
+ transition={{ type: 'spring', damping: 25, stiffness: 200 }}
345
+ className="fixed right-0 top-[128px] bottom-14 w-[92%] sm:w-[380px] bg-[#0D0E18]/95 backdrop-blur-3xl border-l border-white/10 z-50 flex flex-col shadow-[0_0_50px_rgba(0,0,0,0.5)] rounded-l-[32px] overflow-hidden"
346
+ >
347
+ {/* Drag handle indicator */}
348
+ <div className="absolute top-2 left-1/2 -translate-x-1/2 w-8 h-1 bg-white/10 rounded-full z-50" />
349
+
350
+ {/* Floating Close Button */}
351
+ <button
352
+ onClick={() => setIsSummaryOpen(false)}
353
+ className="absolute top-4 right-4 z-[60] p-2 bg-white/5 hover:bg-white/10 rounded-full text-slate-400 hover:text-white transition-all backdrop-blur-md border border-white/5 shadow-xl"
354
+ >
355
+ <X className="w-5 h-5" />
356
+ </button>
357
+
358
+ <div className="flex-1 min-h-0 pt-4">
359
+ <ClientCard
360
+ lead={selectedLead}
361
+ onTakeover={() => { }}
362
+ isAnalyzing={selectedLead.processing_status === 'analyzing'}
363
+ onRefresh={handleRefresh}
364
+ tenantId={user.tenant_id}
365
+ />
366
+ </div>
367
+ </motion.div>
368
+ </div>
369
+ )}
370
+ </AnimatePresence>
371
+ </div>
372
  </div>
373
  )
374
  }
frontend/components/ChatWindow/ChatHeader.tsx CHANGED
@@ -141,10 +141,10 @@ export function ChatHeader({
141
  </button>
142
  </div>
143
 
144
- {/* AI Summary Button - Now visible on all devices to toggle intelligence panel/drawer */}
145
  <button
146
  onClick={onOpenMobileDrawer}
147
- className="flex p-2 text-slate-400 hover:text-indigo-400 hover:bg-white/5 rounded-lg transition-all"
148
  title="Посмотреть AI-анализ"
149
  >
150
  <Brain className="w-5 h-5 transition-colors group-hover:text-indigo-400" />
 
141
  </button>
142
  </div>
143
 
144
+ {/* AI Summary Button - Visible on mobile/tablet to toggle intelligence panel/drawer. Hidden on lg where it's persistent. */}
145
  <button
146
  onClick={onOpenMobileDrawer}
147
+ className="flex lg:hidden p-2 text-slate-400 hover:text-indigo-400 hover:bg-white/5 rounded-lg transition-all"
148
  title="Посмотреть AI-анализ"
149
  >
150
  <Brain className="w-5 h-5 transition-colors group-hover:text-indigo-400" />
frontend/components/ClientCard.tsx CHANGED
@@ -181,72 +181,63 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
181
  ]
182
 
183
  return (
184
- <div className="h-full flex flex-col bg-[#0D0E18]/80 backdrop-blur-3xl font-['Inter'] relative overflow-hidden group/card">
185
- {/* Background Atmosphere */}
186
- <div className="absolute top-0 right-0 w-64 h-64 bg-indigo-500/5 blur-[100px] -z-10 group-hover/card:bg-indigo-500/10 transition-colors duration-700" />
187
- <div className="absolute bottom-0 left-0 w-64 h-64 bg-purple-500/5 blur-[100px] -z-10 group-hover/card:bg-purple-500/10 transition-colors duration-700" />
188
 
189
  {/* Content */}
190
- <div className="flex-1 overflow-y-auto p-4 md:p-6 space-y-6 scrollbar-thin scrollbar-thumb-white/10">
191
 
192
  {/* Header Title with Icon */}
193
- <div className="flex items-center gap-4 mb-2">
194
- <div className="w-12 h-12 rounded-2xl bg-gradient-to-br from-indigo-500/20 to-purple-600/20 flex items-center justify-center text-indigo-400 border border-white/10 shadow-lg">
195
- <Brain className="w-6 h-6" />
196
  </div>
197
  <div>
198
- <h2 className="text-lg font-bold text-white tracking-tight">{t('clientCard.chatSummary')}</h2>
199
- <div className="flex items-center gap-2 mt-0.5">
200
- <span className="text-[10px] text-slate-500 uppercase tracking-widest font-bold">{t('common.aiGenerated')}</span>
201
- <div className="w-1 h-1 rounded-full bg-indigo-500/50" />
202
- <span className="text-[10px] text-indigo-400/70 font-bold uppercase tracking-widest italic">Quantum Analysis</span>
203
- </div>
204
  </div>
205
  </div>
206
 
207
  {/* QUALIFICATION CARD - Quick Info */}
208
  {(lead as any).qualification_data && Object.keys((lead as any).qualification_data).length > 0 && (
209
  <div className={cn(
210
- "rounded-[24px] p-5 border transition-all duration-500 shadow-xl relative overflow-hidden",
211
  (lead as any).qualification_complete
212
  ? "bg-emerald-500/5 border-emerald-500/20"
213
  : "bg-white/5 border-white/10"
214
  )}>
215
- <div className="flex items-center justify-between mb-4">
216
- <div className="flex items-center gap-3">
217
  <div className={cn(
218
- "w-8 h-8 rounded-xl flex items-center justify-center shadow-inner",
219
  (lead as any).qualification_complete
220
- ? "bg-emerald-500/20 text-emerald-400 border border-emerald-500/30"
221
- : "bg-amber-500/20 text-amber-400 border border-amber-500/30"
222
  )}>
223
  {(lead as any).qualification_complete
224
- ? <CheckCircle2 className="w-5 h-5" />
225
- : <Target className="w-5 h-5" />}
226
  </div>
227
- <span className="text-sm font-bold text-white tracking-tight">
228
- {(lead as any).qualification_complete ? 'Клиент Квалифицирован' : 'Квалификация Лида'}
229
  </span>
230
  </div>
231
  {(lead as any).qualification_complete && (
232
- <div className="px-2 py-1 rounded-md bg-emerald-500/10 border border-emerald-500/20">
233
- <span className="text-[10px] uppercase tracking-tighter text-emerald-400 font-black">
234
- PASSED
235
- </span>
236
- </div>
237
  )}
238
  </div>
239
- <div className="grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-3">
240
  {Object.entries((lead as any).qualification_data).map(([field, value]: [string, any]) => {
241
  const isNotFound = !value || value.toLowerCase?.().includes('не выявлено') || value.toLowerCase?.().includes('не указано')
242
  return (
243
- <div key={field} className="flex flex-col gap-0.5 group/item">
244
- <span className="text-[10px] text-slate-500 uppercase font-bold tracking-wider group-hover/item:text-slate-400 transition-colors">{field}</span>
245
  <span className={cn(
246
- "text-xs font-semibold tracking-tight",
247
- isNotFound ? "text-slate-600 italic font-medium" : "text-slate-200"
248
  )}>
249
- {isNotFound ? '...' : String(value)}
250
  </span>
251
  </div>
252
  )
@@ -255,87 +246,56 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
255
  </div>
256
  )}
257
 
258
- {/* Multi-Column Summary List */}
259
- <div className="grid grid-cols-1 xl:grid-cols-2 gap-4">
260
- {summaryPoints.map((point, i) => {
261
- // Logic to identify special points (Pain points, objections, etc)
262
- const isPainPoint = point.toLowerCase().includes('боли') || point.toLowerCase().includes('pain')
263
- const isObjection = point.toLowerCase().includes('возражения') || point.toLowerCase().includes('objection')
264
-
265
- return (
266
- <div
267
- key={i}
268
- className={cn(
269
- "flex gap-4 p-4 rounded-2xl transition-all duration-300 border",
270
- isPainPoint ? "bg-red-500/5 border-red-500/10 group/pt hover:bg-red-500/10" :
271
- isObjection ? "bg-amber-500/5 border-amber-500/10 group/pt hover:bg-amber-500/10" :
272
- "bg-white/[0.03] border-white/5 hover:bg-white/5 group/pt"
273
- )}
274
- >
275
- <div className="flex flex-col items-center gap-1">
276
- <span className={cn(
277
- "text-[10px] font-black w-7 h-7 rounded-lg flex items-center justify-center transition-all duration-500 shadow-sm",
278
- isPainPoint ? "bg-red-500/20 text-red-400 border border-red-500/20" :
279
- isObjection ? "bg-amber-500/20 text-amber-400 border border-amber-500/20" :
280
- "bg-white/5 text-slate-500 group-hover/pt:text-indigo-400 group-hover/pt:bg-indigo-500/10 group-hover/pt:border-indigo-500/20 border border-transparent"
281
- )}>
282
- {isPainPoint ? <AlertCircle className="w-3.5 h-3.5" /> :
283
- isObjection ? <AlertTriangle className="w-3.5 h-3.5" /> :
284
- (i + 1)}
285
- </span>
286
- </div>
287
- <p className={cn(
288
- "text-sm leading-relaxed font-medium transition-colors",
289
- isPainPoint ? "text-red-200" :
290
- isObjection ? "text-amber-200" :
291
- "text-slate-300 group-hover/pt:text-white"
292
- )}>
293
- {point}
294
- </p>
295
  </div>
296
- )
297
- })}
 
298
  </div>
299
 
300
  </div>
301
 
302
- <div className="p-4 md:p-6 pb-20 md:pb-8 mt-auto relative bg-[#0D0E18]/50 backdrop-blur-xl border-t border-white/5">
303
- <div className="bg-gradient-to-br from-[#1A1B26] to-[#0D0E18] rounded-3xl p-6 border border-white/10 relative overflow-hidden group/heat">
304
- {/* Heat Glow Effect */}
305
  <div className={cn(
306
- "absolute -top-10 -right-10 w-40 h-40 blur-[50px] rounded-full pointer-events-none group-hover/heat:opacity-100 opacity-60 transition-all duration-700",
307
  visuals.glow
308
  )} />
309
 
310
- <h3 className="text-xs font-bold text-slate-400 uppercase tracking-widest mb-6 relative z-10">{t('clientCard.heatLevel')}</h3>
311
 
312
- <div className="flex items-end gap-6 relative z-10">
313
  {/* Thermometer Icon Placeholder (Custom Graphic) */}
314
- <div className="h-24 w-10 bg-black/40 rounded-full relative overflow-hidden ring-1 ring-white/10 p-1 group-hover/heat:ring-white/20 transition-all">
315
  <div
316
  className={cn(
317
- "absolute bottom-0 left-0 right-0 bg-gradient-to-t transition-all duration-[1500ms] cubic-bezier(0.4, 0, 0.2, 1)",
318
  visuals.gradient
319
  )}
320
  style={{ height: `${data.heat_score}%` }}
321
  />
322
- {/* Internal marks */}
323
- <div className="absolute inset-0 flex flex-col justify-between py-4 pointer-events-none opacity-20">
324
- {[1, 2, 3, 4, 5].map(i => <div key={i} className="w-full h-px bg-white" />)}
325
- </div>
326
  {/* Bulb */}
327
  <div
328
- className={cn("absolute bottom-1.5 left-2 right-2 h-6 w-6 rounded-full transition-colors duration-700 shadow-[0_0_15px_rgba(0,0,0,0.5)]", visuals.bulb)}
329
- style={{ boxShadow: `0 0 20px ${visuals.shadow}` }}
330
  />
331
  </div>
332
 
333
- <div className="flex-1 pb-1">
334
  <div className="flex items-baseline gap-2">
335
- <span className="text-5xl font-black text-white tracking-tighter drop-shadow-2xl">{data.heat_score}%</span>
336
- <Flame className={cn("w-8 h-8 animate-pulse", getScoreColor(data.heat_score))} />
337
  </div>
338
- <p className={cn("text-sm font-black uppercase tracking-widest mt-2", getScoreColor(data.heat_score))}>
339
  {data.heat_score >= 80 ? t('clientCard.high') : data.heat_score >= 40 ? t('clientCard.medium') : t('clientCard.low')}
340
  </p>
341
  </div>
 
181
  ]
182
 
183
  return (
184
+ <div className="h-full flex flex-col bg-[#0D0E18] font-['Inter'] relative">
 
 
 
185
 
186
  {/* Content */}
187
+ <div className="flex-1 overflow-y-auto p-5 space-y-5 scrollbar-thin scrollbar-thumb-white/10">
188
 
189
  {/* Header Title with Icon */}
190
+ <div className="flex items-center gap-3 mb-2 p-1">
191
+ <div className="w-10 h-10 rounded-xl bg-indigo-500/10 flex items-center justify-center text-indigo-400 border border-indigo-500/20">
192
+ <Brain className="w-5 h-5" />
193
  </div>
194
  <div>
195
+ <h2 className="text-base font-bold text-white tracking-tight">{t('clientCard.chatSummary')}</h2>
196
+ <p className="text-[10px] text-slate-500 uppercase tracking-widest font-semibold">{t('common.aiGenerated') || 'AI Generated'}</p>
 
 
 
 
197
  </div>
198
  </div>
199
 
200
  {/* QUALIFICATION CARD - Quick Info */}
201
  {(lead as any).qualification_data && Object.keys((lead as any).qualification_data).length > 0 && (
202
  <div className={cn(
203
+ "rounded-xl p-4 mb-4 border transition-all",
204
  (lead as any).qualification_complete
205
  ? "bg-emerald-500/5 border-emerald-500/20"
206
  : "bg-white/5 border-white/10"
207
  )}>
208
+ <div className="flex items-center justify-between mb-3">
209
+ <div className="flex items-center gap-2">
210
  <div className={cn(
211
+ "w-6 h-6 rounded-full flex items-center justify-center",
212
  (lead as any).qualification_complete
213
+ ? "bg-emerald-500/20 text-emerald-400"
214
+ : "bg-amber-500/20 text-amber-400"
215
  )}>
216
  {(lead as any).qualification_complete
217
+ ? <CheckCircle2 className="w-4 h-4" />
218
+ : <Target className="w-4 h-4" />}
219
  </div>
220
+ <span className="text-sm font-medium text-white">
221
+ {(lead as any).qualification_complete ? 'Квалифицирован' : 'Квалификация'}
222
  </span>
223
  </div>
224
  {(lead as any).qualification_complete && (
225
+ <span className="text-[10px] uppercase tracking-wider text-emerald-400 font-semibold">
226
+ ✓ Полная
227
+ </span>
 
 
228
  )}
229
  </div>
230
+ <div className="space-y-2">
231
  {Object.entries((lead as any).qualification_data).map(([field, value]: [string, any]) => {
232
  const isNotFound = !value || value.toLowerCase?.().includes('не выявлено') || value.toLowerCase?.().includes('не указано')
233
  return (
234
+ <div key={field} className="flex justify-between items-center">
235
+ <span className="text-xs text-slate-400">{field}:</span>
236
  <span className={cn(
237
+ "text-xs font-medium",
238
+ isNotFound ? "text-slate-500 italic" : "text-white"
239
  )}>
240
+ {isNotFound ? 'Не выявлено' : String(value)}
241
  </span>
242
  </div>
243
  )
 
246
  </div>
247
  )}
248
 
249
+ {/* Numbered Summary List */}
250
+ <div className="space-y-4 px-1">
251
+ {summaryPoints.map((point, i) => (
252
+ <div key={i} className="flex gap-4 items-start group/point">
253
+ <div className="flex flex-col items-center gap-1 mt-1">
254
+ <span className="text-[11px] font-bold text-slate-500 bg-white/5 w-6 h-6 rounded-md flex items-center justify-center group-hover/point:text-indigo-400 group-hover/point:bg-indigo-500/10 transition-colors">
255
+ {i + 1}
256
+ </span>
257
+ {i < summaryPoints.length - 1 && <div className="w-[1px] h-4 bg-white/5" />}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  </div>
259
+ <p className="text-slate-300 text-sm leading-relaxed flex-1 group-hover/point:text-white transition-colors">{point}</p>
260
+ </div>
261
+ ))}
262
  </div>
263
 
264
  </div>
265
 
266
+ <div className="p-5 pb-8 mt-auto">
267
+ <div className="bg-[#1A1B26] rounded-2xl p-5 border border-white/5 relative overflow-hidden group">
268
+ {/* Glow Effect */}
269
  <div className={cn(
270
+ "absolute top-0 right-0 w-32 h-32 blur-[40px] rounded-full pointer-events-none group-hover:opacity-100 opacity-50 transition-all duration-500",
271
  visuals.glow
272
  )} />
273
 
274
+ <h3 className="text-sm font-medium text-slate-300 mb-4 relative z-10">{t('clientCard.heatLevel')}</h3>
275
 
276
+ <div className="flex items-center gap-4 relative z-10">
277
  {/* Thermometer Icon Placeholder (Custom Graphic) */}
278
+ <div className="h-16 w-8 bg-slate-800 rounded-full relative overflow-hidden ring-1 ring-white/10">
279
  <div
280
  className={cn(
281
+ "absolute bottom-0 left-0 right-0 bg-gradient-to-t transition-all duration-1000",
282
  visuals.gradient
283
  )}
284
  style={{ height: `${data.heat_score}%` }}
285
  />
 
 
 
 
286
  {/* Bulb */}
287
  <div
288
+ className={cn("absolute bottom-1 left-1.5 right-1.5 h-5 w-5 rounded-full transition-colors duration-500", visuals.bulb)}
289
+ style={{ boxShadow: `0 0 10px ${visuals.shadow}` }}
290
  />
291
  </div>
292
 
293
+ <div>
294
  <div className="flex items-baseline gap-2">
295
+ <span className="text-4xl font-bold text-white tracking-tight">{data.heat_score}%</span>
296
+ <Flame className={cn("w-6 h-6 animate-pulse", getScoreColor(data.heat_score))} />
297
  </div>
298
+ <p className={cn("text-sm font-medium mt-1", getScoreColor(data.heat_score))}>
299
  {data.heat_score >= 80 ? t('clientCard.high') : data.heat_score >= 40 ? t('clientCard.medium') : t('clientCard.low')}
300
  </p>
301
  </div>