import { Box, Chip, Typography } from '@mui/material' import { useNeeds } from '../../hooks/useNeeds' import { useMatchCenterStore } from '../../stores/matchCenterStore' import { MatchCenterSkeleton } from './MatchCenterSkeleton' import type { Match } from '../../domain/match' import type { Need } from '../../domain/need' interface Props { matches: Match[] } export function NeedSelectionPanel({ matches }: Props) { const { data: needs = [], isLoading } = useNeeds() const { selectedNeedId, setSelectedNeed } = useMatchCenterStore() if (isLoading) return return ( {needs.map((need: Need) => { const pendingCount = matches.filter(m => m.needId === need.id && m.status === 'PENDING_REVIEW').length const isSelected = selectedNeedId === need.id return ( setSelectedNeed(isSelected ? null : need.id)} sx={{ p: 1.5, cursor: 'pointer', borderBottom: '1px solid #f1f5f9', borderRight: isSelected ? '3px solid #d97706' : '3px solid transparent', bgcolor: isSelected ? '#fef3c7' : 'transparent', '&:hover': { bgcolor: isSelected ? '#fef3c7' : '#f8fafc' }, }} > {need.isAnonymous ? 'Anonyme Anfrage' : need.companyName} {need.isAnonymous && ( )} {pendingCount > 0 && ( )} {need.requiredArea.min}–{need.requiredArea.max} m² · {need.preferredLocations.slice(0, 2).join(', ')} ) })} ) }