Spaces:
Running
Running
axeronis commited on
Commit ·
71a56fb
1
Parent(s): 257d187
fix: resolve lead name bug on tablets and refine summary overlay dimensions
Browse files
frontend/app/chats/page.tsx
CHANGED
|
@@ -21,6 +21,7 @@ function ChatsContent() {
|
|
| 21 |
const { user, isLoading: authLoading } = useAuth()
|
| 22 |
const toast = useToast()
|
| 23 |
const [selectedLead, setSelectedLead] = useState<Lead | undefined>(undefined)
|
|
|
|
| 24 |
const [messages, setMessages] = useState<Message[]>([])
|
| 25 |
const [messagesLoading, setMessagesLoading] = useState(false)
|
| 26 |
const [searchQuery, setSearchQuery] = useState('')
|
|
@@ -28,7 +29,6 @@ function ChatsContent() {
|
|
| 28 |
const [conversation, setConversation] = useState<any>(null)
|
| 29 |
const [isLeadsListOpen, setIsLeadsListOpen] = useState(true)
|
| 30 |
const [isSummaryOpen, setIsSummaryOpen] = useState(false) // Unified state for Desktop/Tablet Sidebar and Mobile Drawer
|
| 31 |
-
const [isMobileSummaryOpen_DEPRECATED, setIsMobileSummaryOpen] = useState(false)
|
| 32 |
const { t } = useTranslation()
|
| 33 |
|
| 34 |
// Fetch Leads
|
|
@@ -159,7 +159,7 @@ function ChatsContent() {
|
|
| 159 |
}
|
| 160 |
|
| 161 |
const handleShowSummary = (lead: Lead) => {
|
| 162 |
-
|
| 163 |
setIsSummaryOpen(true)
|
| 164 |
}
|
| 165 |
|
|
@@ -281,7 +281,14 @@ function ChatsContent() {
|
|
| 281 |
}}
|
| 282 |
onToggleLeadsList={() => setIsLeadsListOpen(!isLeadsListOpen)}
|
| 283 |
isLeadsListOpen={isLeadsListOpen}
|
| 284 |
-
onOpenMobileDrawer={() =>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 285 |
/>
|
| 286 |
) : (
|
| 287 |
<div className="h-full flex flex-col items-center justify-center text-slate-500">
|
|
@@ -318,15 +325,15 @@ function ChatsContent() {
|
|
| 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 right-0 top-16 md:top-0 bottom-
|
| 330 |
/>
|
| 331 |
|
| 332 |
<motion.div
|
|
@@ -336,19 +343,20 @@ function ChatsContent() {
|
|
| 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: 30, stiffness: 250, mass: 0.8 }}
|
| 345 |
-
className="fixed right-0 top-16 md:top-0 bottom-
|
| 346 |
style={{ willChange: 'transform', transform: 'translateZ(0)' }}
|
| 347 |
>
|
| 348 |
|
| 349 |
{/* Floating Close Button */}
|
| 350 |
<button
|
| 351 |
-
onClick={() => setIsSummaryOpen(false)}
|
| 352 |
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"
|
| 353 |
>
|
| 354 |
<X className="w-5 h-5" />
|
|
@@ -356,9 +364,9 @@ function ChatsContent() {
|
|
| 356 |
|
| 357 |
<div className="flex-1 min-h-0 pt-4">
|
| 358 |
<ClientCard
|
| 359 |
-
lead={selectedLead}
|
| 360 |
onTakeover={() => { }}
|
| 361 |
-
isAnalyzing={selectedLead.processing_status === 'analyzing'}
|
| 362 |
onRefresh={handleRefresh}
|
| 363 |
tenantId={user.tenant_id}
|
| 364 |
/>
|
|
|
|
| 21 |
const { user, isLoading: authLoading } = useAuth()
|
| 22 |
const toast = useToast()
|
| 23 |
const [selectedLead, setSelectedLead] = useState<Lead | undefined>(undefined)
|
| 24 |
+
const [summaryLead, setSummaryLead] = useState<Lead | undefined>(undefined)
|
| 25 |
const [messages, setMessages] = useState<Message[]>([])
|
| 26 |
const [messagesLoading, setMessagesLoading] = useState(false)
|
| 27 |
const [searchQuery, setSearchQuery] = useState('')
|
|
|
|
| 29 |
const [conversation, setConversation] = useState<any>(null)
|
| 30 |
const [isLeadsListOpen, setIsLeadsListOpen] = useState(true)
|
| 31 |
const [isSummaryOpen, setIsSummaryOpen] = useState(false) // Unified state for Desktop/Tablet Sidebar and Mobile Drawer
|
|
|
|
| 32 |
const { t } = useTranslation()
|
| 33 |
|
| 34 |
// Fetch Leads
|
|
|
|
| 159 |
}
|
| 160 |
|
| 161 |
const handleShowSummary = (lead: Lead) => {
|
| 162 |
+
setSummaryLead(lead)
|
| 163 |
setIsSummaryOpen(true)
|
| 164 |
}
|
| 165 |
|
|
|
|
| 281 |
}}
|
| 282 |
onToggleLeadsList={() => setIsLeadsListOpen(!isLeadsListOpen)}
|
| 283 |
isLeadsListOpen={isLeadsListOpen}
|
| 284 |
+
onOpenMobileDrawer={() => {
|
| 285 |
+
setIsSummaryOpen(!isSummaryOpen);
|
| 286 |
+
if (!isSummaryOpen) { // If opening, set summaryLead to selectedLead
|
| 287 |
+
setSummaryLead(selectedLead);
|
| 288 |
+
} else { // If closing, clear summaryLead
|
| 289 |
+
setSummaryLead(undefined);
|
| 290 |
+
}
|
| 291 |
+
}}
|
| 292 |
/>
|
| 293 |
) : (
|
| 294 |
<div className="h-full flex flex-col items-center justify-center text-slate-500">
|
|
|
|
| 325 |
|
| 326 |
{/* 2. OVERLAY FOR TABLET/MOBILE (< lg) */}
|
| 327 |
<AnimatePresence>
|
| 328 |
+
{isSummaryOpen && (summaryLead || selectedLead) && (
|
| 329 |
<div className="lg:hidden">
|
| 330 |
+
{/* Backdrop - Starts from start of chat header, ends before input block */}
|
| 331 |
<motion.div
|
| 332 |
initial={{ opacity: 0 }}
|
| 333 |
animate={{ opacity: 1 }}
|
| 334 |
exit={{ opacity: 0 }}
|
| 335 |
+
onClick={() => { setIsSummaryOpen(false); setSummaryLead(undefined); }}
|
| 336 |
+
className="fixed right-0 top-16 md:top-0 bottom-24 md:bottom-20 bg-black/30 backdrop-blur-[6px] z-[60] left-0 md:left-[320px]"
|
| 337 |
/>
|
| 338 |
|
| 339 |
<motion.div
|
|
|
|
| 343 |
onDragEnd={(_, info) => {
|
| 344 |
if (info.offset.x > 80 || info.velocity.x > 300) {
|
| 345 |
setIsSummaryOpen(false)
|
| 346 |
+
setSummaryLead(undefined)
|
| 347 |
}
|
| 348 |
}}
|
| 349 |
initial={{ x: '100%', opacity: 0 }}
|
| 350 |
animate={{ x: 0, opacity: 1 }}
|
| 351 |
exit={{ x: '100%', opacity: 0 }}
|
| 352 |
transition={{ type: 'spring', damping: 30, stiffness: 250, mass: 0.8 }}
|
| 353 |
+
className="fixed right-0 top-16 md:top-0 bottom-24 md:bottom-20 w-[90%] sm:w-[380px] bg-[#050510]/95 backdrop-blur-xl border-l border-white/10 z-[70] flex flex-col shadow-[0_0_50px_rgba(0,0,0,0.5)] md:rounded-l-[32px] overflow-hidden"
|
| 354 |
style={{ willChange: 'transform', transform: 'translateZ(0)' }}
|
| 355 |
>
|
| 356 |
|
| 357 |
{/* Floating Close Button */}
|
| 358 |
<button
|
| 359 |
+
onClick={() => { setIsSummaryOpen(false); setSummaryLead(undefined); }}
|
| 360 |
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"
|
| 361 |
>
|
| 362 |
<X className="w-5 h-5" />
|
|
|
|
| 364 |
|
| 365 |
<div className="flex-1 min-h-0 pt-4">
|
| 366 |
<ClientCard
|
| 367 |
+
lead={(summaryLead || selectedLead)!}
|
| 368 |
onTakeover={() => { }}
|
| 369 |
+
isAnalyzing={(summaryLead || selectedLead)!.processing_status === 'analyzing'}
|
| 370 |
onRefresh={handleRefresh}
|
| 371 |
tenantId={user.tenant_id}
|
| 372 |
/>
|
frontend/components/ChatWindow/ChatHeader.tsx
CHANGED
|
@@ -39,7 +39,7 @@ export function ChatHeader({
|
|
| 39 |
|
| 40 |
{/* Left: Lead Info */}
|
| 41 |
<div className="flex items-center gap-3 overflow-hidden">
|
| 42 |
-
{/* Back Button (Phone only) */}
|
| 43 |
<button
|
| 44 |
onClick={onBack}
|
| 45 |
className="md:hidden p-2 -ml-2 text-slate-400 hover:text-white hover:bg-white/10 rounded-full transition-colors"
|
|
|
|
| 39 |
|
| 40 |
{/* Left: Lead Info */}
|
| 41 |
<div className="flex items-center gap-3 overflow-hidden">
|
| 42 |
+
{/* Back Button (Phone only - hidden on tablet/md) */}
|
| 43 |
<button
|
| 44 |
onClick={onBack}
|
| 45 |
className="md:hidden p-2 -ml-2 text-slate-400 hover:text-white hover:bg-white/10 rounded-full transition-colors"
|