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:
17
types/components/hotelFilterAndSort.ts
Normal file
17
types/components/hotelFilterAndSort.ts
Normal 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[]
|
||||
}
|
||||
3
types/contexts/hotel-data.ts
Normal file
3
types/contexts/hotel-data.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { createHotelDataStore } from "@/stores/hotel-data"
|
||||
|
||||
export type HotelDataStore = ReturnType<typeof createHotelDataStore>
|
||||
5
types/enums/hotelFilterAndSort.ts
Normal file
5
types/enums/hotelFilterAndSort.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export enum SortOption {
|
||||
Distance = "distance",
|
||||
Name = "name",
|
||||
TripAdvisorRating = "tripadvisor",
|
||||
}
|
||||
8
types/providers/hotel-data.ts
Normal file
8
types/providers/hotel-data.ts
Normal 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[]
|
||||
}
|
||||
46
types/stores/hotel-data.ts
Normal file
46
types/stores/hotel-data.ts
Normal 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
|
||||
}
|
||||
@@ -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> {}
|
||||
|
||||
Reference in New Issue
Block a user