+
+ Subscription
+
+
+ {subscription && (
+
+
+
+ {subscription.tier.toUpperCase()}
+
+
+ {subscription.status}
+
+
+
+
+ Current Plan: {PLANS.find((p) => p.tier === subscription.tier)?.name || subscription.tier}
+
+
+ {subscription.currentPeriodEnd && (
+
+ Next billing date: {format(new Date(subscription.currentPeriodEnd), 'MMM dd, yyyy')}
+
+ )}
+
+ {subscription.cancelAtPeriodEnd && (
+
+
+ Your subscription will be canceled at the end of the current billing period.
+
+
+ )}
+
+
+ {subscription.cancelAtPeriodEnd ? (
+
+ ) : subscription.tier !== 'free' ? (
+
+ ) : null}
+
+
+ )}
+
+
+
+
+ Available Plans
+
+
+
+
+
+
+
+
+
+ {PLANS.map((plan) => (
+ handleUpgradeClick(plan.tier)}
+ />
+ ))}
+
+
+
+
+
+ Billing History
+
+
+ {isLoadingInvoices ? (
+
+ ) : invoices.length === 0 ? (
+
+ No billing history available
+
+ ) : (
+
+ {invoices.map((invoice: { id: string; date: string; amount: number; status: string; pdfUrl?: string }) => (
+
+
+
+ {format(new Date(invoice.date), 'MMM dd, yyyy')}
+
+
+ ${(invoice.amount / 100).toFixed(2)}
+
+
+
+
+ {invoice.status}
+
+ {invoice.pdfUrl && (
+
+ ↓
+
+ )}
+
+
+ ))}
+
+ )}
+
+
+
+