import { useState, useEffect } from 'react' import { useAuthStore } from '../../store/authStore' import { useTranslation } from '../../i18n' import { MessageCircle, StickyNote, BarChart3, Sparkles } from 'lucide-react' import CollabChat from './CollabChat' import CollabNotes from './CollabNotes' import CollabPolls from './CollabPolls' import WhatsNextWidget from './WhatsNextWidget' function useIsDesktop(breakpoint = 1024) { const [isDesktop, setIsDesktop] = useState(window.innerWidth >= breakpoint) useEffect(() => { const check = () => setIsDesktop(window.innerWidth >= breakpoint) window.addEventListener('resize', check) return () => window.removeEventListener('resize', check) }, [breakpoint]) return isDesktop } const card = { display: 'flex', flexDirection: 'column', background: 'var(--bg-card)', borderRadius: 16, border: '1px solid var(--border-faint)', overflow: 'hidden', minHeight: 0, } interface TripMember { id: number username: string avatar_url?: string | null } interface CollabPanelProps { tripId: number tripMembers?: TripMember[] } export default function CollabPanel({ tripId, tripMembers = [] }: CollabPanelProps) { const { user } = useAuthStore() const { t } = useTranslation() const [mobileTab, setMobileTab] = useState('chat') const isDesktop = useIsDesktop() const tabs = [ { id: 'chat', label: t('collab.tabs.chat') || 'Chat', icon: MessageCircle }, { id: 'notes', label: t('collab.tabs.notes') || 'Notes', icon: StickyNote }, { id: 'polls', label: t('collab.tabs.polls') || 'Polls', icon: BarChart3 }, { id: 'next', label: t('collab.whatsNext.title') || "What's Next", icon: Sparkles }, ] if (isDesktop) { return (
{/* Chat — left, fixed width */}
{/* Right column: Notes top, Polls + What's Next bottom */}
{/* Notes — top */}
{/* Polls + What's Next — bottom row */}
) } // Mobile: tab bar + single panel return (
{tabs.map(tab => { const Icon = tab.icon const active = mobileTab === tab.id return ( ) })}
{mobileTab === 'chat' && } {mobileTab === 'notes' && } {mobileTab === 'polls' && } {mobileTab === 'next' && }
) }