Files
property-match/src/components/layout/RightContextPanel.tsx
T
Benjamin Sutter 5d53f35dea refactor(state): clean layoutStore, add selectors, centralise STALE constants
- layoutStore: remove 4 dead field groups (pinnedPanels, selectedResultId,
  compareTrayVisible, notificationsOpen) — none were read outside the store
- CompareTray: drop dead useLayoutStore side-effect (state was write-only)
- 8 components: replace bare useStore() with explicit selectors / useShallow
  to prevent unnecessary re-renders on unrelated state mutations
- lib/constants: add STALE_MARKET_SIGNALS + STALE_REVIEW_QUEUE (30s each)
- useMarketSignals, useReviewQueue: use global constants instead of
  hook-local magic numbers
- Add STATE_MANAGEMENT.md: decision tree + rules for RQ/Zustand/local/derived

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-24 01:30:44 +02:00

73 lines
2.3 KiB
TypeScript

import { Box, Divider, IconButton, Typography } from '@mui/material'
import { X } from 'lucide-react'
import { useLayoutStore } from '../../stores/layoutStore'
import type { RightPanelContentType } from '../../stores/layoutStore'
const PANEL_TITLES: Record<RightPanelContentType, string> = {
ai_context: 'KI Kontext',
detail_preview: 'Detail Vorschau',
compare_preview: 'Vergleich Vorschau',
activity_feed: 'Aktivitäts-Feed',
}
const PANEL_PLACEHOLDERS: Record<RightPanelContentType, string> = {
ai_context: 'KI-Kontext wird geladen...',
detail_preview: 'Kein Objekt ausgewählt.',
compare_preview: 'Vergleichsvorschau nicht verfügbar.',
activity_feed: 'Keine Aktivitäten vorhanden.',
}
export function RightContextPanel() {
const isRightPanelOpen = useLayoutStore(s => s.isRightPanelOpen)
const rightPanelContentType = useLayoutStore(s => s.rightPanelContentType)
const closeRightPanel = useLayoutStore(s => s.closeRightPanel)
const title = rightPanelContentType ? PANEL_TITLES[rightPanelContentType] : ''
const placeholder = rightPanelContentType ? PANEL_PLACEHOLDERS[rightPanelContentType] : ''
return (
<Box
sx={{
position: 'fixed',
right: 0,
top: 56,
height: 'calc(100vh - 56px)',
width: 320,
transform: isRightPanelOpen ? 'translateX(0)' : 'translateX(320px)',
transition: 'transform 0.25s ease',
bgcolor: '#fff',
borderLeft: '1px solid #e2e8f0',
boxShadow: '-4px 0 16px rgba(0,0,0,0.08)',
zIndex: 1200,
display: 'flex',
flexDirection: 'column',
overflow: 'hidden',
}}
>
<Box
sx={{
height: 48,
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
px: 2,
flexShrink: 0,
}}
>
<Typography variant="subtitle2" sx={{ fontWeight: 600 }}>{title}</Typography>
<IconButton size="small" onClick={closeRightPanel} sx={{ color: '#64748b' }}>
<X size={16} />
</IconButton>
</Box>
<Divider />
<Box sx={{ flex: 1, overflowY: 'auto', p: 2 }}>
<Typography variant="body2" sx={{ color: 'text.secondary' }}>
{placeholder}
</Typography>
</Box>
</Box>
)
}