From 81f1470405413dfa76b3d6e192993d6634fc2c5d Mon Sep 17 00:00:00 2001 From: Erik Tiekstra Date: Tue, 4 Mar 2025 14:43:36 +0000 Subject: [PATCH] Merged in fix/SW-1812-include-schema (pull request #1471) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix(SW-1812): fixes the issue where we receive `null` instead of actual data inside the includeSchema * fix(SW-1812): fixes the issue where we receive `null` instead of actual data inside the includeSchema Approved-by: Matilda Landström --- .../hotels/schemas/hotel/include/include.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/scandic-web/server/routers/hotels/schemas/hotel/include/include.ts b/apps/scandic-web/server/routers/hotels/schemas/hotel/include/include.ts index 24a850119..d447f8729 100644 --- a/apps/scandic-web/server/routers/hotels/schemas/hotel/include/include.ts +++ b/apps/scandic-web/server/routers/hotels/schemas/hotel/include/include.ts @@ -11,15 +11,19 @@ import { import { additionalDataSchema, transformAdditionalData } from "./additionalData" export const includeSchema = z - .discriminatedUnion("type", [ - additionalDataSchema, - citySchema, - nearbyHotelsSchema, - restaurantsSchema, - roomCategoriesSchema, + .union([ + z.null(), + z.undefined(), + z.discriminatedUnion("type", [ + additionalDataSchema, + citySchema, + nearbyHotelsSchema, + restaurantsSchema, + roomCategoriesSchema, + ]), ]) .transform((data) => { - switch (data.type) { + switch (data?.type) { case "additionalData": return transformAdditionalData(data) case "cities":