feat(SW-325): added additional poi groups

This commit is contained in:
Erik Tiekstra
2024-09-26 15:20:22 +02:00
parent 947ceb1736
commit fe607f640c
17 changed files with 254 additions and 123 deletions

View File

@@ -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,