Merged in fix/SW-2253-consolidate-autocomplete-search (pull request #1795)

Consolidate autocomplete search SW-2253 SW-2338

* use fuse.js for fuzzy search
* Handle weird behaviour when search field loses focus on destinationPage
* Add error logging for JumpTo when no URL was provided
* Switch to use <Typography /> over <Caption />
* fix: bookingWidget search label should always be red
* fix: searchHistory can no longer add invalid items
* fix: list more hits when searching
* fix: issue when searchField value was undefined
* fix: don't show searchHistory label if no searchHistory items
* simplify skeleton for listitems in search

Approved-by: Linus Flood
This commit is contained in:
Joakim Jäderberg
2025-04-17 06:39:42 +00:00
parent 8c0597727b
commit b98d6c10c0
35 changed files with 797 additions and 1602 deletions

View File

@@ -1,3 +1,5 @@
import { normalizeAumlauts } from "./normalizeAumlauts"
import type { Location } from "@/types/trpc/routers/hotel/locations"
export function getSearchTokens(location: Location) {
@@ -11,25 +13,8 @@ export function getSearchTokens(location: Location) {
.filter(hasValue)
.map((x) => x.toLocaleLowerCase())
const additionalTokens: string[] = []
tokens.forEach((token) => {
const replaced = token
.replace(/å/g, "a")
.replace(/ä/g, "a")
.replace(/ö/g, "o")
.replace(/æ/g, "a")
.replace(/ø/g, "o")
.replace(/é/g, "e")
.replace(/ü/g, "u")
if (replaced !== token) {
additionalTokens.push(replaced)
}
})
const allTokens = [...new Set([...tokens, ...additionalTokens])]
return allTokens
const normalizedTokens = normalizeAumlauts(tokens)
return normalizedTokens
}
function hasValue(value: string | null | undefined): value is string {