import { useState, useEffect } from 'react'; import { Link } from 'react-router-dom'; import PageMeta from '../../components/common/PageMeta'; import { useToast } from '../../components/ui/toast/ToastContainer'; import { getCreditBalance, CreditBalance } from '../../services/billing.api'; import { Card } from '../../components/ui/card'; import Badge from '../../components/ui/badge/Badge'; import Button from '../../components/ui/button/Button'; import { ArrowUpIcon } from '../../icons'; import { usePageLoading } from '../../context/PageLoadingContext'; export default function Credits() { const toast = useToast(); const { startLoading, stopLoading } = usePageLoading(); const [balance, setBalance] = useState(null); useEffect(() => { loadBalance(); }, []); const loadBalance = async () => { try { startLoading('Loading content usage...'); const data = await getCreditBalance(); setBalance(data); } catch (error: any) { toast.error(`Failed to load content usage: ${error.message}`); } finally { stopLoading(); } }; return ( <>

Content Usage

Track your monthly content allowance

{balance && (

Content Remaining

{(balance?.credits ?? 0).toLocaleString()}

Pieces available this month

Current Plan

{(balance as any)?.subscription_plan || 'None'}

{(balance?.plan_credits_per_month ?? 0) ? `${(balance?.plan_credits_per_month ?? 0).toLocaleString()} content pieces/month` : 'No subscription'}

Status

{(balance as any)?.subscription_status || 'No subscription'}

Subscription status

)} {/* What's Included */}

What's Included Per Content Piece

Every content piece you create includes all of these features

{[ { name: 'AI Keyword Clustering', desc: 'Smart keyword grouping' }, { name: 'AI Content Ideas', desc: 'Topic suggestions from keywords' }, { name: 'AI Content Writing', desc: '1000-2000 word articles' }, { name: 'AI Images', desc: '1 featured + 2 in-article images' }, { name: 'Internal Linking', desc: 'Smart link suggestions' }, { name: 'SEO Optimization', desc: 'Meta tags & readability' }, { name: 'Publishing to your sites', desc: 'Direct publish to your site' }, { name: 'Multiple Formats', desc: 'Pages, articles, product content' }, ].map((feature) => (
{feature.name}
{feature.desc}
))}
); }