fix: need selector on results page + retail budget parsing

- Results page: chip strip shows all saved searches — click to switch without
  creating a new search. Defaults to first need instead of most-recently-created
  so pre-existing mock needs load immediately on navigation.
- AI parser: asset-type-aware monthly budget threshold (RETAIL: 500, others: 150)
  so "150 CHF/m²" for retail is correctly converted to 1800 CHF/m²/year instead
  of being stored as an impossibly low annual value that excludes all properties.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Benjamin Sutter
2026-05-21 20:47:14 +02:00
parent 27c53f3af1
commit 11ecd5d900
2 changed files with 32 additions and 11 deletions
+5 -3
View File
@@ -177,14 +177,16 @@ function mockParseNeed(input: string): ParseNeedResult {
const budgetMaxMatch = input.match(/(?:max\.?|bis|höchstens)\s*(?:CHF\s*)?(\d+)/i)
let budgetRange: { maxPerSqm: number; currency: string } | undefined
let budgetConfidence = 0.20
// Monthly-to-annual threshold: Swiss retail quotes monthly (150/m²/mon → 1800/year),
// office/logistics quote monthly too but at lower values (45/m²/mon → 540/year).
const monthlyThreshold = assetType === 'RETAIL' ? 500 : 150
if (budgetPerSqmMatch) {
const raw = parseInt(budgetPerSqmMatch[1])
// Values < 100 are monthly (e.g. CHF 45/m²/month); convert to annual
budgetRange = { maxPerSqm: raw < 100 ? raw * 12 : raw, currency: 'CHF' }
budgetRange = { maxPerSqm: raw < monthlyThreshold ? raw * 12 : raw, currency: 'CHF' }
budgetConfidence = 0.92
} else if (budgetMaxMatch) {
const raw = parseInt(budgetMaxMatch[1])
budgetRange = { maxPerSqm: raw < 100 ? raw * 12 : raw, currency: 'CHF' }
budgetRange = { maxPerSqm: raw < monthlyThreshold ? raw * 12 : raw, currency: 'CHF' }
budgetConfidence = 0.60
}