import { ArrowLeft, Search } from 'lucide-react' import { useState } from 'react' import { Button } from '#/components/ui/button' import { Input } from '#/components/ui/input' import { Sidebar, SidebarContent, SidebarHeader, SidebarInset, SidebarProvider, } from '#/components/ui/sidebar' import { TooltipProvider } from '#/components/ui/tooltip' import { WorkspaceNavigation } from '#/components/workspace-navigation' import { type Status, useWorkspaceState, } from '#/features/workspace/workspace-state' import { ConversationDetail } from './conversation-detail' import { conversations } from './mock-conversations' import './support.css' const views = [ { id: 'now', label: 'Now' }, { id: 'later', label: 'Later' }, { id: 'waiting', label: 'Waiting' }, { id: 'done', label: 'History' }, { id: 'all', label: 'All' }, ] as const export function SupportPage() { const [view, setView] = useState('now') const [query, setQuery] = useState('') const { statuses, setStatuses, outcomes, setOutcomes } = useWorkspaceState() const [selectedId, setSelectedId] = useState() const [reading, setReading] = useState(false) const [notice, setNotice] = useState('') const matches = conversations.filter((item) => { const status = statuses[item.id] ?? 'now' return ( (view === 'all' ? true : view === 'done' ? status === 'sent' || status === 'dismissed' : status === view) && `${item.name} ${item.subject}`.includes(query) ) }) const visible = view === 'now' ? matches.slice(0, 3) : matches const selected = visible.find((item) => item.id === selectedId) ?? visible[0] function resolve(id: string, status: Exclude, note?: string) { setStatuses((current) => ({ ...current, [id]: status })) if (note) setOutcomes((current) => ({ ...current, [id]: note })) setNotice( status === 'sent' ? 'Reply preview recorded' : status === 'later' ? 'Moved to Later' : status === 'waiting' ? 'Moved to Waiting' : 'Marked as no action needed', ) setReading(false) } return (

Messages

{views.map((tab) => ( ))}
setQuery(event.target.value)} />
{visible.map((item) => ( ))} {!visible.length && (

{query ? 'No results found' : 'No messages to handle right now'}

)} {view === 'now' && matches.length > 3 && (

{matches.length - 3} more

)}
{selected?.name} {notice}
{conversations.map((conversation) => ( ))} {selected ? ( <> {outcomes[selected.id] && (

Activity log

{outcomes[selected.id]}

)} {view !== 'now' && ( )} ) : (
Select a conversation
)}
) }