refactor(items): move workflows into use cases
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { z } from "zod"
|
||||
|
||||
export const createItemSchema = z.object({
|
||||
name: z.string().min(1, {
|
||||
error: "Name is required",
|
||||
}),
|
||||
categoryId: z.string().min(1, {
|
||||
error: "Category is required",
|
||||
}),
|
||||
stock: z.coerce.number().int().nonnegative().min(0, {
|
||||
error: "Stock is required",
|
||||
}),
|
||||
})
|
||||
|
||||
export type CreateItemFormType = z.input<typeof createItemSchema>
|
||||
export type CreateItemData = z.output<typeof createItemSchema>
|
||||
|
||||
export const updateItemSchema = createItemSchema.extend({
|
||||
id: z.string().min(1, {
|
||||
error: "Item is required",
|
||||
}),
|
||||
})
|
||||
|
||||
export type UpdateItemFormType = z.input<typeof updateItemSchema>
|
||||
export type UpdateItemData = z.output<typeof updateItemSchema>
|
||||
|
||||
export const getItemByIdSchema = z.object({
|
||||
id: z.string().min(1, {
|
||||
error: "Item is required",
|
||||
}),
|
||||
})
|
||||
|
||||
export type GetItemByIdFormType = z.infer<typeof getItemByIdSchema>
|
||||
Reference in New Issue
Block a user