plan_Api: The update api issue was fixed and ready go for testing
This commit is contained in:
@@ -33,7 +33,10 @@ const create_plan_into_db = async (req: Request) => {
|
||||
const update_plan_into_db = async (req: Request) => {
|
||||
// define your own login here
|
||||
const { id } = req.params;
|
||||
console.log(req.body)
|
||||
const user = req.user
|
||||
if (user?.role !== "ADMIN") {
|
||||
throw new AppError("You don’t have permission to update plan information.!!!", 401)
|
||||
}
|
||||
const isPlanExist = await prisma.plan.findFirst({
|
||||
where: {
|
||||
id: id as string
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const create_plan = z.object({
|
||||
planName: z.string(),
|
||||
price: z.number(),
|
||||
planName: z.string("Enter the plan name..."),
|
||||
price: z.number("Enter the plan price..."),
|
||||
planType: z.enum(["FREE", "STANDARD", "PRO"]),
|
||||
planDesc: z.string(),
|
||||
planDesc: z.string("Enter the plan description..."),
|
||||
planFeatures: z.union([
|
||||
z.string(),
|
||||
z.number(),
|
||||
@@ -15,7 +15,21 @@ const create_plan = z.object({
|
||||
z.record(z.string(), z.any())
|
||||
])
|
||||
});
|
||||
const update_plan = z.object({});
|
||||
const update_plan = z.object({
|
||||
planName: z.string(),
|
||||
price: z.number(),
|
||||
planType: z.enum(["FREE", "STANDARD", "PRO"]),
|
||||
planDesc: z.string().optional(),
|
||||
planFeatures: z.union([
|
||||
z.string(),
|
||||
z.number(),
|
||||
z.boolean(),
|
||||
z.null(),
|
||||
z.array(z.any()),
|
||||
z.record(z.string(), z.any())
|
||||
])
|
||||
|
||||
});
|
||||
|
||||
export const plan_validations = {
|
||||
create_plan,
|
||||
|
||||
Reference in New Issue
Block a user