correction bible du mande (store update temps reel)
This commit is contained in:
@@ -220,12 +220,6 @@ async function GET() {
|
||||
});
|
||||
return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$server$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["NextResponse"].json(projects);
|
||||
}
|
||||
// Plan limits for project creation
|
||||
const PLAN_PROJECT_LIMITS = {
|
||||
free: 3,
|
||||
pro: 20,
|
||||
master: 999
|
||||
};
|
||||
async function POST(request) {
|
||||
const session = await (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$src$2f$lib$2f$auth$2e$ts__$5b$app$2d$route$5d$__$28$ecmascript$29$__["auth"])();
|
||||
if (!session?.user?.id) {
|
||||
@@ -235,26 +229,26 @@ async function POST(request) {
|
||||
status: 401
|
||||
});
|
||||
}
|
||||
// Check plan limits
|
||||
const prisma = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$src$2f$lib$2f$prisma$2e$ts__$5b$app$2d$route$5d$__$28$ecmascript$29$__["default"])();
|
||||
// Check plan limit
|
||||
const user = await prisma.user.findUnique({
|
||||
where: {
|
||||
id: session.user.id
|
||||
},
|
||||
select: {
|
||||
plan: true
|
||||
include: {
|
||||
subscriptionPlan: true
|
||||
}
|
||||
});
|
||||
const plan = user?.plan || 'free';
|
||||
const limit = PLAN_PROJECT_LIMITS[plan] || PLAN_PROJECT_LIMITS.free;
|
||||
}); // Cast to any to bypass Prisma type cache issues
|
||||
const limit = user?.subscriptionPlan?.maxProjects ?? 3;
|
||||
const planName = user?.subscriptionPlan?.displayName || 'Gratuit';
|
||||
const currentCount = await prisma.project.count({
|
||||
where: {
|
||||
userId: session.user.id
|
||||
}
|
||||
});
|
||||
if (currentCount >= limit) {
|
||||
if (limit !== -1 && currentCount >= limit) {
|
||||
return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$server$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["NextResponse"].json({
|
||||
error: `Limite de ${limit} projets atteinte pour le plan ${plan}. Passez au plan supérieur !`
|
||||
error: `Limite de ${limit} projets atteinte pour le plan ${planName}. Passez au plan supérieur !`
|
||||
}, {
|
||||
status: 403
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user