Mostrar badge de plan y botón de pago deshabilitado
This commit is contained in:
@@ -9,6 +9,12 @@ import {
|
|||||||
formatEuros,
|
formatEuros,
|
||||||
formatFecha,
|
formatFecha,
|
||||||
} from '@/lib/funnel';
|
} 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';
|
export const dynamic = 'force-dynamic';
|
||||||
|
|
||||||
@@ -27,6 +33,13 @@ export default async function PanelPage({
|
|||||||
|
|
||||||
const [leads, resumen] = await Promise.all([getLeads(filtro), getResumen()]);
|
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 (
|
return (
|
||||||
<div className="flex flex-col gap-6">
|
<div className="flex flex-col gap-6">
|
||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
@@ -36,6 +49,18 @@ export default async function PanelPage({
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</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 */}
|
{/* Filtros por estado */}
|
||||||
<div className="flex flex-wrap gap-2">
|
<div className="flex flex-wrap gap-2">
|
||||||
{FILTROS.map((f) => {
|
{FILTROS.map((f) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user