refactor: refactor data schemas
This commit is contained in:
parent
efa9789a2a
commit
0176a59865
1 changed files with 9 additions and 14 deletions
|
|
@ -1,21 +1,16 @@
|
|||
import { z } from "zod";
|
||||
|
||||
export const ImageSchema = z.object({
|
||||
export const StepsSchema = z.object({
|
||||
id: z.uuid().default(() => crypto.randomUUID()),
|
||||
file: z.instanceof(File),
|
||||
alt: z.string().default(""),
|
||||
width: z.number(),
|
||||
height: z.number(),
|
||||
size: z.number(),
|
||||
mimeType: z.string(),
|
||||
createdAt: z.date(),
|
||||
updatedAt: z.date(),
|
||||
text: z.string().min(1, "Text is required"),
|
||||
order: z.number(),
|
||||
frameId: z.uuid(),
|
||||
});
|
||||
|
||||
export const FrameSchema = z.object({
|
||||
id: z.uuid().default(() => crypto.randomUUID()),
|
||||
imageId: z.uuid(),
|
||||
steps: z.array(z.string()).min(1, "Steps are required"),
|
||||
file: z.instanceof(File),
|
||||
steps: z.array(StepsSchema).min(1, "Steps are required"),
|
||||
order: z.number(),
|
||||
});
|
||||
|
||||
|
|
@ -27,9 +22,9 @@ export const GuideSchema = z.object({
|
|||
createdAt: z.date(),
|
||||
updatedAt: z.date(),
|
||||
deletedAt: z.date().optional(),
|
||||
frames: z.array(FrameSchema),
|
||||
frames: z.array(FrameSchema).min(1, "Frames are required"),
|
||||
});
|
||||
|
||||
export type Guide = z.infer<typeof GuideSchema>;
|
||||
export type Image = z.infer<typeof ImageSchema>;
|
||||
export type Steps = z.infer<typeof StepsSchema>;
|
||||
export type Frame = z.infer<typeof FrameSchema>;
|
||||
export type Guide = z.infer<typeof GuideSchema>;
|
||||
|
|
|
|||
Loading…
Reference in a new issue