chore: remove locations type to opt for location in array instead, this highlights array objects

This commit is contained in:
Christian Andolf
2025-04-02 10:11:39 +02:00
parent 14f9b68365
commit 2a07fcf7be
4 changed files with 15 additions and 16 deletions

View File

@@ -4,7 +4,7 @@ import {
type InitState,
type State,
} from "@/types/components/form/bookingwidget"
import type { Locations } from "@/types/trpc/routers/hotel/locations"
import type { Location } from "@/types/trpc/routers/hotel/locations"
export const localStorageKey = "searchHistory"
export const sessionStorageKey = "searchData"
@@ -61,7 +61,7 @@ export function reducer(state: State, action: Action) {
}
})
const matches: Locations = []
const matches: Location[] = []
matchesMap.forEach((value) => {
matches.push(value)
})

View File

@@ -1,14 +1,14 @@
import type { BookingWidgetType } from "@/types/components/bookingWidget"
import type { Location, Locations } from "@/types/trpc/routers/hotel/locations"
import type { Location } from "@/types/trpc/routers/hotel/locations"
export interface BookingWidgetFormProps {
locations: Locations
locations: Location[]
type?: BookingWidgetType
onClose: () => void
}
export interface BookingWidgetFormContentProps {
locations: Locations
locations: Location[]
formId: string
onSubmit: () => void
isSearching: boolean
@@ -40,7 +40,7 @@ interface SearchLocationsAction {
interface SetItemAction {
payload: {
location: Location
searchHistory: Locations
searchHistory: Location[]
}
type: ActionType.SELECT_ITEM
}
@@ -48,7 +48,7 @@ interface SetItemAction {
export interface SetStorageData {
payload: {
searchData?: Location
searchHistory?: Locations
searchHistory?: Location[]
}
type: ActionType.SET_STORAGE_DATA
}
@@ -61,11 +61,11 @@ export type Action =
| SetStorageData
export interface State {
defaultLocations: Locations
locations: Locations
defaultLocations: Location[]
locations: Location[]
search: string
searchData: Location | undefined
searchHistory: Locations | null
searchHistory: Location[] | null
}
export interface InitState extends Pick<State, "defaultLocations"> {

View File

@@ -2,10 +2,10 @@ 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"
import type { Location } from "../trpc/routers/hotel/locations"
export interface SearchProps {
locations: Locations
locations: Location[]
handlePressEnter: () => void
}
@@ -22,9 +22,9 @@ export interface SearchListProps {
isOpen: boolean
handleClearSearchHistory: () => void
highlightedIndex: HighlightedIndex
locations: Locations
locations: Location[]
search: string
searchHistory: Locations | null
searchHistory: Location[] | null
}
export interface ListProps

View File

@@ -8,8 +8,7 @@ import type {
export interface LocationSchema extends z.output<typeof locationsSchema> {}
export type Locations = LocationSchema["data"]
export type Location = Locations[number]
export type Location = LocationSchema["data"][number]
export type CityLocation = Location & { type: "cities" }
export type HotelLocation = Location & { type: "hotels" }