fix: improve handling of booking widget params from search params
now we are defensive in parsing the location if parsing fails the not found is now displayed
This commit is contained in:
@@ -317,12 +317,21 @@ export const locationsSchema = z.object({
|
||||
},
|
||||
},
|
||||
type: location.type,
|
||||
operaId: location.attributes.operaId ?? "",
|
||||
}
|
||||
})
|
||||
)
|
||||
.transform((data) =>
|
||||
data
|
||||
.filter((node) => !!node)
|
||||
.filter((node) => {
|
||||
if (node.type === "hotels") {
|
||||
if (!node.operaId) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
.sort((a, b) => {
|
||||
if (a.type === b.type) {
|
||||
return a.name.localeCompare(b.name)
|
||||
|
||||
@@ -13,7 +13,7 @@ export const locationHotelSchema = z.object({
|
||||
.optional(),
|
||||
keyWords: z.array(z.string()).optional(),
|
||||
name: z.string().optional().default(""),
|
||||
operaId: z.string().optional(),
|
||||
operaId: z.coerce.string().optional(),
|
||||
}),
|
||||
id: z.string().optional().default(""),
|
||||
relationships: z
|
||||
|
||||
Reference in New Issue
Block a user