From b105fd21511246c16a9ea9164b4137a2f96e512c Mon Sep 17 00:00:00 2001 From: Sidney Date: Sun, 19 Jul 2026 20:14:25 -0300 Subject: [PATCH] fix(admin): corrigir coalesce de preco para priorizar price_monthly sobre price=0 --- admin/src/app/api/plans/route.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/admin/src/app/api/plans/route.ts b/admin/src/app/api/plans/route.ts index e6407a5..f09f51f 100644 --- a/admin/src/app/api/plans/route.ts +++ b/admin/src/app/api/plans/route.ts @@ -5,8 +5,8 @@ export async function GET() { try { let res = await query(` SELECT p.id, p.name, COALESCE(p.slug, LOWER(p.name)) as slug, - COALESCE(p.price, p.price_monthly, 0) as "priceMonthly", - COALESCE(p.price_yearly, p.price * 10, 0) as "priceYearly", + COALESCE(NULLIF(p.price_monthly, 0), NULLIF(p.price, 0), 0) as "priceMonthly", + COALESCE(NULLIF(p.price_yearly, 0), p.price * 10, 0) as "priceYearly", COALESCE(p.max_professionals, 1) as "maxProfessionals", COALESCE(p.max_services, 10) as "maxServices", p.features, p.is_active as active, @@ -34,8 +34,8 @@ export async function GET() { res = await query(` SELECT p.id, p.name, COALESCE(p.slug, LOWER(p.name)) as slug, - COALESCE(p.price, p.price_monthly, 0) as "priceMonthly", - COALESCE(p.price_yearly, p.price * 10, 0) as "priceYearly", + COALESCE(NULLIF(p.price_monthly, 0), NULLIF(p.price, 0), 0) as "priceMonthly", + COALESCE(NULLIF(p.price_yearly, 0), p.price * 10, 0) as "priceYearly", COALESCE(p.max_professionals, 1) as "maxProfessionals", COALESCE(p.max_services, 10) as "maxServices", p.features, p.is_active as active,