diff --git a/src/pages/demand/Results.tsx b/src/pages/demand/Results.tsx index 2cc206b..85b3098 100644 --- a/src/pages/demand/Results.tsx +++ b/src/pages/demand/Results.tsx @@ -1,5 +1,5 @@ import { useState } from 'react' -import { Box, Button, Card, Chip, Typography } from '@mui/material' +import { Box, Button, Card, Typography } from '@mui/material' import { useNavigate, useLocation } from 'react-router' import { useQuery, useQueryClient } from '@tanstack/react-query' import { useUnifiedResults } from '../../hooks/useUnifiedResults' @@ -44,27 +44,22 @@ export default function Results() { (localStorage.getItem('view-results') as 'list' | 'grid') ?? 'list' ) - const [selectedNeedId, setSelectedNeedId] = useState(undefined) - // When coming from NeedBuilder, invalidate so the freshly created need is included const activeNeedIdFromNav = (location.state as { activeNeedId?: string } | null)?.activeNeedId const { data: needResp } = useQuery({ queryKey: ['needs'], queryFn: () => needService.getAll(), - // Refetch on mount when navigating from NeedBuilder to pick up the new need refetchOnMount: activeNeedIdFromNav ? 'always' : true, gcTime: 0, }) const allNeeds = needResp?.data ?? [] - // Only show named needs in the selector — skip auto-generated "Neue Suche" entries - const namedNeeds = allNeeds.filter(n => n.companyName !== 'Neue Suche') - // Priority: explicit user selection → nav (just came from NeedBuilder) → first named need - const effectiveNeedId = selectedNeedId ?? activeNeedIdFromNav ?? namedNeeds[0]?.id + // Nav ID (from NeedBuilder) takes priority; otherwise first named need + const effectiveNeedId = activeNeedIdFromNav ?? allNeeds.find(n => n.companyName !== 'Neue Suche')?.id - const activeNeed = allNeeds.find(n => n.id === effectiveNeedId) ?? namedNeeds[0] + const activeNeed = allNeeds.find(n => n.id === effectiveNeedId) ?? allNeeds[0] // Ensure query cache is invalidated when a new need was just created if (activeNeedIdFromNav) { @@ -129,25 +124,6 @@ export default function Results() { {activeNeed && ( - {/* Need selector — named searches only */} - {namedNeeds.length > 1 && ( - - {namedNeeds.map(n => ( - setSelectedNeedId(n.id)} - sx={n.id === activeNeed.id - ? { fontSize: '0.68rem', height: 22, bgcolor: '#1e3a5f', color: 'white', cursor: 'pointer' } - : { fontSize: '0.68rem', height: 22, color: '#64748b', borderColor: '#cbd5e1', cursor: 'pointer' } - } - /> - ))} - - )} -