Skip to content

Commit 0c34f9b

Browse files
committed
Subscription success toast
1 parent e090f02 commit 0c34f9b

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

web/src/app/profile/page.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client'
22

33
import { CreditCard, Shield, Users, Key, Menu } from 'lucide-react'
4-
import { useSearchParams } from 'next/navigation'
4+
import { useRouter, useSearchParams } from 'next/navigation'
55
import { useSession } from 'next-auth/react'
66
import { useState, useEffect, Suspense } from 'react'
77

@@ -17,6 +17,7 @@ import { Button } from '@/components/ui/button'
1717
import { Sheet, SheetContent, SheetTrigger } from '@/components/ui/sheet'
1818
import { Skeleton } from '@/components/ui/skeleton'
1919
import { cn } from '@/lib/utils'
20+
import { toast } from '@/components/ui/use-toast'
2021

2122
const sections = [
2223
{
@@ -82,6 +83,7 @@ function ProfileSidebar({
8283

8384
function ProfilePageContent() {
8485
const { status } = useSession()
86+
const router = useRouter()
8587
const searchParams = useSearchParams() ?? new URLSearchParams()
8688
const [activeSection, setActiveSection] = useState('usage')
8789
const [open, setOpen] = useState(false)
@@ -93,6 +95,19 @@ function ProfilePageContent() {
9395
}
9496
}, [searchParams])
9597

98+
// Check for subscription success
99+
useEffect(() => {
100+
if (searchParams.get('subscription_success') === 'true') {
101+
toast({
102+
title: 'Welcome to Codebuff Strong! 🎉',
103+
description:
104+
'Thanks for subscribing! Your subscription is now active.',
105+
})
106+
// Clean up the URL while preserving the tab
107+
router.replace('/profile?tab=usage', { scroll: false })
108+
}
109+
}, [searchParams, router])
110+
96111
const ActiveComponent =
97112
sections.find((s) => s.id === activeSection)?.component || UsageSection
98113
const activeTitle =

0 commit comments

Comments
 (0)