Files
web/types/components/search.ts
Niclas Edenvin 0ac09f37f6 Merged in fix/sw-1177-search-history (pull request #1124)
fix(SW-1177): fix localization problems in search history

* fix(SW-1177): fix localization problems in search history

When saving search history the whole location objects where stored and
also used later. This made the list display in different languages if
the user previously had search for something in another language.
Another issue where that the list where also deduped based on name of
the search item, which meant that there could be multiple history
items for the same entity and the same ID, e.g. `Gothenburg` and
`Göteborg`.


Approved-by: Bianca Widstam
2025-01-07 10:32:32 +00:00

63 lines
1.5 KiB
TypeScript

import type { VariantProps } from "class-variance-authority"
import type { PropGetters } from "downshift"
import type { dialogVariants } from "@/components/Forms/BookingWidget/FormContent/Search/SearchList/Dialog/variants"
import type { Location, Locations } from "../trpc/routers/hotel/locations"
export interface SearchProps {
locations: Locations
handlePressEnter: () => void
}
export type SearchHistoryItem = {
type: "cities" | "hotels"
id: string
}
type HighlightedIndex = number | null
export interface SearchListProps {
getItemProps: PropGetters<unknown>["getItemProps"]
getMenuProps: PropGetters<unknown>["getMenuProps"]
isOpen: boolean
handleClearSearchHistory: () => void
highlightedIndex: HighlightedIndex
locations: Locations
search: string
searchHistory: Locations | null
}
export interface ListProps
extends Pick<
SearchListProps,
"getItemProps" | "highlightedIndex" | "locations"
> {
initialIndex?: number
label?: string
}
export interface ListItemProps
extends Pick<SearchListProps, "getItemProps" | "highlightedIndex"> {
index: number
location: Location
}
export interface DialogProps
extends React.PropsWithChildren,
VariantProps<typeof dialogVariants>,
Pick<SearchListProps, "getMenuProps"> {
className?: string
}
export interface ErrorDialogProps
extends React.PropsWithChildren,
Pick<SearchListProps, "getMenuProps"> {}
export interface ClearSearchButtonProps
extends Pick<
SearchListProps,
"getItemProps" | "handleClearSearchHistory" | "highlightedIndex"
> {
index: number
}