Spaces:
Running
Running
Download frontend/components/ChatWindow/ChatHeader.tsx from axeronis/microfunnel-api: direct link, hf CLI and curl.
- Browser
- Download file 6.38 kB
-
https://huggingface.co/spaces/axeronis/microfunnel-api/resolve/main/frontend/components/ChatWindow/ChatHeader.tsx
- Command line
-
hf download hf://spaces/axeronis/microfunnel-api/frontend/components/ChatWindow/ChatHeader.tsx
-
curl -L -o ChatHeader.tsx https://huggingface.co/spaces/axeronis/microfunnel-api/resolve/main/frontend/components/ChatWindow/ChatHeader.tsx
6.38 kB
| 'use client' | |
| import { cn } from '@/lib/utils' | |
| import { ArrowLeft, Bot, Brain, Calendar, Info, Loader2, MoreVertical, Sparkles, GraduationCap } from 'lucide-react' | |
| import { useState, useEffect } from 'react' | |
| import { motion } from 'framer-motion' | |
| import type { Lead } from '@/types' | |
| interface ChatHeaderProps { | |
| lead?: Lead | |
| isAnalyzing?: boolean | |
| isAIActive: boolean | |
| isTogglingAI: boolean | |
| isLeadsListOpen?: boolean | |
| onToggleLeadsList?: () => void | |
| onBack?: () => void | |
| onToggleAI: () => void | |
| onOpenMobileDrawer?: () => void | |
| onOpenBookingModal: () => void | |
| onTrainAI?: () => void | |
| } | |
| export function ChatHeader({ | |
| lead, | |
| isAnalyzing, | |
| isAIActive, | |
| isTogglingAI, | |
| isLeadsListOpen, | |
| onToggleLeadsList, | |
| onBack, | |
| onToggleAI, | |
| onOpenMobileDrawer, | |
| onOpenBookingModal, | |
| onTrainAI, | |
| }: ChatHeaderProps) { | |
| const [mounted, setMounted] = useState(false) | |
| useEffect(() => { | |
| setMounted(true) | |
| }, []) | |
| if (!mounted) return null | |
| return ( | |
| <div className="h-[52px] md:h-16 shrink-0 flex items-center justify-between px-3 md:px-6 relative z-[50] bg-[#050510]/60 backdrop-blur-xl border-b border-white/5"> | |
| {/* Aurora Background Atmosphere - Synced */} | |
| <div className="absolute inset-0 pointer-events-none overflow-hidden -z-10 bg-gradient-to-r from-indigo-500/5 to-purple-500/5 opacity-30 blur-xl" /> | |
| {/* Left: Lead Info */} | |
| <div className="flex items-center gap-2 md:gap-3 overflow-hidden"> | |
| {/* Back Button (Phone only - strictly hidden on md+) */} | |
| <div className="md:hidden"> | |
| <button | |
| onClick={onBack} | |
| className="p-1.5 -ml-1 text-slate-400 hover:text-white hover:bg-white/10 rounded-full transition-colors" | |
| > | |
| <ArrowLeft className="w-5 h-5" /> | |
| </button> | |
| </div> | |
| {/* Tablet/Desktop Toggle - only visible on Desktop (lg+) */} | |
| <button | |
| onClick={onToggleLeadsList} | |
| className="hidden lg:flex p-2 -ml-2 text-slate-400 hover:text-indigo-400 hover:bg-white/5 rounded-lg transition-all" | |
| title={isLeadsListOpen ? "Скрыть список" : "Показать список"} | |
| > | |
| {isLeadsListOpen ? <ArrowLeft className="w-5 h-5" /> : <MoreVertical className="w-5 h-5 rotate-90" />} | |
| </button> | |
| <div className="flex items-center gap-2 md:gap-3"> | |
| <div className="w-7 h-7 md:w-10 md:h-10 rounded-full bg-gradient-to-br from-indigo-600/30 to-purple-600/30 flex items-center justify-center text-indigo-400 font-bold text-[10px] md:text-sm border border-indigo-500/20 shadow-sm shrink-0"> | |
| {lead?.name?.charAt(0) || 'L'} | |
| </div> | |
| <div className="min-w-0"> | |
| <h2 className="font-bold text-white text-[13px] md:text-sm truncate max-w-[100px] sm:max-w-none leading-none mb-0.5">{lead?.name || 'Лид'}</h2> | |
| <div className="flex items-center gap-2"> | |
| {(lead as any)?.channel_source && ( | |
| <span className="text-[10px] text-slate-500 font-medium">{(lead as any)?.channel_source}</span> | |
| )} | |
| {lead?.needs_attention && ( | |
| <span className="flex items-center gap-1 text-[9px] text-red-400 bg-red-500/10 px-1.5 py-0 rounded-full border border-red-500/20 font-semibold leading-tight animate-pulse"> | |
| Внимание | |
| </span> | |
| )} | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <div className="flex items-center gap-1.5 md:gap-3"> | |
| <button | |
| onClick={onOpenBookingModal} | |
| className="hidden sm:flex items-center gap-2 px-2 md:px-3 py-1.5 rounded-lg text-[11px] font-semibold bg-white/5 text-slate-300 border border-white/10 hover:bg-white/10 transition-all" | |
| title="Записать на встречу" | |
| > | |
| <Calendar className="w-3.5 h-3.5 text-slate-500" /> | |
| Записать | |
| </button> | |
| {/* AI Toggle Switch - Clean Design */} | |
| <button | |
| onClick={onToggleAI} | |
| disabled={isTogglingAI} | |
| className={cn( | |
| "relative w-12 min-w-[48px] h-6 flex-shrink-0 rounded-full transition-all duration-300 border", | |
| isAIActive | |
| ? "bg-indigo-500 border-indigo-400 shadow-[0_2px_8px_rgba(99,102,241,0.3)]" | |
| : "bg-white/10 border-white/10 hover:bg-white/20", | |
| isTogglingAI && "opacity-80" | |
| )} | |
| title={isAIActive ? 'AI Активен' : 'AI Отключен'} | |
| > | |
| {/* Thumb */} | |
| <motion.div | |
| animate={{ | |
| x: isAIActive ? 26 : 2, | |
| scale: isTogglingAI ? 0.8 : 1, | |
| }} | |
| transition={{ type: "spring", stiffness: 500, damping: 30 }} | |
| className="absolute top-[2px] w-[18px] h-[18px] rounded-full bg-white shadow-sm flex items-center justify-center z-10" | |
| > | |
| {isTogglingAI && ( | |
| <Loader2 className="w-3 h-3 animate-spin text-indigo-500" /> | |
| )} | |
| </motion.div> | |
| </button> | |
| {/* AI Summary Button */} | |
| <button | |
| onClick={onOpenMobileDrawer} | |
| className="flex lg:hidden p-1.5 text-slate-400 hover:text-indigo-400 hover:bg-white/5 rounded-lg transition-all active:scale-95" | |
| title="AI-анализ" | |
| > | |
| <Brain className="w-[18px] h-[18px]" /> | |
| </button> | |
| </div> | |
| </div > | |
| ) | |
| } | |