Merged in feat/SW-1452-city-page-filter-2 (pull request #1392)

feat(SW-1452): Added filtering and sorting to destination city pages

* feat(SW-1452): Added filtering and sorting to destination city pages

* feat(SW-1452): Added temporary component for country pages to avoid Context issues


Approved-by: Matilda Landström
This commit is contained in:
Erik Tiekstra
2025-02-25 13:02:38 +00:00
parent 8a564274c5
commit 3867baadd6
53 changed files with 1561 additions and 255 deletions

View File

@@ -0,0 +1,17 @@
import type { SortOption } from "../enums/hotelFilterAndSort"
export interface SortItem {
label: string
value: SortOption
}
export interface Filter {
name: string
slug: string
filterType: string
}
export interface CategorizedFilters {
facilityFilters: Filter[]
surroundingsFilters: Filter[]
}

View File

@@ -0,0 +1,3 @@
import type { createHotelDataStore } from "@/stores/hotel-data"
export type HotelDataStore = ReturnType<typeof createHotelDataStore>

View File

@@ -0,0 +1,5 @@
export enum SortOption {
Distance = "distance",
Name = "name",
TripAdvisorRating = "tripadvisor",
}

View File

@@ -0,0 +1,8 @@
import type { HotelDataWithUrl } from "@/types/hotel"
import type { SortItem } from "../components/hotelFilterAndSort"
export interface HotelDataProviderProps extends React.PropsWithChildren {
allHotels: HotelDataWithUrl[]
filterFromUrl?: string
sortItems: SortItem[]
}

View File

@@ -0,0 +1,46 @@
import type { ReadonlyURLSearchParams } from "next/navigation"
import type {
CategorizedFilters,
SortItem,
} from "../components/hotelFilterAndSort"
import type { SortOption } from "../enums/hotelFilterAndSort"
import type { HotelDataWithUrl } from "../hotel"
interface Actions {
submitFiltersAndSort: () => void
setPendingSort: (sort: SortOption) => void
togglePendingFilter: (filter: string) => void
clearPendingFilters: () => void
resetPendingValues: () => void
loadInitialHashFilter: (hash: string) => void
}
export interface SubmitCallbackData {
sort: SortOption
filters: string[]
basePath: string
}
export interface HotelDataState {
actions: Actions
allHotels: HotelDataWithUrl[]
activeHotels: HotelDataWithUrl[]
pendingSort: SortOption
activeSort: SortOption
pendingFilters: string[]
activeFilters: string[]
pendingCount: number
searchParams: ReadonlyURLSearchParams
allFilters: CategorizedFilters
allFilterSlugs: string[]
basePathnameWithoutFilters: string
sortItems: SortItem[]
initialHashFilterLoaded: boolean
}
export interface InitialState
extends Pick<HotelDataState, "allHotels" | "searchParams" | "sortItems"> {
pathname: string
filterFromUrl?: string
submitCallbackFn?: (data: SubmitCallbackData) => void
}

View File

@@ -1,5 +1,8 @@
import { z } from "zod"
import type { z } from "zod"
import { rawMetadataSchema } from "@/server/routers/contentstack/metadata/output"
import type { getMetadataInput } from "@/server/routers/contentstack/metadata/input"
import type { rawMetadataSchema } from "@/server/routers/contentstack/metadata/output"
export interface RawMetadataSchema extends z.output<typeof rawMetadataSchema> {}
export interface MetadataInputSchema extends z.input<typeof getMetadataInput> {}