✅ product admin crud
This commit is contained in:
@@ -1,14 +1,37 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const productModel = z.object({
|
||||
id: z.string(),
|
||||
linkId: z.string(),
|
||||
title: z.string(),
|
||||
description: z.string(),
|
||||
longDescription: z.string(),
|
||||
price: z.number(),
|
||||
discountPrice: z.number(),
|
||||
id: z.number().optional(),
|
||||
linkId: z.string().min(8).max(32),
|
||||
title: z.string().min(1).max(64),
|
||||
description: z.string().min(1),
|
||||
longDescription: z.string().min(1),
|
||||
price: z.coerce.number().nonnegative(),
|
||||
discountPrice: z.coerce.number().nonnegative(),
|
||||
createdAt: z.coerce.string().optional(),
|
||||
updatedAt: z.coerce.string().optional(),
|
||||
});
|
||||
|
||||
export type ProductModel = z.infer<typeof productModel>;
|
||||
|
||||
export const createProductPayload = productModel.omit({
|
||||
id: true,
|
||||
linkId: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
});
|
||||
|
||||
export type CreateProductPayload = z.infer<typeof createProductPayload>;
|
||||
|
||||
export const updateProductPayload = productModel
|
||||
.omit({
|
||||
linkId: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
})
|
||||
.partial()
|
||||
.extend({
|
||||
id: z.number(),
|
||||
});
|
||||
|
||||
export type UpdateProductPayload = z.infer<typeof updateProductPayload>;
|
||||
|
||||
Reference in New Issue
Block a user