Purpose

Landing view after login. Type-ahead search across companies in the database, with optional advanced filters and CSV export. File: frontend/kundkort/components/SearchPage.tsx.

Behaviour

  • Single <input>, autofocused on mount (SearchPage.tsx:170)
  • Hits /api/kundkort/search?q=… for plain queries, /api/kundkort/search/advanced?… when any filter is non-empty (hooks/useSearch.ts:46-49)
  • Debounced 300 ms (useSearch.ts:36-69)
  • Minimum 2 characters unless filters are active (useSearch.ts:22)
  • Results dropdown shows name, formatted org_nr, legal_form, postal_city
  • Selecting a result calls onSelect(orgNr, name) which KundkortPage-routes via URL pushState (defined in app.tsx:29-36)

Recent searches

localStorage key enrichnode_recent, max 5 entries (SearchPage.tsx:7-28). Each entry is { org_nr, name }. Shown as pill buttons under the search bar when query is empty.

Advanced filters

Toggled by the “Filter” button. Three text inputs: city, sni, legal_form (SearchPage.tsx:309-313). State is SearchFilters from types/kundkort.ts:104-109. active filter is in the type but not in the UI.

CSV export

“Exportera CSV” button calls GET /api/kundkort/export?…&format=csv with the current query and filters (SearchPage.tsx:48-73). Streams a blob, creates an object URL, downloads as enrichnode-export-YYYY-MM-DD.csv. Only shown when there are results or a non-empty query.

Logout

Top-right link calls the onLogout prop (passed down from App). See Auth Flow.

See also

Kundkort API Client, Kundkort Page, Auth Flow, Frontend Overview.

See also