Skip to content

Enhance payment successful page #3131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 19, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 92 additions & 41 deletions apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import {
ArrowLeft,
CheckCircle,
Clock,

Check warning on line 6 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L6

Added line #L6 was not covered by tests
CreditCard,
Download,
} from '@tuturuuu/ui/icons';
import { format } from 'date-fns';
import { addHours, format, isAfter } from 'date-fns';

Check warning on line 10 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L10

Added line #L10 was not covered by tests
import Link from 'next/link';

const fetchWorkspaceSubscription = async (
Expand All @@ -17,7 +18,7 @@

const { data: subscription, error } = await supabase
.from('workspace_subscription')
.select('*')
.select('*, workspace_subscription_products(price)')

Check warning on line 21 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L21

Added line #L21 was not covered by tests
.eq('ws_id', wsId)
.single();

Expand All @@ -41,15 +42,20 @@
}) {
const { wsId } = await params;

// Fetch the workspace subscription data
const subscription = await fetchWorkspaceSubscription(wsId);

// Create paymentDetails from the subscription data, or use defaults if not found
// Calculate link expiration
const createdAt = subscription?.created_at
? new Date(subscription.created_at)
: new Date();
const expiresAt = addHours(createdAt, 24);
const isLinkExpired = isAfter(new Date(), expiresAt);

Check warning on line 53 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L47-L53

Added lines #L47 - L53 were not covered by tests
const paymentDetails = subscription
? {
planName: subscription.plan_name || 'Pro Plan',
amount: subscription.price
? `$${(subscription.price / 100).toFixed(2)}`
amount: subscription.workspace_subscription_products.price
? `$${subscription.workspace_subscription_products.price.toFixed(2)}`

Check warning on line 58 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L57-L58

Added lines #L57 - L58 were not covered by tests
: '--',
invoiceId: subscription.id || 'N/A',
date: subscription.created_at
Expand All @@ -66,78 +72,99 @@
};

return (
<div className="container mx-auto max-w-6xl px-4 py-8">
{/* Header */}
<div className="mb-8 text-center">
<div className="mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-green-100 dark:bg-green-900/30">
<div className="container mx-auto max-w-6xl px-4 py-8 duration-700 animate-in fade-in">
<div className="mb-8 text-center delay-100 duration-1000 animate-in fade-in">
<div className="mx-auto mb-4 flex h-16 w-16 animate-pulse items-center justify-center rounded-full bg-green-100 delay-200 dark:bg-green-900/30">

Check warning on line 77 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L75-L77

Added lines #L75 - L77 were not covered by tests
<CheckCircle className="h-8 w-8 text-green-600 dark:text-green-400" />
</div>
<h1 className="mb-2 text-3xl font-bold tracking-tight">
<h1 className="mb-2 text-3xl font-bold tracking-tight delay-300 duration-600 animate-in slide-in-from-bottom-4">

Check warning on line 80 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L80

Added line #L80 was not covered by tests
Payment Successful!
</h1>
<p className="text-muted-foreground">
<p className="text-muted-foreground delay-500 duration-600 animate-in slide-in-from-bottom-4">

Check warning on line 83 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L83

Added line #L83 was not covered by tests
Thank you for your subscription. Your payment has been processed
successfully.
</p>
</div>

{/* Payment Summary Card */}
<div className="mb-8 rounded-lg border border-border bg-card p-8 shadow-sm dark:bg-card/80">
<div className="mb-8 rounded-lg border border-border bg-card p-8 shadow-sm transition-all delay-700 duration-700 animate-in slide-in-from-bottom-6 hover:scale-[1.02] hover:shadow-lg dark:bg-card/80">

Check warning on line 90 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L90

Added line #L90 was not covered by tests
<h2 className="mb-6 text-2xl font-semibold text-card-foreground">
Payment Summary
</h2>
<div className="grid gap-6 md:grid-cols-2">
<div className="space-y-4">
<div className="flex justify-between">
<div className="-m-2 flex justify-between rounded p-2 transition-all duration-200 hover:scale-105 hover:bg-muted/30">

Check warning on line 96 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L96

Added line #L96 was not covered by tests
<span className="text-muted-foreground">Plan:</span>
<span className="font-medium text-card-foreground">
{paymentDetails.planName}
</span>
</div>
<div className="flex justify-between">
<div className="-m-2 flex justify-between rounded p-2 transition-all duration-200 hover:scale-105 hover:bg-muted/30">

Check warning on line 102 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L102

Added line #L102 was not covered by tests
<span className="text-muted-foreground">Amount:</span>
<span className="font-medium text-card-foreground">
{paymentDetails.amount}
</span>
</div>
<div className="flex justify-between">
<div className="-m-2 flex justify-between rounded p-2 transition-all duration-200 hover:scale-105 hover:bg-muted/30">

Check warning on line 108 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L108

Added line #L108 was not covered by tests
<span className="text-muted-foreground">Invoice ID:</span>
<span className="font-medium text-card-foreground">
{paymentDetails.invoiceId}
</span>
</div>
</div>
<div className="space-y-4">
<div className="flex justify-between">
<div className="-m-2 flex justify-between rounded p-2 transition-all duration-200 hover:scale-105 hover:bg-muted/30">

Check warning on line 116 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L116

Added line #L116 was not covered by tests
<span className="text-muted-foreground">Date:</span>
<span className="font-medium text-card-foreground">
{paymentDetails.date}
</span>
</div>
<div className="flex justify-between">
<div className="-m-2 flex justify-between rounded p-2 transition-all duration-200 hover:scale-105 hover:bg-muted/30">

Check warning on line 122 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L122

Added line #L122 was not covered by tests
<span className="text-muted-foreground">Payment Method:</span>
<span className="font-medium text-card-foreground">
{paymentDetails.paymentMethod}
</span>
</div>
<div className="flex justify-between">
<div className="-m-2 flex justify-between rounded p-2 transition-all duration-200 hover:bg-muted/30">

Check warning on line 128 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L128

Added line #L128 was not covered by tests
<span className="text-muted-foreground">Status:</span>
<span className="inline-flex rounded-full bg-green-100 px-2 text-xs leading-5 font-semibold text-green-800 dark:bg-green-900/30 dark:text-green-400">
<span className="rounded-full bg-green-100 px-2 text-xs leading-5 font-semibold text-green-800 hover:scale-110 dark:bg-green-900/30 dark:text-green-400">

Check warning on line 130 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L130

Added line #L130 was not covered by tests
Paid
</span>
</div>
</div>
</div>
</div>

{/* Download Link Expiration Notice */}
<div className="mb-8 rounded-lg border border-amber-200 bg-amber-50 p-6 text-center transition-all delay-900 duration-300 animate-in fade-in dark:border-amber-800 dark:bg-amber-900/20">
<div className="mb-2 flex items-center justify-center gap-2">
<Clock className="h-5 w-5 text-amber-600 dark:text-amber-400" />
<p className="font-medium text-amber-800 dark:text-amber-200">
Download Receipt Availability
</p>
</div>
{isLinkExpired ? (
<p className="text-sm text-amber-700 dark:text-amber-300">
The download link has expired (24 hours after payment). Please
contact support for a new receipt.
</p>
) : (
<p className="text-sm text-amber-700 dark:text-amber-300">
Download link expires on{' '}
{format(expiresAt, "MMMM d, yyyy 'at' h:mm a")} (24 hours after
payment)
</p>
)}
</div>

Check warning on line 159 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L138-L159

Added lines #L138 - L159 were not covered by tests
{/* What's Next Card */}
<div className="mb-8 rounded-lg border border-border bg-card p-8 shadow-sm dark:bg-card/80">
<div className="mb-8 rounded-lg border border-border bg-card p-8 shadow-sm transition-all delay-1000 duration-300 duration-700 animate-in slide-in-from-bottom-6 hover:scale-[1.02] hover:shadow-lg dark:bg-card/80">

Check warning on line 161 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L161

Added line #L161 was not covered by tests
<h2 className="mb-6 text-2xl font-semibold text-card-foreground">
What's Next?
</h2>
<div className="space-y-4">
<div className="flex items-start gap-3">
<CheckCircle className="mt-0.5 h-5 w-5 text-green-600 dark:text-green-400" />
<div className="-m-3 flex items-start gap-3 rounded-lg p-3 transition-all delay-1200 duration-300 duration-500 animate-in slide-in-from-left-4 hover:translate-x-2 hover:bg-muted/30">
<CheckCircle className="mt-0.5 h-5 w-5 text-green-600 transition-transform duration-300 hover:scale-125 hover:rotate-12 dark:text-green-400" />

Check warning on line 167 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L166-L167

Added lines #L166 - L167 were not covered by tests
<div>
<p className="font-medium text-card-foreground">
Your subscription is now active
Expand All @@ -147,8 +174,8 @@
</p>
</div>
</div>
<div className="flex items-start gap-3">
<CheckCircle className="mt-0.5 h-5 w-5 text-green-600 dark:text-green-400" />
<div className="-m-3 flex items-start gap-3 rounded-lg p-3 transition-all delay-1400 duration-300 duration-500 animate-in slide-in-from-left-4 hover:translate-x-2 hover:bg-muted/30">
<CheckCircle className="mt-0.5 h-5 w-5 text-green-600 transition-transform duration-300 hover:scale-125 hover:rotate-12 dark:text-green-400" />

Check warning on line 178 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L177-L178

Added lines #L177 - L178 were not covered by tests
<div>
<p className="font-medium text-card-foreground">
Confirmation email sent
Expand All @@ -158,8 +185,8 @@
</p>
</div>
</div>
<div className="flex items-start gap-3">
<CheckCircle className="mt-0.5 h-5 w-5 text-green-600 dark:text-green-400" />
<div className="-m-3 flex items-start gap-3 rounded-lg p-3 transition-all delay-1600 duration-300 duration-500 animate-in slide-in-from-left-4 hover:translate-x-2 hover:bg-muted/30">
<CheckCircle className="mt-0.5 h-5 w-5 text-green-600 transition-transform duration-300 hover:scale-125 hover:rotate-12 dark:text-green-400" />

Check warning on line 189 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L188-L189

Added lines #L188 - L189 were not covered by tests
<div>
<p className="font-medium text-card-foreground">
Billing cycle started
Expand All @@ -173,39 +200,63 @@
</div>

{/* Action Buttons */}
<div className="flex flex-col gap-4 sm:flex-row sm:justify-center">
<Button asChild className="flex items-center gap-2">
<div className="flex flex-col gap-4 delay-1800 duration-600 animate-in slide-in-from-bottom-4 sm:flex-row sm:justify-center">
<Button
asChild
className="group flex items-center gap-2 transition-all duration-300 hover:-translate-y-1 hover:scale-110 hover:shadow-xl"
>

Check warning on line 207 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L203-L207

Added lines #L203 - L207 were not covered by tests
<Link href={`/${wsId}/billing`}>
<ArrowLeft className="h-4 w-4" />
<ArrowLeft className="h-4 w-4 transition-transform duration-300 group-hover:-translate-x-2" />

Check warning on line 209 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L209

Added line #L209 was not covered by tests
Back to Billing
</Link>
</Button>
<Button variant="outline" className="flex items-center gap-2">
<Download className="h-4 w-4" />
Download Receipt
</Button>
<Button variant="outline" asChild className="flex items-center gap-2">
{isLinkExpired ? (
<Button
variant="outline"
disabled
className="group flex cursor-not-allowed items-center gap-2 opacity-50"
>
<Download className="h-4 w-4" />
Download Receipt (Expired)
</Button>
) : (
<Button
variant="outline"
asChild
className="group flex items-center gap-2 transition-all duration-300 hover:-translate-y-1 hover:scale-110 hover:shadow-xl"
>
<Link href={`/api/billing/${wsId}/invoice`} target="_blank">
<Download className="h-4 w-4 transition-transform duration-300 group-hover:translate-y-2 group-hover:scale-125" />
Download Receipt
</Link>
</Button>
)}
<Button
variant="outline"
asChild
className="group flex items-center gap-2 transition-all duration-300 hover:-translate-y-1 hover:scale-110 hover:shadow-xl"
>

Check warning on line 238 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L213-L238

Added lines #L213 - L238 were not covered by tests
<Link href={`/${wsId}`}>
<CreditCard className="h-4 w-4" />
<CreditCard className="h-4 w-4 transition-transform duration-300 group-hover:scale-125 group-hover:rotate-45" />

Check warning on line 240 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L240

Added line #L240 was not covered by tests
Go to Dashboard
</Link>
</Button>
</div>

{/* Support Information */}
<div className="mt-8 rounded-lg border border-border bg-muted/30 p-6 text-center">
<div className="mt-8 rounded-lg border border-border bg-muted/30 p-6 text-center transition-all delay-2000 duration-300 duration-800 animate-in fade-in hover:scale-105 hover:bg-muted/50">

Check warning on line 247 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L247

Added line #L247 was not covered by tests
<p className="text-sm text-muted-foreground">
Need help? Contact our{' '}
<Link
href="/support"
className="font-medium text-primary hover:text-primary/80"
href="/#"
className="inline-block font-medium text-primary transition-all duration-300 hover:scale-110 hover:text-primary/80 hover:underline"

Check warning on line 252 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L251-L252

Added lines #L251 - L252 were not covered by tests
>
support team
</Link>{' '}
or visit our{' '}
<Link
href="/help"
className="font-medium text-primary hover:text-primary/80"
href="/#"
className="inline-block font-medium text-primary transition-all duration-300 hover:scale-110 hover:text-primary/80 hover:underline"

Check warning on line 259 in apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/[locale]/(dashboard)/[wsId]/billing/success/page.tsx#L258-L259

Added lines #L258 - L259 were not covered by tests
>
help center
</Link>
Expand Down
Loading