feat(SW-325): added additional poi groups
This commit is contained in:
@@ -2,6 +2,13 @@ import { z } from "zod"
|
||||
|
||||
import { toLang } from "@/server/utils"
|
||||
|
||||
import { getPoiGroupByCategoryName } from "./utils"
|
||||
|
||||
import {
|
||||
PointOfInterestCategoryNameEnum,
|
||||
PointOfInterestGroupEnum,
|
||||
} from "@/types/hotel"
|
||||
|
||||
const ratingsSchema = z
|
||||
.object({
|
||||
tripAdvisor: z.object({
|
||||
@@ -213,32 +220,15 @@ const rewardNightSchema = z.object({
|
||||
}),
|
||||
})
|
||||
|
||||
const poiCategories = z.enum([
|
||||
"Airport",
|
||||
"Amusement park",
|
||||
"Bus terminal",
|
||||
"Fair",
|
||||
"Hospital",
|
||||
"Hotel",
|
||||
"Marketing city",
|
||||
"Museum",
|
||||
"Nearby companies",
|
||||
"Parking / Garage",
|
||||
"Restaurant",
|
||||
"Shopping",
|
||||
"Sports",
|
||||
"Theatre",
|
||||
"Tourist",
|
||||
"Transportations",
|
||||
"Zoo",
|
||||
])
|
||||
const poiGroups = z.nativeEnum(PointOfInterestGroupEnum)
|
||||
const poiCategoryNames = z.nativeEnum(PointOfInterestCategoryNameEnum)
|
||||
|
||||
export const pointOfInterestSchema = z
|
||||
.object({
|
||||
name: z.string(),
|
||||
distance: z.number(),
|
||||
category: z.object({
|
||||
name: poiCategories,
|
||||
name: poiCategoryNames,
|
||||
group: z.string(),
|
||||
}),
|
||||
location: locationSchema,
|
||||
@@ -247,7 +237,8 @@ export const pointOfInterestSchema = z
|
||||
.transform((poi) => ({
|
||||
name: poi.name,
|
||||
distance: poi.distance,
|
||||
category: poi.category.name,
|
||||
categoryName: poi.category.name,
|
||||
group: getPoiGroupByCategoryName(poi.category.name),
|
||||
coordinates: {
|
||||
lat: poi.location.latitude,
|
||||
lng: poi.location.longitude,
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { IconName } from "@/types/components/icon"
|
||||
|
||||
import deepmerge from "deepmerge"
|
||||
import { unstable_cache } from "next/cache"
|
||||
|
||||
@@ -15,23 +13,39 @@ import {
|
||||
} from "./output"
|
||||
|
||||
import type { RequestOptionsWithOutBody } from "@/types/fetch"
|
||||
import {
|
||||
PointOfInterestCategoryNameEnum,
|
||||
PointOfInterestGroupEnum,
|
||||
} from "@/types/hotel"
|
||||
import type { Lang } from "@/constants/languages"
|
||||
import type { Endpoint } from "@/lib/api/endpoints"
|
||||
|
||||
export function getIconByPoiCategory(category: string) {
|
||||
export function getPoiGroupByCategoryName(
|
||||
category: PointOfInterestCategoryNameEnum
|
||||
) {
|
||||
switch (category) {
|
||||
case "Transportations":
|
||||
return IconName.Train
|
||||
case "Shopping":
|
||||
return IconName.Shopping
|
||||
case "Museum":
|
||||
return IconName.Museum
|
||||
case "Tourist":
|
||||
return IconName.Cultural
|
||||
case "Restaurant":
|
||||
return IconName.Restaurant
|
||||
case PointOfInterestCategoryNameEnum.AIRPORT:
|
||||
case PointOfInterestCategoryNameEnum.BUS_TERMINAL:
|
||||
case PointOfInterestCategoryNameEnum.TRANSPORTATIONS:
|
||||
return PointOfInterestGroupEnum.PUBLIC_TRANSPORT
|
||||
case PointOfInterestCategoryNameEnum.AMUSEMENT_PARK:
|
||||
case PointOfInterestCategoryNameEnum.MUSEUM:
|
||||
case PointOfInterestCategoryNameEnum.SPORTS:
|
||||
case PointOfInterestCategoryNameEnum.THEATRE:
|
||||
case PointOfInterestCategoryNameEnum.TOURIST:
|
||||
case PointOfInterestCategoryNameEnum.ZOO:
|
||||
return PointOfInterestGroupEnum.ATTRACTIONS
|
||||
case PointOfInterestCategoryNameEnum.NEARBY_COMPANIES:
|
||||
case PointOfInterestCategoryNameEnum.FAIR:
|
||||
return PointOfInterestGroupEnum.BUSINESS
|
||||
case PointOfInterestCategoryNameEnum.PARKING_GARAGE:
|
||||
return PointOfInterestGroupEnum.PARKING
|
||||
case PointOfInterestCategoryNameEnum.SHOPPING:
|
||||
case PointOfInterestCategoryNameEnum.RESTAURANT:
|
||||
return PointOfInterestGroupEnum.SHOPPING_DINING
|
||||
case PointOfInterestCategoryNameEnum.HOSPITAL:
|
||||
default:
|
||||
return null
|
||||
return PointOfInterestGroupEnum.LOCATION
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user