49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import { z } from "zod";
|
|
|
|
const ScopeSectionSchema = z.object({
|
|
title: z.string().nullish(),
|
|
title_cz: z.string().nullish(),
|
|
content: z.string().nullish(),
|
|
position: z
|
|
.union([z.number(), z.string()])
|
|
.transform((v) => Number(v))
|
|
.optional(),
|
|
});
|
|
|
|
export const CreateScopeTemplateSchema = z.object({
|
|
name: z.string().nullish(),
|
|
title: z.string().nullish(),
|
|
description: z.string().nullish(),
|
|
sections: z.array(ScopeSectionSchema).optional(),
|
|
});
|
|
|
|
export const CreateItemTemplateSchema = z.object({
|
|
id: z
|
|
.union([z.number(), z.string()])
|
|
.transform((v) => Number(v))
|
|
.optional(),
|
|
name: z.string().nullish(),
|
|
description: z.string().nullish(),
|
|
default_price: z
|
|
.union([z.number(), z.string()])
|
|
.transform((v) => Number(v))
|
|
.optional()
|
|
.default(0),
|
|
category: z.string().nullish(),
|
|
});
|
|
|
|
export const UpdateScopeTemplateSchema = z.object({
|
|
name: z.string().optional(),
|
|
title: z.string().optional(),
|
|
description: z.string().optional(),
|
|
sections: z.array(ScopeSectionSchema).optional(),
|
|
});
|
|
|
|
export type CreateScopeTemplateInput = z.infer<
|
|
typeof CreateScopeTemplateSchema
|
|
>;
|
|
export type CreateItemTemplateInput = z.infer<typeof CreateItemTemplateSchema>;
|
|
export type UpdateScopeTemplateInput = z.infer<
|
|
typeof UpdateScopeTemplateSchema
|
|
>;
|