Mostrar badge de plan y botón de pago deshabilitado
This commit is contained in:
@@ -9,6 +9,12 @@ import {
|
||||
formatEuros,
|
||||
formatFecha,
|
||||
} from '@/lib/funnel';
|
||||
import { getCurrentTenantId } from '@/lib/auth/current-user';
|
||||
import { db } from '@/db';
|
||||
import { tenants, plans } from '@/db/schema';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import { formatPlanBadge } from '@/lib/billing/plan';
|
||||
import { STRIPE_ENABLED } from '@/lib/billing/stripe';
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
@@ -27,6 +33,13 @@ export default async function PanelPage({
|
||||
|
||||
const [leads, resumen] = await Promise.all([getLeads(filtro), getResumen()]);
|
||||
|
||||
const tenantId = await getCurrentTenantId();
|
||||
const [tenant] = await db.select().from(tenants).where(eq(tenants.id, tenantId)).limit(1);
|
||||
const [plan] = tenant?.planId
|
||||
? await db.select().from(plans).where(eq(plans.id, tenant.planId)).limit(1)
|
||||
: [];
|
||||
const badge = formatPlanBadge(plan?.nombre ?? null, tenant?.subscriptionStatus ?? 'trial', tenant?.trialEndsAt ?? null);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
<div className="flex flex-col gap-1">
|
||||
@@ -36,6 +49,18 @@ export default async function PanelPage({
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between bg-white border border-gray-200 rounded-xl px-4 py-3">
|
||||
<span className="text-sm font-medium text-gray-700">{badge}</span>
|
||||
<button
|
||||
type="button"
|
||||
disabled={!STRIPE_ENABLED}
|
||||
title="Próximamente"
|
||||
className="text-xs font-semibold text-gray-400 cursor-not-allowed"
|
||||
>
|
||||
Gestionar pago
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Filtros por estado */}
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{FILTROS.map((f) => {
|
||||
|
||||
Reference in New Issue
Block a user