Skip to content

Commit c69d6b3

Browse files
fix(billing): redirect to billing page after manual payment submission and improve status UX
- After submitting a bank transfer request, "Back to Billing" now navigates to /dashboard/admin/billing instead of resetting to the plan table, so users can immediately see their pending request in the queue - Add try/catch + toast.error to handleManualSubmit so errors (e.g. duplicate pending request) are surfaced instead of swallowed silently - Replace cryptic status badges with human-readable labels and per-status hint text explaining what happens next (awaiting review / instructions sent / payment received) - Add clock icon and queue explanation to the pending requests card header Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7863e86 commit c69d6b3

2 files changed

Lines changed: 38 additions & 9 deletions

File tree

app/[locale]/dashboard/admin/billing/billing-dashboard-client.tsx

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/com
88
import { Badge } from '@/components/ui/badge'
99
import { Button } from '@/components/ui/button'
1010
import { ProofUpload } from '@/components/shared/proof-upload'
11-
import { IconExternalLink, IconRefresh, IconCreditCard, IconPhoto } from '@tabler/icons-react'
11+
import { IconExternalLink, IconRefresh, IconCreditCard, IconPhoto, IconClock } from '@tabler/icons-react'
1212
import { uploadPaymentProof, requestManualRenewal } from '@/app/actions/admin/billing'
1313

1414
interface BillingDashboardClientProps {
@@ -176,8 +176,13 @@ export function BillingDashboardClient({ status, paymentRequests }: BillingDashb
176176
{pendingRequests.length > 0 && (
177177
<Card>
178178
<CardHeader>
179-
<CardTitle>Pending Upgrade Requests</CardTitle>
180-
<CardDescription>Bank transfer requests awaiting confirmation</CardDescription>
179+
<CardTitle className="flex items-center gap-2">
180+
<IconClock className="h-5 w-5" />
181+
Pending Payment Requests
182+
</CardTitle>
183+
<CardDescription>
184+
Your bank transfer request{pendingRequests.length > 1 ? 's are' : ' is'} in the queue — our team will review and activate your plan once payment is confirmed.
185+
</CardDescription>
181186
</CardHeader>
182187
<CardContent>
183188
<div className="space-y-3">
@@ -192,8 +197,7 @@ export function BillingDashboardClient({ status, paymentRequests }: BillingDashb
192197
{req.platform_plans?.name || 'Unknown Plan'}
193198
</p>
194199
<p className="text-sm text-muted-foreground">
195-
${req.amount}/{req.interval === 'yearly' ? 'year' : 'month'} &middot;{' '}
196-
{new Date(req.created_at).toLocaleDateString()}
200+
${req.amount}/{req.interval === 'yearly' ? 'year' : 'month'} &middot; Submitted {new Date(req.created_at).toLocaleDateString()}
197201
</p>
198202
</div>
199203
<div className="flex items-center gap-2">
@@ -213,16 +217,26 @@ export function BillingDashboardClient({ status, paymentRequests }: BillingDashb
213217
: req.status === 'instructions_sent' ? 'outline'
214218
: 'default'
215219
}>
216-
{req.status.replace(/_/g, ' ')}
220+
{req.status === 'pending' && 'Awaiting review'}
221+
{req.status === 'instructions_sent' && 'Instructions sent'}
222+
{req.status === 'payment_received' && 'Payment received'}
223+
{!['pending', 'instructions_sent', 'payment_received'].includes(req.status) && req.status.replace(/_/g, ' ')}
217224
</Badge>
218225
</div>
219226
</div>
220227

228+
{/* Status hint */}
229+
<p className="text-xs text-muted-foreground">
230+
{req.status === 'pending' && 'We\'ll send bank transfer instructions to your billing email shortly.'}
231+
{req.status === 'instructions_sent' && 'Check your email for bank transfer instructions. Once you\'ve transferred, upload proof below.'}
232+
{req.status === 'payment_received' && 'We\'ve received your payment and are confirming it. Your plan will be activated soon.'}
233+
</p>
234+
221235
{/* Proof upload for requests without proof */}
222236
{!req.proof_url && (
223237
<ProofUpload
224238
onUpload={(file) => handleProofUpload(req.request_id, file)}
225-
label="Upload payment proof"
239+
label="Upload payment proof (optional — speeds up activation)"
226240
disabled={uploadingFor === req.request_id}
227241
/>
228242
)}

app/[locale]/dashboard/admin/billing/upgrade/upgrade-page-client.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { PlanComparisonTable } from '@/components/admin/plan-comparison-table'
77
import { ManualTransferForm } from '@/components/admin/manual-transfer-form'
88
import { requestManualPlanUpgrade } from '@/app/actions/admin/billing'
99
import { useTranslations } from 'next-intl'
10+
import { useLocale } from 'next-intl'
1011

1112
interface UpgradePageClientProps {
1213
plans: Array<{
@@ -25,8 +26,10 @@ interface UpgradePageClientProps {
2526

2627
export function UpgradePageClient({ plans, currentPlan }: UpgradePageClientProps) {
2728
const router = useRouter()
29+
const locale = useLocale()
2830
const t = useTranslations('dashboard.admin.billing.upgrade')
2931
const [loading, setLoading] = useState(false)
32+
const [manualSubmitted, setManualSubmitted] = useState(false)
3033
const [manualTransfer, setManualTransfer] = useState<{
3134
planId: string
3235
planName: string
@@ -70,7 +73,13 @@ export function UpgradePageClient({ plans, currentPlan }: UpgradePageClientProps
7073

7174
const handleManualSubmit = async (bankReference: string, notes: string) => {
7275
if (!manualTransfer) return
73-
await requestManualPlanUpgrade(manualTransfer.planId, manualTransfer.interval, bankReference, notes)
76+
try {
77+
await requestManualPlanUpgrade(manualTransfer.planId, manualTransfer.interval, bankReference, notes)
78+
setManualSubmitted(true)
79+
} catch (e: any) {
80+
toast.error(e.message || t('submitError'))
81+
throw e
82+
}
7483
}
7584

7685
if (manualTransfer) {
@@ -80,7 +89,13 @@ export function UpgradePageClient({ plans, currentPlan }: UpgradePageClientProps
8089
amount={manualTransfer.amount}
8190
interval={manualTransfer.interval}
8291
onSubmit={handleManualSubmit}
83-
onCancel={() => setManualTransfer(null)}
92+
onCancel={() => {
93+
if (manualSubmitted) {
94+
router.push(`/${locale}/dashboard/admin/billing`)
95+
} else {
96+
setManualTransfer(null)
97+
}
98+
}}
8499
/>
85100
)
86101
}

0 commit comments

Comments
 (0)