fix: clean up hotel and its typings
This commit is contained in:
72
server/routers/hotels/schemas/hotel/include/restaurants.ts
Normal file
72
server/routers/hotels/schemas/hotel/include/restaurants.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import { z } from "zod"
|
||||
|
||||
import { imageSchema } from "@/server/routers/hotels/schemas/image"
|
||||
|
||||
import { CurrencyEnum } from "@/types/enums/currency"
|
||||
|
||||
const contentSchema = z.object({
|
||||
images: z.array(imageSchema).default([]),
|
||||
texts: z.object({
|
||||
descriptions: z.object({
|
||||
medium: z.string().default(""),
|
||||
short: z.string().default(""),
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
||||
const externalBreakfastSchema = z.object({
|
||||
isAvailable: z.boolean().default(false),
|
||||
localPriceForExternalGuests: z.object({
|
||||
amount: z.number().default(0),
|
||||
currency: z.nativeEnum(CurrencyEnum).default(CurrencyEnum.SEK),
|
||||
}),
|
||||
})
|
||||
|
||||
const menuItemSchema = z.object({
|
||||
name: z.string(),
|
||||
url: z.string().url(),
|
||||
})
|
||||
|
||||
const daySchema = z.object({
|
||||
alwaysOpen: z.boolean().default(false),
|
||||
closingTime: z.string().default(""),
|
||||
isClosed: z.boolean().default(false),
|
||||
openingTime: z.string().default(""),
|
||||
sortOrder: z.number().int().default(0),
|
||||
})
|
||||
|
||||
const openingDetailsSchema = z.object({
|
||||
alternateOpeningHours: z.object({
|
||||
isActive: z.boolean().default(false),
|
||||
}),
|
||||
openingHours: z.object({
|
||||
friday: daySchema,
|
||||
isActive: z.boolean().default(false),
|
||||
monday: daySchema,
|
||||
name: z.string().default(""),
|
||||
saturday: daySchema,
|
||||
sunday: daySchema,
|
||||
thursday: daySchema,
|
||||
tuesday: daySchema,
|
||||
wednesday: daySchema,
|
||||
}),
|
||||
})
|
||||
|
||||
export const restaurantsSchema = z.object({
|
||||
attributes: z.object({
|
||||
bookTableUrl: z.string().default(""),
|
||||
content: contentSchema,
|
||||
// When using .email().default("") is not sufficent
|
||||
// so .optional also needs to be chained
|
||||
email: z.string().email().optional(),
|
||||
externalBreakfast: externalBreakfastSchema,
|
||||
isPublished: z.boolean().default(false),
|
||||
menus: z.array(menuItemSchema).default([]),
|
||||
name: z.string().default(""),
|
||||
openingDetails: z.array(openingDetailsSchema).default([]),
|
||||
restaurantPage: z.boolean().default(false),
|
||||
specialAlerts: z.array(z.object({})).default([]),
|
||||
}),
|
||||
id: z.string(),
|
||||
type: z.literal("restaurants"),
|
||||
})
|
||||
Reference in New Issue
Block a user