Files
karaoke-gen/frontend/app/[locale]/payment/success/page.tsx
T
Andrew Beveridge ☄️andClaude Opus 4.6 8c1dfe5460 feat(i18n): Phase 3 frontend — next-intl infrastructure + 1062 strings (en/es/de) (#656)
@coderabbitai ignore

## Summary
- Phase 3 of the i18n multilingual initiative — makes the karaoke-gen
frontend fully multilingual (English, Spanish, German)
- Installs `next-intl` with `[locale]` path-based routing,
LanguageSwitcher, and `Accept-Language` API header
- Extracts **1,062 strings** from ~70 components into `messages/en.json`
across 31 namespaces
- Wires `useTranslations()` into all user-facing components (landing,
dashboard, auth, job flow, lyrics review, instrumental review, audio
editor, etc.)
- Admin pages (`/admin/*`) stay outside locale routing — intentionally
excluded from i18n scope
- Static export generates `/en/`, `/es/`, `/de/` directories (45 total
pages) for Cloudflare Pages
- `es.json`/`de.json` are English placeholders — translation via Gemini
pipeline pending
- Translation pipeline (`scripts/translate.py`) and glossary (55
karaoke-specific terms) included

## Key architecture decisions
- Root layout keeps ThemeProvider/TenantProvider (needed by admin pages
outside `[locale]`)
- Only NextIntlClientProvider added to `[locale]/layout.tsx`
- `job-status.ts` labels converted to translation keys; consumers
translate via `useTranslations('jobStatus')`
- Jest mock loads actual `en.json` so existing tests validate i18n
wiring without assertion changes

## Test plan
- [x] All 707 frontend tests pass (39 suites)
- [x] Static build generates all 45 pages across 3 locales
- [x] Admin pages render at `/admin/` without locale prefix
- [x] CodeRabbit review: 4 issues fixed, 7 pre-existing noted
- [ ] Post-deploy: verify `/en/` landing page renders correctly
- [ ] Post-deploy: verify LanguageSwitcher redirects to `/es/` and
`/de/`
- [ ] Post-deploy: verify `/admin/` still works without locale context

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 21:50:53 -04:00

91 lines
2.7 KiB
TypeScript

"use client"
import { Suspense, useEffect, useState } from "react"
import { useRouter, useSearchParams } from "next/navigation"
import { CheckCircle, Loader2, Coins } from "lucide-react"
import { Button } from "@/components/ui/button"
import { useAuth } from "@/lib/auth"
import { useTranslations } from "next-intl"
function PaymentSuccessContent() {
const t = useTranslations('payment')
const router = useRouter()
const searchParams = useSearchParams()
const [isLoading, setIsLoading] = useState(true)
const { user, fetchUser } = useAuth()
useEffect(() => {
// Refresh user data to get updated credits
const refreshUser = async () => {
await fetchUser()
setIsLoading(false)
}
refreshUser()
}, [fetchUser])
const sessionId = searchParams.get("session_id")
return (
<div className="max-w-md w-full bg-card border border-border rounded-xl p-8 text-center">
<CheckCircle className="w-16 h-16 text-success mx-auto mb-4" />
<h1 className="text-2xl font-bold text-foreground mb-2">
{t('title')}
</h1>
<p className="text-muted-foreground mb-6">
{t('description')}
</p>
{isLoading ? (
<div className="flex items-center justify-center gap-2 text-muted-foreground mb-6">
<Loader2 className="w-4 h-4 animate-spin" />
{t('loadingBalance')}
</div>
) : user ? (
<div className="bg-secondary rounded-lg p-4 mb-6">
<div className="flex items-center justify-center gap-2 text-warning">
<Coins className="w-5 h-5" />
<span className="text-2xl font-bold">{user.credits}</span>
<span className="text-muted-foreground">{t('creditsAvailable')}</span>
</div>
</div>
) : null}
<div className="space-y-3">
<Button
onClick={() => router.push("/app")}
className="w-full bg-primary hover:bg-primary/90"
>
{t('startCreating')}
</Button>
<p className="text-xs text-muted-foreground">
{t('confirmationEmail')}
</p>
</div>
</div>
)
}
function PaymentLoadingFallback() {
const tCommon = useTranslations('common')
return (
<div className="max-w-md w-full bg-card border border-border rounded-xl p-8 text-center">
<Loader2 className="w-16 h-16 text-primary mx-auto mb-4 animate-spin" />
<p className="text-muted-foreground">{tCommon('loading')}</p>
</div>
)
}
export default function PaymentSuccessPage() {
return (
<div className="min-h-screen bg-background flex items-center justify-center p-4">
<Suspense fallback={<PaymentLoadingFallback />}>
<PaymentSuccessContent />
</Suspense>
</div>
)
}