Feat/SW-2271 hotel list filtering
* feat(SW-2271): Changes to hotel data types in preperation for filtering * feat(SW-2271): Added filter and sort functionality Approved-by: Matilda Landström
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
import type { AdditionalData, Hotel } from "@scandic-hotels/trpc/types/hotel"
|
||||
import type { HotelListingHotelData } from "@scandic-hotels/trpc/types/hotel"
|
||||
|
||||
import type { HotelListing } from "@/types/trpc/routers/contentstack/blocks"
|
||||
|
||||
export interface HotelListingItemProps {
|
||||
hotel: Hotel
|
||||
additionalData: AdditionalData
|
||||
hotelData: HotelListingHotelData
|
||||
contentType: HotelListing["contentType"]
|
||||
url: string | null
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import type { SortOption } from "@scandic-hotels/trpc/enums/destinationFilterAndSort"
|
||||
|
||||
export interface SortItem {
|
||||
label: string
|
||||
value: SortOption
|
||||
isDefault?: boolean
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Amenities } from "@scandic-hotels/trpc/types/hotel"
|
||||
import type { FeatureCollection, Point } from "geojson"
|
||||
|
||||
import type { Amenities } from "@scandic-hotels/trpc/types/hotel"
|
||||
import type { GalleryImage } from "../imageGallery"
|
||||
|
||||
export interface DestinationMarker {
|
||||
@@ -9,7 +9,7 @@ export interface DestinationMarker {
|
||||
name: string
|
||||
coordinates: google.maps.LatLngLiteral
|
||||
url: string
|
||||
tripadvisor: number | undefined
|
||||
tripadvisor: number | null
|
||||
amenities: Amenities
|
||||
image: GalleryImage
|
||||
}
|
||||
|
||||
5
apps/scandic-web/types/contexts/hotel-listing-data.ts
Normal file
5
apps/scandic-web/types/contexts/hotel-listing-data.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import type { createHotelListingDataStore } from "@/stores/hotel-listing-data"
|
||||
|
||||
export type HotelListingDataStore = ReturnType<
|
||||
typeof createHotelListingDataStore
|
||||
>
|
||||
@@ -1,14 +1,15 @@
|
||||
import type { DestinationCityListItem } from "@scandic-hotels/trpc/types/destinationCityPage"
|
||||
import type { CategorizedFilters } from "@scandic-hotels/trpc/types/destinationFilterAndSort"
|
||||
import type { DestinationPagesHotelData } from "@scandic-hotels/trpc/types/hotel"
|
||||
|
||||
import type { SortItem } from "../components/destinationFilterAndSort"
|
||||
import type {
|
||||
CategorizedHotelFilters,
|
||||
HotelListingHotelData,
|
||||
HotelSortItem,
|
||||
} from "@scandic-hotels/trpc/types/hotel"
|
||||
|
||||
export interface DestinationDataProviderProps extends React.PropsWithChildren {
|
||||
allHotels: DestinationPagesHotelData[]
|
||||
allHotels: HotelListingHotelData[]
|
||||
allCities?: DestinationCityListItem[]
|
||||
allFilters: CategorizedFilters
|
||||
allFilters: CategorizedHotelFilters
|
||||
filterFromUrl?: string
|
||||
sortItems: SortItem[]
|
||||
sortItems: HotelSortItem[]
|
||||
pathname: string
|
||||
}
|
||||
|
||||
11
apps/scandic-web/types/providers/hotel-listing-data.ts
Normal file
11
apps/scandic-web/types/providers/hotel-listing-data.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import type {
|
||||
CategorizedHotelFilters,
|
||||
HotelListingHotelData,
|
||||
HotelSortItem,
|
||||
} from "@scandic-hotels/trpc/types/hotel"
|
||||
|
||||
export interface HotelListingDataProviderProps extends React.PropsWithChildren {
|
||||
allHotels: HotelListingHotelData[]
|
||||
allFilters: CategorizedHotelFilters
|
||||
sortItems: HotelSortItem[]
|
||||
}
|
||||
@@ -1,14 +1,15 @@
|
||||
import type { SortOption } from "@scandic-hotels/trpc/enums/destinationFilterAndSort"
|
||||
import type { DestinationCityListItem } from "@scandic-hotels/trpc/types/destinationCityPage"
|
||||
import type { CategorizedFilters } from "@scandic-hotels/trpc/types/destinationFilterAndSort"
|
||||
import type { DestinationPagesHotelData } from "@scandic-hotels/trpc/types/hotel"
|
||||
import type {
|
||||
CategorizedHotelFilters,
|
||||
HotelListingHotelData,
|
||||
HotelSortItem,
|
||||
HotelSortOption,
|
||||
} from "@scandic-hotels/trpc/types/hotel"
|
||||
import type { ReadonlyURLSearchParams } from "next/navigation"
|
||||
|
||||
import type { SortItem } from "../components/destinationFilterAndSort"
|
||||
|
||||
interface Actions {
|
||||
updateActiveFiltersAndSort: (filters: string[], sort: string | null) => void
|
||||
setPendingSort: (sort: SortOption) => void
|
||||
setPendingSort: (sort: HotelSortOption) => void
|
||||
togglePendingFilter: (filter: string) => void
|
||||
clearPendingFilters: () => void
|
||||
resetPendingValues: () => void
|
||||
@@ -16,8 +17,8 @@ interface Actions {
|
||||
}
|
||||
|
||||
export interface SubmitCallbackData {
|
||||
sort: SortOption
|
||||
defaultSort: SortOption
|
||||
sort: HotelSortOption
|
||||
defaultSort: HotelSortOption
|
||||
filters: string[]
|
||||
basePath: string
|
||||
}
|
||||
@@ -25,19 +26,19 @@ export interface DestinationDataState {
|
||||
actions: Actions
|
||||
allCities: DestinationCityListItem[]
|
||||
activeCities: DestinationCityListItem[]
|
||||
allHotels: DestinationPagesHotelData[]
|
||||
activeHotels: DestinationPagesHotelData[]
|
||||
pendingSort: SortOption
|
||||
activeSort: SortOption
|
||||
defaultSort: SortOption
|
||||
allHotels: HotelListingHotelData[]
|
||||
activeHotels: HotelListingHotelData[]
|
||||
pendingSort: HotelSortOption
|
||||
activeSort: HotelSortOption
|
||||
defaultSort: HotelSortOption
|
||||
pendingFilters: string[]
|
||||
activeFilters: string[]
|
||||
pendingHotelCount: number
|
||||
pendingCityCount: number
|
||||
allFilters: CategorizedFilters
|
||||
allFilters: CategorizedHotelFilters
|
||||
allFilterSlugs: string[]
|
||||
basePathnameWithoutFilters: string
|
||||
sortItems: SortItem[]
|
||||
sortItems: HotelSortItem[]
|
||||
isLoading: boolean
|
||||
}
|
||||
|
||||
|
||||
46
apps/scandic-web/types/stores/hotel-listing-data.ts
Normal file
46
apps/scandic-web/types/stores/hotel-listing-data.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import type {
|
||||
CategorizedHotelFilters,
|
||||
HotelListingHotelData,
|
||||
HotelSortItem,
|
||||
HotelSortOption,
|
||||
} from "@scandic-hotels/trpc/types/hotel"
|
||||
import type { ReadonlyURLSearchParams } from "next/navigation"
|
||||
|
||||
interface Actions {
|
||||
updateActiveFiltersAndSort: (filters: string[], sort: string | null) => void
|
||||
setPendingSort: (sort: HotelSortOption) => void
|
||||
togglePendingFilter: (filter: string) => void
|
||||
clearPendingFilters: () => void
|
||||
resetPendingValues: () => void
|
||||
setIsLoading: (isLoading: boolean) => void
|
||||
}
|
||||
|
||||
export interface SubmitCallbackData {
|
||||
sort: HotelSortOption
|
||||
defaultSort: HotelSortOption
|
||||
filters: string[]
|
||||
basePath: string
|
||||
}
|
||||
export interface HotelListingDataState {
|
||||
actions: Actions
|
||||
allHotels: HotelListingHotelData[]
|
||||
activeHotels: HotelListingHotelData[]
|
||||
pendingSort: HotelSortOption
|
||||
activeSort: HotelSortOption
|
||||
defaultSort: HotelSortOption
|
||||
pendingFilters: string[]
|
||||
activeFilters: string[]
|
||||
pendingHotelCount: number
|
||||
allFilters: CategorizedHotelFilters
|
||||
allFilterSlugs: string[]
|
||||
sortItems: HotelSortItem[]
|
||||
isLoading: boolean
|
||||
}
|
||||
|
||||
export interface InitialState
|
||||
extends Pick<
|
||||
HotelListingDataState,
|
||||
"allHotels" | "sortItems" | "allFilters"
|
||||
> {
|
||||
searchParams: ReadonlyURLSearchParams
|
||||
}
|
||||
Reference in New Issue
Block a user