import type { CSSProperties } from 'react' import type { components } from '@/api/schema' import { I } from '@/components/icons' import { Button, SectionLabel, SidebarItem } from '@/components/ui/primitives' import type { RoomsFilter } from '@/lib/types' import { BrandHeader, PrimaryNav, UserChip, sidebarAsideStyle } from './sidebarChrome' import { useAuth } from '@/auth/AuthContext' type Room = components['schemas']['RoomDetails'] type Props = { filter: RoomsFilter onFilter: (f: RoomsFilter) => void rooms: Room[] collapsed: boolean onToggle: () => void onNewRecording?: () => void } const PLATFORM_COLOR: Record = { whereby: 'var(--status-processing)', daily: 'var(--status-ok)', livekit: 'var(--primary)', } const PLATFORMS: Room['platform'][] = ['whereby', 'daily', 'livekit'] export function RoomsSidebar({ filter, onFilter, rooms, collapsed, onToggle, onNewRecording, }: Props) { const { user } = useAuth() const isActive = ( kind: RoomsFilter['kind'], val: RoomsFilter['value'] | null = null, ) => filter.kind === kind && (filter.value ?? null) === val const counts = { all: rooms.length, mine: rooms.filter((r) => !r.is_shared).length, shared: rooms.filter((r) => r.is_shared).length, calendar: rooms.filter((r) => r.ics_enabled).length, } const platformCount = (p: Room['platform']) => rooms.filter((r) => r.platform === p).length const sizeCount = (s: string) => rooms.filter((r) => r.room_mode === s).length const recCount = (t: string) => rooms.filter((r) => r.recording_type === t).length const presentPlatforms = PLATFORMS.filter((p) => platformCount(p) > 0) return ( ) } type RailProps = { filter: RoomsFilter onFilter: (f: RoomsFilter) => void onToggle: () => void onNewRecording?: () => void } function RoomsRail({ filter, onFilter, onToggle, onNewRecording }: RailProps) { const items: Array<{ kind: RoomsFilter['kind'] value: RoomsFilter['value'] | null icon: ReturnType title: string }> = [ { kind: 'all', value: null, icon: I.Door(18), title: 'All rooms' }, { kind: 'scope', value: 'mine', icon: I.User(18), title: 'My rooms' }, { kind: 'scope', value: 'shared', icon: I.Share(18), title: 'Shared' }, { kind: 'status', value: 'active', icon: I.Radio(18), title: 'Active' }, { kind: 'status', value: 'calendar', icon: I.Calendar(18), title: 'Calendar' }, ] return ( ) }