correction bible du mande (store update temps reel)
This commit is contained in:
@@ -453,11 +453,6 @@ const dynamic = 'force-dynamic';
|
||||
;
|
||||
;
|
||||
;
|
||||
const PLAN_AI_LIMITS = {
|
||||
free: 100,
|
||||
pro: 5000,
|
||||
master: 999999
|
||||
};
|
||||
async function POST(request) {
|
||||
try {
|
||||
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"])();
|
||||
@@ -474,11 +469,10 @@ async function POST(request) {
|
||||
where: {
|
||||
id: session.user.id
|
||||
},
|
||||
select: {
|
||||
plan: true,
|
||||
aiActionsUsed: true
|
||||
include: {
|
||||
subscriptionPlan: true
|
||||
}
|
||||
});
|
||||
}); // Bypass Prisma client types for this relation
|
||||
if (!dbUser) {
|
||||
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: 'Utilisateur non trouvé'
|
||||
@@ -486,10 +480,11 @@ async function POST(request) {
|
||||
status: 404
|
||||
});
|
||||
}
|
||||
const limit = PLAN_AI_LIMITS[dbUser.plan] || PLAN_AI_LIMITS.free;
|
||||
if (dbUser.aiActionsUsed >= limit) {
|
||||
const limit = dbUser.subscriptionPlan?.maxAiActions ?? 100;
|
||||
const planName = dbUser.subscriptionPlan?.displayName || 'Gratuit';
|
||||
if (limit !== -1 && dbUser.aiActionsUsed >= 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} actions IA atteinte pour le plan ${dbUser.plan}. Passez au plan supérieur !`
|
||||
error: `Limite de ${limit} actions IA atteinte pour le plan ${planName}. Passez au plan supérieur !`
|
||||
}, {
|
||||
status: 403
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user