feat: mix Schattenmarkt into result tiers, add filter toggle
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -16,7 +16,7 @@ import { AddToShortlistDialog } from '../../components/shortlist'
|
||||
import type { ResultType } from '../../domain/enums'
|
||||
import type { UnifiedMatchResult } from '../../domain/unifiedResult'
|
||||
|
||||
type FilterSource = ResultType | 'ALL'
|
||||
type FilterSource = Exclude<ResultType, 'FUTURE_AVAILABILITY'> | 'ALL'
|
||||
type SortBy = 'score' | 'rent' | 'area'
|
||||
|
||||
function sortResults(results: UnifiedMatchResult[], sortBy: SortBy): UnifiedMatchResult[] {
|
||||
@@ -36,6 +36,7 @@ export default function Results() {
|
||||
const queryClient = useQueryClient()
|
||||
const [filterSource, setFilterSource] = useState<FilterSource>('ALL')
|
||||
const [sortBy, setSortBy] = useState<SortBy>('score')
|
||||
const [showSchattenmarkt, setShowSchattenmarkt] = useState(true)
|
||||
const [view, setView] = useState<'list' | 'grid'>(() =>
|
||||
(localStorage.getItem('view-results') as 'list' | 'grid') ?? 'list'
|
||||
)
|
||||
@@ -67,8 +68,9 @@ export default function Results() {
|
||||
|
||||
const { data: results = [], isLoading } = useUnifiedResults(activeNeed?.id)
|
||||
|
||||
const filtered =
|
||||
filterSource === 'ALL' ? results : results.filter(r => r.resultType === filterSource)
|
||||
const filtered = results
|
||||
.filter(r => filterSource === 'ALL' || r.resultType === filterSource)
|
||||
.filter(r => showSchattenmarkt || r.resultType !== 'FUTURE_AVAILABILITY')
|
||||
|
||||
const sorted = sortResults(filtered, sortBy)
|
||||
|
||||
@@ -167,12 +169,14 @@ export default function Results() {
|
||||
onFilterChange={setFilterSource}
|
||||
sortBy={sortBy}
|
||||
onSortChange={setSortBy}
|
||||
showSchattenmarkt={showSchattenmarkt}
|
||||
onShowSchattenmarktChange={setShowSchattenmarkt}
|
||||
/>
|
||||
|
||||
{isLoading ? (
|
||||
<FeedSkeleton />
|
||||
) : sorted.length === 0 ? (
|
||||
<FeedEmptyState filtered={filterSource !== 'ALL'} />
|
||||
<FeedEmptyState filtered={filterSource !== 'ALL' || !showSchattenmarkt} />
|
||||
) : (
|
||||
<UnifiedResultFeed results={sorted} view={view} />
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user