diff --git a/frontend/src/components/billing/BillingRecentTransactions.tsx b/frontend/src/components/billing/BillingRecentTransactions.tsx index aac7d6f3..6c03b881 100644 --- a/frontend/src/components/billing/BillingRecentTransactions.tsx +++ b/frontend/src/components/billing/BillingRecentTransactions.tsx @@ -4,7 +4,9 @@ import Badge from '../../components/ui/badge/Badge'; import { useToast } from '../../components/ui/toast/ToastContainer'; import { getCreditTransactions, type CreditTransaction } from '../../services/billing.api'; -export default function BillingRecentTransactions({ limit = 10 }: { limit?: number }) { +type Variant = 'card' | 'plain'; + +export default function BillingRecentTransactions({ limit = 10, variant = 'card' }: { limit?: number; variant?: Variant }) { const toast = useToast(); const [transactions, setTransactions] = useState([]); const [loading, setLoading] = useState(true); @@ -41,6 +43,44 @@ export default function BillingRecentTransactions({ limit = 10 }: { limit?: numb return type.split('_').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' '); }; + const content = ( +
+ {transactions.slice(0, limit).map((transaction) => ( +
+
+
+ + {formatOperationType(transaction.transaction_type)} + + + {transaction.description} + +
+
+ {new Date(transaction.created_at).toLocaleString()} + {transaction.reference_id && ` • Ref: ${transaction.reference_id}`} +
+
+
+
0 ? 'text-green-600' : 'text-red-600'}`}> + {transaction.amount > 0 ? '+' : ''}{transaction.amount} +
+
+
+ ))} + {transactions.length === 0 && ( +
No transactions yet
+ )} +
+ ); + + if (variant === 'plain') { + if (loading) { + return
Loading...
; + } + return content; + } + if (loading) { return ( @@ -49,36 +89,5 @@ export default function BillingRecentTransactions({ limit = 10 }: { limit?: numb ); } - return ( - -
- {transactions.slice(0, limit).map((transaction) => ( -
-
-
- - {formatOperationType(transaction.transaction_type)} - - - {transaction.description} - -
-
- {new Date(transaction.created_at).toLocaleString()} - {transaction.reference_id && ` • Ref: ${transaction.reference_id}`} -
-
-
-
0 ? 'text-green-600' : 'text-red-600'}`}> - {transaction.amount > 0 ? '+' : ''}{transaction.amount} -
-
-
- ))} - {transactions.length === 0 && ( -
No transactions yet
- )} -
-
- ); + return {content}; } diff --git a/frontend/src/pages/account/AccountBillingPage.tsx b/frontend/src/pages/account/AccountBillingPage.tsx index 233050a4..55341488 100644 --- a/frontend/src/pages/account/AccountBillingPage.tsx +++ b/frontend/src/pages/account/AccountBillingPage.tsx @@ -47,6 +47,43 @@ export default function AccountBillingPage() { const [loading, setLoading] = useState(true); const [error, setError] = useState(''); + const planCatalog: PricingPlan[] = [ + { + id: 1, + name: 'Starter', + price: 89, + period: '/month', + description: 'Good for small teams getting started', + features: ['1,000 credits included', '1 site', '2 users'], + }, + { + id: 2, + name: 'Growth', + price: 139, + period: '/month', + description: 'For growing teams that need more volume', + features: ['2,000 credits included', '3 sites', '3 users'], + highlighted: true, + }, + { + id: 3, + name: 'Scale', + price: 229, + period: '/month', + description: 'Larger teams with higher usage', + features: ['4,000 credits included', '5 sites', '5 users'], + }, + { + id: 4, + name: 'Enterprise', + price: 0, + period: '/custom', + description: 'Custom limits, SSO, and dedicated support', + features: ['10,000+ credits', '20 sites', '10,000 users'], + buttonText: 'Talk to us', + }, + ]; + useEffect(() => { loadData(); }, []); @@ -126,15 +163,15 @@ export default function AccountBillingPage() { } return ( -
-
+
+

Plans & Billing

Manage your subscription, credits, and billing

@@ -242,7 +279,7 @@ export default function AccountBillingPage() {

Quick Actions

Purchase Credits @@ -285,7 +322,7 @@ export default function AccountBillingPage() { View usage details
- +
)} @@ -293,79 +330,76 @@ export default function AccountBillingPage() { {/* Plans Tab */} {activeTab === 'plans' && (
-
- -
-
-

Choose a plan

-

Pick the package that fits your team.

-
- + +
+
+

Active plan

+

Your current subscription allocation

- {creditPackages.length === 0 ? ( -
- - No packages available yet. Please check back soon. +
+
Monthly allocation
+
+ {creditBalance?.plan_credits_per_month?.toLocaleString() || '—'}
- ) : ( - { - const plan: PricingPlan = { - id: pkg.id, - name: pkg.name, - price: Number(pkg.price), - period: '/one-time', - description: pkg.description, - features: [ - `${pkg.credits.toLocaleString()} credits`, - pkg.discount_percentage > 0 ? `${pkg.discount_percentage}% discount applied` : 'Standard pricing', - 'Manual & online payments supported', - ], - highlighted: pkg.is_featured, - buttonText: 'Select', - }; - return plan; - })} - onPlanSelect={() => navigate('/account/credits/purchase')} - /> - )} - +
+ Remaining: {creditBalance?.credits_remaining?.toLocaleString() ?? '—'} credits +
+
+
+ - -

Current plan

-
-
-
Plan
-
- {creditBalance?.plan_credits_per_month ? 'Active Plan' : 'Pay as you go'} -
-
-
-
Monthly allocation
-
- {creditBalance?.plan_credits_per_month?.toLocaleString() || '—'} -
-
+ +
+
+

Available plans

+

Choose the plan that fits your team (excluding free).

-
- Remaining this month:{' '} - - {creditBalance?.credits_remaining?.toLocaleString() ?? '—'} credits - +
+ plan.name !== 'Free')} + onPlanSelect={() => {}} + /> + + + +
+
+

Credit add-ons

+

One-time credit bundles to top up your balance.

-
- - Buy more credits - +
+ {creditPackages.length === 0 ? ( +
+ + No packages available yet. Please check back soon.
- -
+ ) : ( + { + const plan: PricingPlan = { + id: pkg.id, + name: pkg.name, + price: Number(pkg.price), + period: '/one-time', + description: pkg.description, + features: [ + `${pkg.credits.toLocaleString()} credits`, + pkg.discount_percentage > 0 ? `${pkg.discount_percentage}% discount applied` : 'Standard pricing', + 'Manual & online payments supported', + ], + highlighted: pkg.is_featured, + buttonText: 'Select', + }; + return plan; + })} + onPlanSelect={() => navigate('/account/purchase-credits')} + /> + )} +
)} @@ -508,7 +542,7 @@ export default function AccountBillingPage() {

Use these options when purchasing credits.

Go to purchase