All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 12s
- Sidebar: dynamic brand-accent colors, brainstorm section restyled - AI chat general: popup panel with expand/collapse, hides when contextual AI open - AI chat contextual: tabs reordered (Actions first), X close button, height fix - Settings: all tabs restyled, 6 new color presets (sage, terracotta, iron, etc.) - Global color cleanup: emerald/orange hardcoded → brand-accent dynamic - Brainstorm page: orange → brand-accent throughout - PageEntry animation component added to key pages - Floating AI button: bg-brand-accent instead of hardcoded black - i18n: all 15 locales updated with new AI/billing keys - Billing: freemium quota tracking, BYOK, stripe subscription scaffolding - Admin: integrated into new design - AGENTS.md + CLAUDE.md project rules added
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
'use client';
|
|
|
|
import { ExternalLink, Receipt } from 'lucide-react';
|
|
import { useState } from 'react';
|
|
import { Loader2 } from 'lucide-react';
|
|
import { useLanguage } from '@/lib/i18n';
|
|
|
|
export function BillingHistory() {
|
|
const { t } = useLanguage();
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
const handleOpenPortal = async () => {
|
|
setLoading(true);
|
|
try {
|
|
const res = await fetch('/api/billing/portal', { method: 'POST' });
|
|
const data = await res.json();
|
|
if (!res.ok) throw new Error(data.error ?? 'Failed');
|
|
window.location.href = data.url;
|
|
} catch {
|
|
// ignore — portal not configured
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<div className="rounded-xl border border-border/40 bg-paper p-6 space-y-4">
|
|
<div className="flex items-center gap-2">
|
|
<Receipt className="h-4 w-4 text-muted-foreground" />
|
|
<h3 className="text-sm font-semibold text-foreground">{t('billing.billingHistory')}</h3>
|
|
</div>
|
|
<p className="text-xs text-muted-foreground">{t('billing.noUsage')}</p>
|
|
<button
|
|
type="button"
|
|
onClick={handleOpenPortal}
|
|
disabled={loading}
|
|
className="flex items-center gap-2 text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-60"
|
|
>
|
|
{loading ? (
|
|
<Loader2 className="h-3.5 w-3.5 animate-spin" />
|
|
) : (
|
|
<ExternalLink className="h-3.5 w-3.5" />
|
|
)}
|
|
{t('billing.viewInvoices')}
|
|
</button>
|
|
</div>
|
|
);
|
|
}
|