73 lines
2.0 KiB
TypeScript
73 lines
2.0 KiB
TypeScript
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"),
|
|
})
|