fix(admin): corrigir erro SQL de coluna active_plan_id inexistente na busca de planos
Build and Deploy (Gitea Actions) / build-and-deploy (push) Successful in 2m40s Details

This commit is contained in:
Sidney 2026-07-19 20:08:07 -03:00
parent 104974abd1
commit cbf8b639e8
2 changed files with 5 additions and 3 deletions

View File

@ -10,7 +10,7 @@ export async function GET() {
COALESCE(p.max_professionals, 1) as "maxProfessionals",
COALESCE(p.max_services, 10) as "maxServices",
p.features, p.is_active as active,
(SELECT COUNT(*) FROM tenants WHERE active_plan_id = p.id) as subscribers
(SELECT COUNT(*) FROM subscriptions WHERE plan_id = p.id AND status = 'active') as subscribers
FROM plans p
ORDER BY p.price ASC
`);
@ -39,7 +39,7 @@ export async function GET() {
COALESCE(p.max_professionals, 1) as "maxProfessionals",
COALESCE(p.max_services, 10) as "maxServices",
p.features, p.is_active as active,
(SELECT COUNT(*) FROM tenants WHERE active_plan_id = p.id) as subscribers
(SELECT COUNT(*) FROM subscriptions WHERE plan_id = p.id AND status = 'active') as subscribers
FROM plans p
ORDER BY p.price ASC
`);

View File

@ -40,8 +40,10 @@ export default function Plans() {
const res = await fetch('/api/plans');
if (res.ok) {
const data = await res.json();
if (Array.isArray(data)) {
setPlans(data);
}
}
} catch (e) {
console.error(e);
} finally {