-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use form schema types in addNoteSlice
- Loading branch information
Showing
12 changed files
with
101 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { z } from 'zod'; | ||
import { noteModel } from '@/entities/note'; | ||
import { quantitySchema } from './quantitySchema'; | ||
|
||
export const noteSchema = z.object({ | ||
date: z.string(), | ||
mealType: z.nativeEnum(noteModel.MealType), | ||
displayOrder: z.coerce.number().int().min(0), | ||
product: z | ||
.object({ | ||
id: z.number(), | ||
name: z.string(), | ||
defaultQuantity: quantitySchema, | ||
}) | ||
.nullable() | ||
.refine(product => product !== null, { message: 'Product is required' }), | ||
quantity: quantitySchema, | ||
}); | ||
|
||
export type NoteFormValues = z.infer<typeof noteSchema>; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { z } from 'zod'; | ||
import { quantitySchema } from './quantitySchema'; | ||
|
||
export const productSchema = z.object({ | ||
name: z.string().min(3).max(100), | ||
caloriesCost: z.coerce.number().int().min(1).max(4999), | ||
defaultQuantity: quantitySchema, | ||
category: z | ||
.object({ | ||
id: z.number(), | ||
name: z.string().min(3).max(50), | ||
}) | ||
.nullable() | ||
.refine(category => category !== null, { message: 'Category is required' }), | ||
}); | ||
|
||
export type ProductFormValues = z.infer<typeof productSchema>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { z } from 'zod'; | ||
|
||
export const quantitySchema = z.coerce.number().int().min(1).max(999); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters