fix(SW-769): removed categoryname enum from pointOfInterestSchema and use z.string() instead
This commit is contained in:
@@ -1,22 +1,15 @@
|
||||
import { IconName } from "@/types/components/icon"
|
||||
import {
|
||||
PointOfInterestCategoryNameEnum,
|
||||
PointOfInterestGroupEnum,
|
||||
} from "@/types/hotel"
|
||||
import { PointOfInterestGroupEnum } from "@/types/hotel"
|
||||
|
||||
export function getIconByPoiGroupAndCategory(
|
||||
group: PointOfInterestGroupEnum,
|
||||
category?: PointOfInterestCategoryNameEnum
|
||||
category?: string
|
||||
) {
|
||||
switch (group) {
|
||||
case PointOfInterestGroupEnum.PUBLIC_TRANSPORT:
|
||||
return category === PointOfInterestCategoryNameEnum.AIRPORT
|
||||
? IconName.Airplane
|
||||
: IconName.Train
|
||||
return category === "Airport" ? IconName.Airplane : IconName.Train
|
||||
case PointOfInterestGroupEnum.ATTRACTIONS:
|
||||
return category === PointOfInterestCategoryNameEnum.MUSEUM
|
||||
? IconName.Museum
|
||||
: IconName.Camera
|
||||
return category === "Museum" ? IconName.Museum : IconName.Camera
|
||||
case PointOfInterestGroupEnum.BUSINESS:
|
||||
return IconName.Business
|
||||
case PointOfInterestGroupEnum.PARKING:
|
||||
|
||||
@@ -13,7 +13,6 @@ import { AlertTypeEnum } from "@/types/enums/alert"
|
||||
import { CurrencyEnum } from "@/types/enums/currency"
|
||||
import { FacilityEnum } from "@/types/enums/facilities"
|
||||
import { PackageTypeEnum } from "@/types/enums/packages"
|
||||
import { PointOfInterestCategoryNameEnum } from "@/types/hotel"
|
||||
|
||||
const ratingsSchema = z
|
||||
.object({
|
||||
@@ -199,14 +198,12 @@ const rewardNightSchema = z.object({
|
||||
}),
|
||||
})
|
||||
|
||||
const poiCategoryNames = z.nativeEnum(PointOfInterestCategoryNameEnum)
|
||||
|
||||
export const pointOfInterestSchema = z
|
||||
.object({
|
||||
name: z.string(),
|
||||
distance: z.number(),
|
||||
category: z.object({
|
||||
name: poiCategoryNames,
|
||||
name: z.string(),
|
||||
group: z.string(),
|
||||
}),
|
||||
location: locationSchema,
|
||||
|
||||
@@ -12,39 +12,34 @@ import {
|
||||
type Countries,
|
||||
} from "./output"
|
||||
|
||||
import type { RequestOptionsWithOutBody } from "@/types/fetch"
|
||||
import {
|
||||
PointOfInterestCategoryNameEnum,
|
||||
PointOfInterestGroupEnum,
|
||||
} from "@/types/hotel"
|
||||
import { HotelLocation } from "@/types/trpc/routers/hotel/locations"
|
||||
import type { Lang } from "@/constants/languages"
|
||||
import type { Endpoint } from "@/lib/api/endpoints"
|
||||
import type { RequestOptionsWithOutBody } from "@/types/fetch"
|
||||
import { PointOfInterestGroupEnum } from "@/types/hotel"
|
||||
import { HotelLocation } from "@/types/trpc/routers/hotel/locations"
|
||||
|
||||
export function getPoiGroupByCategoryName(
|
||||
category: PointOfInterestCategoryNameEnum
|
||||
) {
|
||||
export function getPoiGroupByCategoryName(category: string) {
|
||||
switch (category) {
|
||||
case PointOfInterestCategoryNameEnum.AIRPORT:
|
||||
case PointOfInterestCategoryNameEnum.BUS_TERMINAL:
|
||||
case PointOfInterestCategoryNameEnum.TRANSPORTATIONS:
|
||||
case "Airport":
|
||||
case "Bus terminal":
|
||||
case "Transportations":
|
||||
return PointOfInterestGroupEnum.PUBLIC_TRANSPORT
|
||||
case PointOfInterestCategoryNameEnum.AMUSEMENT_PARK:
|
||||
case PointOfInterestCategoryNameEnum.MUSEUM:
|
||||
case PointOfInterestCategoryNameEnum.SPORTS:
|
||||
case PointOfInterestCategoryNameEnum.THEATRE:
|
||||
case PointOfInterestCategoryNameEnum.TOURIST:
|
||||
case PointOfInterestCategoryNameEnum.ZOO:
|
||||
case "Amusement park":
|
||||
case "Museum":
|
||||
case "Sports":
|
||||
case "Theatre":
|
||||
case "Tourist":
|
||||
case "Zoo":
|
||||
return PointOfInterestGroupEnum.ATTRACTIONS
|
||||
case PointOfInterestCategoryNameEnum.NEARBY_COMPANIES:
|
||||
case PointOfInterestCategoryNameEnum.FAIR:
|
||||
case "Nearby companies":
|
||||
case "Fair":
|
||||
return PointOfInterestGroupEnum.BUSINESS
|
||||
case PointOfInterestCategoryNameEnum.PARKING_GARAGE:
|
||||
case "Parking / Garage":
|
||||
return PointOfInterestGroupEnum.PARKING
|
||||
case PointOfInterestCategoryNameEnum.SHOPPING:
|
||||
case PointOfInterestCategoryNameEnum.RESTAURANT:
|
||||
case "Shopping":
|
||||
case "Restaurant":
|
||||
return PointOfInterestGroupEnum.SHOPPING_DINING
|
||||
case PointOfInterestCategoryNameEnum.HOSPITAL:
|
||||
case "Hospital":
|
||||
default:
|
||||
return PointOfInterestGroupEnum.LOCATION
|
||||
}
|
||||
|
||||
@@ -2,14 +2,11 @@ import { poiVariants } from "@/components/Maps/Markers/Poi/variants"
|
||||
|
||||
import type { VariantProps } from "class-variance-authority"
|
||||
|
||||
import {
|
||||
PointOfInterestCategoryNameEnum,
|
||||
PointOfInterestGroupEnum,
|
||||
} from "@/types/hotel"
|
||||
import type { PointOfInterestGroupEnum } from "@/types/hotel"
|
||||
|
||||
export interface PoiMarkerProps extends VariantProps<typeof poiVariants> {
|
||||
group: PointOfInterestGroupEnum
|
||||
categoryName?: PointOfInterestCategoryNameEnum
|
||||
categoryName?: string
|
||||
size?: number
|
||||
className?: string
|
||||
}
|
||||
|
||||
@@ -26,26 +26,6 @@ export type GalleryImage = z.infer<typeof imageSchema>
|
||||
|
||||
export type PointOfInterest = z.output<typeof pointOfInterestSchema>
|
||||
|
||||
export enum PointOfInterestCategoryNameEnum {
|
||||
AIRPORT = "Airport",
|
||||
AMUSEMENT_PARK = "Amusement park",
|
||||
BUS_TERMINAL = "Bus terminal",
|
||||
FAIR = "Fair",
|
||||
HOSPITAL = "Hospital",
|
||||
HOTEL = "Hotel",
|
||||
MARKETING_CITY = "Marketing city",
|
||||
MUSEUM = "Museum",
|
||||
NEARBY_COMPANIES = "Nearby companies",
|
||||
PARKING_GARAGE = "Parking / Garage",
|
||||
RESTAURANT = "Restaurant",
|
||||
SHOPPING = "Shopping",
|
||||
SPORTS = "Sports",
|
||||
THEATRE = "Theatre",
|
||||
TOURIST = "Tourist",
|
||||
TRANSPORTATIONS = "Transportations",
|
||||
ZOO = "Zoo",
|
||||
}
|
||||
|
||||
export enum PointOfInterestGroupEnum {
|
||||
PUBLIC_TRANSPORT = "Public transport",
|
||||
ATTRACTIONS = "Attractions",
|
||||
|
||||
Reference in New Issue
Block a user