feat(admin): 예전/최신 어드민 통합 — 실데이터 복원 + 인증 아키텍처 정리

예전 배포본(HEAD)의 상세 기능을 새 아키텍처(인증=.NET 백엔드, 데이터=Supabase)
위에 실데이터로 복원. 예전 HEAD는 서명 쿠키를 거부하고 위조 쿠키는 통과시키는
인증 결함이 있었고, 삭제된 페이지 다수는 백엔드 호출 0인 하드코딩 목업이었음.

인증/세션
- 로그인 이메일 전용화(username 폐지), 에러 키별 안내 메시지
- ADMIN_COOKIE_SECURE 옵션: TLS 없는 LAN HTTP 배포에서 Secure 쿠키 유실로
  로그인이 유지되지 않던 문제 해결 (login/logout route, admin-session, compose, .env.example)
- Supabase 미설정 시 우아한 저하: isSupabaseAdminConfigured + UnavailableAdminPanel

기능 복원 (실데이터)
- Release Hub: Forgejo API 실데이터(다운로드 수/SHA-256 체크섬/릴리스 이력)
- Ad Monetization: 데스크톱 미디에이션 10개 어댑터 로스터(fail-closed) + ad_reward_claims 통계
- License Issuer: 서버사이드 Ed25519 서명(/api/admin/license, super_admin 전용),
  개인키는 ADMIN_LICENSE_PRIVATE_KEY env로만, 발급 감사를 .NET AdminAuditEntries에 기록
- Service Models: STT 7종/LLM 5종 프리셋 드롭다운 + 자동채움
- 대시보드 ARR/MRR KPI: Supabase 구독 실집계(티어 월단가 기반)
- 사용자 상세 티어별 기능 배지(pro_plus 조건부)

.NET
- SuperAdminOnly 정책 추가, /api/admin/license-audit 엔드포인트, LicenseAuditDto
This commit is contained in:
Yun Chan 2026-08-23 23:38:08 +09:00
parent a9c9a1ca6e
commit 5a34f66981
66 changed files with 4471 additions and 3501 deletions

View file

@ -4,7 +4,7 @@
// 구독 수정/삭제 클라이언트 컴포넌트
import { useState } from 'react'
import { Box, Button } from '@mui/material'
import { Alert, Box, Button } from '@mui/material'
import { d3roFontMono } from '@d3ro/ui/theme'
import { SubscriptionForm } from '@/components/subscription-form'
import { MemoDialog } from '@/components/memo-dialog'
@ -36,9 +36,11 @@ export function SubscriptionDetailClient({
const router = useRouter()
const [deleteOpen, setDeleteOpen] = useState(false)
const [deleteLoading, setDeleteLoading] = useState(false)
const [deleteError, setDeleteError] = useState<string | null>(null)
const handleDelete = async (memo: string): Promise<void> => {
setDeleteLoading(true)
setDeleteError(null)
try {
await callAdminApi(`admin-subscriptions?userId=${userId}`, {
method: 'DELETE',
@ -46,8 +48,8 @@ export function SubscriptionDetailClient({
})
setDeleteOpen(false)
router.refresh()
} catch {
// error handled in dialog
} catch (error) {
setDeleteError(error instanceof Error ? error.message : 'Subscription deletion failed')
} finally {
setDeleteLoading(false)
}
@ -74,6 +76,7 @@ export function SubscriptionDetailClient({
{/* admin 이상: 삭제 가능 */}
{canCreateDelete && (
<>
{deleteError && <Alert severity="error" sx={{ mt: 2 }}>{deleteError}</Alert>}
<Box sx={{ mt: 2, display: 'flex', justifyContent: 'flex-end' }}>
<Button
variant="outlined"

View file

@ -4,57 +4,57 @@
import { Box, Typography } from '@mui/material'
import { C, FONT_SANS, FONT_MONO, panelSx, tableSx, statusBadgeSx } from '@/lib/console-theme'
import { DoubleBezelCard, TactileBadge } from '@d3ro/ui/components/ds'
import { getSupabaseServerClient } from '@/lib/supabase-server'
import { getSupabaseAdminClient, isSupabaseAdminConfigured } from '@/lib/supabase-admin'
import { UnavailableAdminPanel } from '@/components/unavailable-admin-panel'
import { requireManager, hasMinRole } from '@/lib/admin-guard'
import Link from 'next/link'
import { notFound } from 'next/navigation'
import { SubscriptionDetailClient } from './client'
import { fetchUsers } from '@/lib/api-server'
interface PageProps {
params: Promise<{ id: string }>
}
export default async function SubscriptionDetailPage({ params }: PageProps): Promise<React.ReactElement> {
if (!isSupabaseAdminConfigured()) {
return (
<UnavailableAdminPanel
title="Subscription Detail"
capability="Plans, billing, payment history"
reason="SUPABASE_URL / SUPABASE_SERVICE_ROLE_KEY 환경변수가 설정되지 않아 Supabase 관리 데이터에 연결할 수 없습니다. 환경변수를 설정하면 실데이터가 표시됩니다."
/>
)
}
const { id: userId } = await params
const admin = await requireManager()
const supabase = await getSupabaseServerClient()
const supabase = await getSupabaseAdminClient()
const [subRes, profileRes, auditRes] = await Promise.all([
supabase.from('subscriptions').select('*').eq('user_id', userId).maybeSingle(),
supabase.from('subscriptions').select('id, user_id, tier, status, provider, payment_provider, current_period_start, current_period_end, overage_credits, admin_note, cancel_at, created_at, updated_at').eq('user_id', userId).maybeSingle(),
supabase.from('profiles').select('id, name, tier, role').eq('id', userId).maybeSingle(),
supabase.from('audit_log').select('*')
supabase.from('audit_log').select('id, action, target_type, target_id, memo, created_at')
.eq('target_id', userId)
.eq('target_type', 'subscription')
.order('created_at', { ascending: false })
.limit(20),
])
// Fallback to mock user
const allUsers = await fetchUsers()
const matchedUser = allUsers.find((u) => String(u.id) === userId || u.uid === userId) || allUsers[0]
if (subRes.error) throw new Error(`Supabase subscription failed: ${subRes.error.message}`)
if (profileRes.error) throw new Error(`Supabase profile failed: ${profileRes.error.message}`)
if (auditRes.error) throw new Error(`Supabase audit log failed: ${auditRes.error.message}`)
if (!profileRes.data) notFound()
const profile = profileRes.data || {
id: matchedUser.uid,
name: matchedUser.name,
tier: matchedUser.tier,
role: matchedUser.role,
const profile = profileRes.data
const sub = subRes.data
const auditLogs = auditRes.data ?? []
if (sub && (!['free', 'pro', 'pro_plus'].includes(sub.tier) ||
!['active', 'canceled', 'past_due', 'expired'].includes(sub.status) ||
!Number.isInteger(sub.overage_credits))) {
throw new Error('Supabase subscription response is invalid')
}
const sub = subRes.data || {
tier: matchedUser.tier,
status: 'active',
payment_provider: 'LemonSqueezy',
current_period_end: '2026-12-31T23:59:59Z',
overage_credits: 0,
admin_note: 'Enterprise Tier Active',
}
const auditLogs = (auditRes.data && auditRes.data.length > 0) ? auditRes.data : [
{ id: 101, created_at: '2026-08-18T10:00:00Z', action: 'TIER_UPGRADE', memo: 'Upgraded to PRO+ VIP with Realtime Voice access' },
{ id: 102, created_at: '2026-06-01T09:00:00Z', action: 'SUBSCRIPTION_CREATE', memo: 'Initial subscription creation via LemonSqueezy checkout' },
]
const tier = (sub.tier as string) || (profile.tier as string) || 'free'
const tier = (sub?.tier as string | undefined) || (profile.tier as string) || 'free'
const isProPlus = tier === 'pro_plus'
const isPro = tier === 'pro'
@ -90,7 +90,7 @@ export default async function SubscriptionDetailPage({ params }: PageProps): Pro
sx={{
fontFamily: FONT_SANS,
fontSize: '20px',
fontWeight: 700,
fontWeight: 500,
color: C.bright,
letterSpacing: '-0.02em',
m: 0,
@ -119,7 +119,7 @@ export default async function SubscriptionDetailPage({ params }: PageProps): Pro
<Box sx={{ display: 'grid', gridTemplateColumns: { xs: '1fr', lg: '1fr 1fr' }, gap: 3 }}>
{/* User Info Card */}
<DoubleBezelCard bezelPadding="6px" innerPadding="24px">
<Typography sx={{ fontFamily: FONT_SANS, fontSize: '16px', fontWeight: 700, color: C.bright, mb: 2 }}>
<Typography sx={{ fontFamily: FONT_SANS, fontSize: '16px', fontWeight: 500, color: C.bright, mb: 2 }}>
Account Identifiers
</Typography>
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 1.5, fontFamily: FONT_SANS, fontSize: '13px' }}>
@ -131,15 +131,15 @@ export default async function SubscriptionDetailPage({ params }: PageProps): Pro
{/* Subscription State Card */}
<DoubleBezelCard bezelPadding="6px" innerPadding="24px">
<Typography sx={{ fontFamily: FONT_SANS, fontSize: '16px', fontWeight: 700, color: C.bright, mb: 2 }}>
<Typography sx={{ fontFamily: FONT_SANS, fontSize: '16px', fontWeight: 500, color: C.bright, mb: 2 }}>
Contract Status & Pricing
</Typography>
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 1.5, fontFamily: FONT_SANS, fontSize: '13px' }}>
<Row label="Plan Level" value={isProPlus ? 'PRO+ VIP ($29/mo)' : isPro ? 'PRO ($12/mo)' : 'FREE'} />
<Row label="Current Status" value={((sub.status as string) ?? 'active').toUpperCase()} />
<Row label="Payment Gateway" value={((sub.payment_provider as string) ?? 'LemonSqueezy').toUpperCase()} />
<Row label="Contract Expires / Renews" value={sub.current_period_end ? new Date(sub.current_period_end as string).toLocaleDateString() : 'Auto Renew'} />
<Row label="Overage Credits" value={String(sub.overage_credits ?? 0)} isMono />
<Row label="Plan Level" value={isProPlus ? 'PRO+ VIP' : isPro ? 'PRO' : 'FREE'} />
<Row label="Current Status" value={sub?.status ? String(sub.status).toUpperCase() : 'NO SUBSCRIPTION'} />
<Row label="Payment Gateway" value={sub?.payment_provider ? String(sub.payment_provider).toUpperCase() : 'NOT ASSIGNED'} />
<Row label="Contract Expires / Renews" value={sub?.current_period_end ? new Date(sub.current_period_end as string).toLocaleDateString() : 'NOT SET'} />
<Row label="Overage Credits" value={sub ? String(sub.overage_credits) : 'NO SUBSCRIPTION'} isMono />
</Box>
</DoubleBezelCard>
</Box>
@ -151,10 +151,10 @@ export default async function SubscriptionDetailPage({ params }: PageProps): Pro
canEdit={true}
canCreateDelete={hasMinRole(admin, 'admin')}
initialSub={sub ? ({
tier: (sub.tier as 'free' | 'pro' | 'pro_plus') ?? 'free',
status: (sub.status as 'active' | 'canceled' | 'past_due' | 'expired') ?? 'active',
tier: sub.tier as 'free' | 'pro' | 'pro_plus',
status: sub.status as 'active' | 'canceled' | 'past_due' | 'expired',
currentPeriodEnd: (sub.current_period_end as string | null) ?? null,
overageCredits: (sub.overage_credits as number) ?? 0,
overageCredits: sub.overage_credits as number,
adminNote: (sub.admin_note as string | null) ?? null,
}) : undefined}
/>
@ -162,7 +162,7 @@ export default async function SubscriptionDetailPage({ params }: PageProps): Pro
{/* Audit Trail Table */}
<DoubleBezelCard bezelPadding="6px" innerPadding="24px">
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 2 }}>
<Typography sx={{ fontFamily: FONT_SANS, fontSize: '15px', fontWeight: 700, color: C.bright }}>
<Typography sx={{ fontFamily: FONT_SANS, fontSize: '15px', fontWeight: 500, color: C.bright }}>
Subscription Security Audit Trail
</Typography>
<TactileBadge tone="mono" mono>
@ -181,7 +181,13 @@ export default async function SubscriptionDetailPage({ params }: PageProps): Pro
</Box>
</Box>
<Box component="tbody">
{auditLogs.map((log) => (
{auditLogs.length === 0 ? (
<Box component="tr">
<Box component="td" colSpan={4} sx={{ textAlign: 'center', color: C.dim, py: 3 }}>
No subscription audit events have been recorded.
</Box>
</Box>
) : auditLogs.map((log) => (
<Box component="tr" key={log.id as number}>
<Box component="td" sx={{ fontFamily: FONT_MONO, fontSize: '12px', color: C.dim }}>
{new Date(log.created_at as string).toLocaleString()}

View file

@ -28,7 +28,7 @@ export function NewSubscriptionClient({ initialUserId }: NewSubscriptionClientPr
size="small"
value={userId}
onChange={(e) => setUserId(e.target.value)}
placeholder="e.g. usr_d3ro_001 or Supabase UUID..."
placeholder="Supabase user UUID"
sx={{
'& .MuiOutlinedInput-root': {
bgcolor: 'rgba(10, 17, 31, 0.7)',

View file

@ -49,7 +49,7 @@ export default async function NewSubscriptionPage({ searchParams }: PageProps):
sx={{
fontFamily: FONT_SANS,
fontSize: '20px',
fontWeight: 700,
fontWeight: 500,
color: C.bright,
letterSpacing: '-0.02em',
m: 0,

View file

@ -1,11 +1,12 @@
// apps/admin/src/app/(admin)/subscriptions/page.tsx
// D3RO Voice — Subscriptions & ARR Revenue Console (Midnight Glass v2)
// D3RO Voice — Subscription Operations Console
import { Box, Typography, Button } from '@mui/material'
import { C, FONT_SANS, FONT_MONO, panelSx, tableSx, filterBtnSx, statusBadgeSx, primaryButtonSx } from '@/lib/console-theme'
import { DoubleBezelCard, TactileBadge, StatRing } from '@d3ro/ui/components/ds'
import { getSupabaseServerClient } from '@/lib/supabase-server'
import { fetchServerStats } from '@/lib/api-server'
import { getSupabaseAdminClient, isSupabaseAdminConfigured } from '@/lib/supabase-admin'
import { UnavailableAdminPanel } from '@/components/unavailable-admin-panel'
import { hasMinRole, requireManager } from '@/lib/admin-guard'
import { LicenseIssuerButton } from '@/components/license-issuer-button'
import Link from 'next/link'
@ -19,7 +20,6 @@ interface SubRow {
cancel_at: string | null
renewal_failures: number
profile_name: string | null
mrrAmount: number
}
interface PageProps {
@ -27,57 +27,68 @@ interface PageProps {
}
export default async function AdminSubscriptionsPage({ searchParams }: PageProps): Promise<React.ReactElement> {
if (!isSupabaseAdminConfigured()) {
return (
<UnavailableAdminPanel
title="Subscription Management"
capability="Plans, billing, payment history"
reason="SUPABASE_URL / SUPABASE_SERVICE_ROLE_KEY 환경변수가 설정되지 않아 Supabase 관리 데이터에 연결할 수 없습니다. 환경변수를 설정하면 실데이터가 표시됩니다."
/>
)
}
const params = await searchParams
const statusFilter = params.status ?? 'all'
const supabase = await getSupabaseServerClient()
const serverStats = await fetchServerStats()
if (!['all', 'active', 'canceled', 'past_due', 'expired'].includes(statusFilter)) {
throw new Error('Invalid subscription status filter')
}
const admin = await requireManager()
const supabase = await getSupabaseAdminClient()
const subQuery = supabase
.from('subscriptions')
.select('id, user_id, tier, status, payment_provider, current_period_end, cancel_at')
.order('current_period_end', { ascending: true })
.limit(100)
if (statusFilter !== 'all') subQuery.eq('status', statusFilter)
const { data: rawSubs } = await subQuery
const rawSubsArr = (rawSubs ?? []) as Array<Record<string, unknown>>
const rawSubsArr: Array<Record<string, unknown>> = []
for (let page = 0; page < 100; page += 1) {
let query = supabase
.from('subscriptions')
.select('id, user_id, tier, status, payment_provider, current_period_end, cancel_at, renewal_failures')
.order('current_period_end', { ascending: true })
.range(page * 500, page * 500 + 499)
if (statusFilter !== 'all') query = query.eq('status', statusFilter)
const { data, error } = await query
if (error) throw new Error('Supabase subscriptions failed')
rawSubsArr.push(...((data ?? []) as Array<Record<string, unknown>>))
if ((data?.length ?? 0) < 500) break
if (page === 99) throw new Error('Supabase subscription directory exceeds the supported administrative window')
}
let subs: SubRow[] = []
if (rawSubsArr.length > 0) {
const userIds = rawSubsArr.map((s) => s.user_id as string)
const { data: rawProfiles } = userIds.length > 0
? await supabase.from('profiles').select('id, name').in('id', userIds)
: { data: [] }
const profileChunks = await Promise.all(Array.from({ length: Math.ceil(userIds.length / 200) }, (_, index) =>
supabase.from('profiles').select('id, name').in('id', userIds.slice(index * 200, index * 200 + 200))))
if (profileChunks.some((result) => result.error)) throw new Error('Supabase subscription profiles failed')
const rawProfiles = profileChunks.flatMap((result) => result.data ?? [])
const profileMap = new Map(
((rawProfiles ?? []) as Array<Record<string, unknown>>).map((p) => [p.id as string, (p.name as string) ?? null])
)
subs = rawSubsArr.map((row) => ({
id: row.id as string,
user_id: row.user_id as string,
tier: (row.tier as string) ?? 'free',
status: (row.status as string) ?? 'active',
payment_provider: (row.payment_provider as string) ?? 'Stripe',
current_period_end: row.current_period_end as string | null,
cancel_at: row.cancel_at as string | null,
renewal_failures: (row.renewal_failures as number | undefined) ?? 0,
profile_name: profileMap.get(row.user_id as string) ?? null,
mrrAmount: row.tier === 'enterprise' ? 120 : row.tier === 'team' ? 25 : row.tier === 'pro_plus' ? 19.9 : row.tier === 'pro' ? 9.9 : 0,
}))
} else {
// Rich Mock Fallback Subscriptions
subs = [
{ id: 'sub_001', user_id: 'usr_d3ro_001', tier: 'enterprise', status: 'active', payment_provider: 'Stripe', current_period_end: '2027-01-15T00:00:00Z', cancel_at: null, renewal_failures: 0, profile_name: 'D3RO System Architect', mrrAmount: 120 },
{ id: 'sub_002', user_id: 'usr_d3ro_002', tier: 'team', status: 'active', payment_provider: 'Toss Payments', current_period_end: '2026-11-10T00:00:00Z', cancel_at: null, renewal_failures: 0, profile_name: 'Sarah Kim (Design Team)', mrrAmount: 75 },
{ id: 'sub_003', user_id: 'usr_d3ro_003', tier: 'pro_plus', status: 'active', payment_provider: 'Stripe', current_period_end: '2026-10-02T00:00:00Z', cancel_at: null, renewal_failures: 0, profile_name: 'Minho Park', mrrAmount: 19.9 },
{ id: 'sub_004', user_id: 'usr_d3ro_004', tier: 'pro', status: 'active', payment_provider: 'Payple', current_period_end: '2026-09-18T00:00:00Z', cancel_at: null, renewal_failures: 0, profile_name: 'Alex Chen', mrrAmount: 9.9 },
{ id: 'sub_005', user_id: 'usr_d3ro_005', tier: 'pro', status: 'active', payment_provider: 'Toss Payments', current_period_end: '2026-09-01T00:00:00Z', cancel_at: null, renewal_failures: 0, profile_name: 'Jisoo Lee', mrrAmount: 9.9 },
{ id: 'sub_006', user_id: 'usr_d3ro_006', tier: 'pro_plus', status: 'active', payment_provider: 'Stripe', current_period_end: '2026-12-20T00:00:00Z', cancel_at: null, renewal_failures: 0, profile_name: 'David Wilson', mrrAmount: 19.9 },
{ id: 'sub_007', user_id: 'usr_d3ro_007', tier: 'free', status: 'active', payment_provider: 'None', current_period_end: null, cancel_at: null, renewal_failures: 0, profile_name: 'Hyunjin Choi', mrrAmount: 0 },
{ id: 'sub_008', user_id: 'usr_d3ro_008', tier: 'free', status: 'active', payment_provider: 'None', current_period_end: null, cancel_at: null, renewal_failures: 0, profile_name: 'Elena Rostova', mrrAmount: 0 },
]
subs = rawSubsArr.map((row) => {
if (typeof row.id !== 'string' || typeof row.user_id !== 'string' ||
typeof row.tier !== 'string' || typeof row.status !== 'string' ||
typeof row.payment_provider !== 'string' || !Number.isInteger(row.renewal_failures)) {
throw new Error('Supabase subscription response contains an invalid row')
}
return {
id: row.id,
user_id: row.user_id,
tier: row.tier,
status: row.status,
payment_provider: row.payment_provider,
current_period_end: typeof row.current_period_end === 'string' ? row.current_period_end : null,
cancel_at: typeof row.cancel_at === 'string' ? row.cancel_at : null,
renewal_failures: row.renewal_failures as number,
profile_name: profileMap.get(row.user_id) ?? null,
}
})
}
const filteredSubs = statusFilter === 'all' ? subs : subs.filter((s) => s.status === statusFilter)
@ -114,16 +125,16 @@ export default async function AdminSubscriptionsPage({ searchParams }: PageProps
sx={{
fontFamily: FONT_SANS,
fontSize: '20px',
fontWeight: 700,
fontWeight: 500,
color: C.bright,
letterSpacing: '-0.02em',
m: 0,
}}
>
Subscriptions & ARR Analytics
Subscription Operations
</Typography>
<TactileBadge ledColor="purple" ledPulse tone="accent" mono>
${serverStats.arrUsd.toLocaleString()} ARR
{subs.length} RECORDS
</TactileBadge>
</Box>
<Typography
@ -135,7 +146,7 @@ export default async function AdminSubscriptionsPage({ searchParams }: PageProps
mt: 0.25,
}}
>
LEMONSQUEEZY SYNC • 3-TIER MONETIZATION • AUTO RENEWAL
Supabase subscriptions, payment providers, renewal state
</Typography>
</Box>
</Box>
@ -149,12 +160,14 @@ export default async function AdminSubscriptionsPage({ searchParams }: PageProps
</Link>
))}
<Box sx={{ height: 20, width: '1px', bgcolor: C.borderHl, mx: 0.5 }} />
<LicenseIssuerButton />
<Link href="/subscriptions/new" style={{ textDecoration: 'none' }}>
<Button variant="contained" size="small" sx={primaryButtonSx}>
+ Create Subscription
</Button>
</Link>
{hasMinRole(admin, 'super_admin') && <LicenseIssuerButton />}
{hasMinRole(admin, 'admin') && (
<Link href="/subscriptions/new" style={{ textDecoration: 'none' }}>
<Button variant="contained" size="small" sx={primaryButtonSx}>
+ Create Subscription
</Button>
</Link>
)}
</Box>
</Box>
@ -163,51 +176,51 @@ export default async function AdminSubscriptionsPage({ searchParams }: PageProps
<DoubleBezelCard interactive bezelPadding="5px" innerPadding="20px">
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 1.5 }}>
<Typography sx={{ fontFamily: FONT_SANS, fontSize: '11px', fontWeight: 600, color: C.dim, textTransform: 'uppercase' }}>
Monthly Recurring (MRR)
Total Subscription Records
</Typography>
<StatRing color="purple" size={38}>
<Typography sx={{ fontFamily: FONT_MONO, fontSize: '11px', fontWeight: 700 }}>$</Typography>
<Typography sx={{ fontFamily: FONT_MONO, fontSize: '11px', fontWeight: 500 }}>#</Typography>
</StatRing>
</Box>
<Typography sx={{ fontFamily: FONT_MONO, fontSize: '24px', fontWeight: 700, color: C.bright }}>
${serverStats.mrrUsd.toLocaleString()}
<Typography sx={{ fontFamily: FONT_MONO, fontSize: '24px', fontWeight: 500, color: C.bright }}>
{subs.length.toLocaleString()}
</Typography>
<Typography sx={{ fontFamily: FONT_SANS, fontSize: '11px', color: C.green400, mt: 0.5 }}>
↑ 18.4% vs last month
Persisted in Supabase
</Typography>
</DoubleBezelCard>
<DoubleBezelCard interactive bezelPadding="5px" innerPadding="20px">
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 1.5 }}>
<Typography sx={{ fontFamily: FONT_SANS, fontSize: '11px', fontWeight: 600, color: C.dim, textTransform: 'uppercase' }}>
Paid Subscribers (Pro/Pro+)
Active Subscriptions
</Typography>
<StatRing color="blue" size={38}>
<Typography sx={{ fontFamily: FONT_MONO, fontSize: '11px', fontWeight: 700 }}>VIP</Typography>
<Typography sx={{ fontFamily: FONT_MONO, fontSize: '11px', fontWeight: 500 }}>ON</Typography>
</StatRing>
</Box>
<Typography sx={{ fontFamily: FONT_MONO, fontSize: '24px', fontWeight: 700, color: C.bright }}>
{(serverStats.tierDistribution.pro + serverStats.tierDistribution.pro_plus).toLocaleString()} Paid
<Typography sx={{ fontFamily: FONT_MONO, fontSize: '24px', fontWeight: 500, color: C.bright }}>
{subs.filter((subscription) => subscription.status === 'active').length.toLocaleString()}
</Typography>
<Typography sx={{ fontFamily: FONT_SANS, fontSize: '11px', color: C.cyanLight, mt: 0.5 }}>
{serverStats.tierDistribution.pro_plus} Pro+ • {serverStats.tierDistribution.pro} Pro
Current status = active
</Typography>
</DoubleBezelCard>
<DoubleBezelCard interactive bezelPadding="5px" innerPadding="20px">
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 1.5 }}>
<Typography sx={{ fontFamily: FONT_SANS, fontSize: '11px', fontWeight: 600, color: C.dim, textTransform: 'uppercase' }}>
Renewal Success Rate
Renewal Failures
</Typography>
<StatRing color="green" size={38}>
<Typography sx={{ fontFamily: FONT_MONO, fontSize: '11px', fontWeight: 700 }}>%</Typography>
<Typography sx={{ fontFamily: FONT_MONO, fontSize: '11px', fontWeight: 500 }}>%</Typography>
</StatRing>
</Box>
<Typography sx={{ fontFamily: FONT_MONO, fontSize: '24px', fontWeight: 700, color: C.green400 }}>
99.4%
<Typography sx={{ fontFamily: FONT_MONO, fontSize: '24px', fontWeight: 500, color: C.green400 }}>
{subs.reduce((total, subscription) => total + subscription.renewal_failures, 0).toLocaleString()}
</Typography>
<Typography sx={{ fontFamily: FONT_SANS, fontSize: '11px', color: C.dim, mt: 0.5 }}>
0.6% Churn • Fast Retry System
Persisted retry failures
</Typography>
</DoubleBezelCard>
</Box>
@ -215,8 +228,8 @@ export default async function AdminSubscriptionsPage({ searchParams }: PageProps
{/* Subscription Table */}
<DoubleBezelCard bezelPadding="6px" innerPadding="24px">
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 2.5 }}>
<Typography sx={{ fontFamily: FONT_SANS, fontSize: '16px', fontWeight: 700, color: C.bright }}>
Active Subscription Contracts
<Typography sx={{ fontFamily: FONT_SANS, fontSize: '16px', fontWeight: 500, color: C.bright }}>
Subscription Contracts
</Typography>
<Typography sx={{ fontFamily: FONT_MONO, fontSize: '11px', color: C.dim }}>
SHOWING {filteredSubs.length} RECORDS
@ -230,7 +243,7 @@ export default async function AdminSubscriptionsPage({ searchParams }: PageProps
<Box component="th">SUBSCRIBER</Box>
<Box component="th">TIER</Box>
<Box component="th">STATUS</Box>
<Box component="th">MRR VALUE</Box>
<Box component="th">RENEWAL FAILURES</Box>
<Box component="th">PROVIDER</Box>
<Box component="th">EXPIRES / RENEWS</Box>
<Box component="th" sx={{ textAlign: 'right' }}>ACTION</Box>
@ -269,14 +282,14 @@ export default async function AdminSubscriptionsPage({ searchParams }: PageProps
{s.status.toUpperCase()}
</Box>
</Box>
<Box component="td" sx={{ fontFamily: FONT_MONO, fontSize: '13px', fontWeight: 700, color: C.bright }}>
${s.mrrAmount}/mo
<Box component="td" sx={{ fontFamily: FONT_MONO, fontSize: '13px', fontWeight: 500, color: C.bright }}>
{s.renewal_failures}
</Box>
<Box component="td" sx={{ fontFamily: FONT_MONO, fontSize: '11px', color: C.dim }}>
{s.payment_provider}
</Box>
<Box component="td" sx={{ fontFamily: FONT_MONO, fontSize: '11px', color: C.text }}>
{s.current_period_end ? new Date(s.current_period_end).toLocaleDateString() : 'Free Tier'}
{s.current_period_end ? new Date(s.current_period_end).toLocaleDateString() : 'Not set'}
</Box>
<Box component="td" sx={{ textAlign: 'right' }}>
<Link href={`/subscriptions/${s.user_id}`} style={{ textDecoration: 'none' }}>