11'use client'
22
33import { CreditCard , Shield , Users , Key , Menu } from 'lucide-react'
4- import { useSearchParams } from 'next/navigation'
4+ import { useRouter , useSearchParams } from 'next/navigation'
55import { useSession } from 'next-auth/react'
66import { useState , useEffect , Suspense } from 'react'
77
@@ -17,6 +17,7 @@ import { Button } from '@/components/ui/button'
1717import { Sheet , SheetContent , SheetTrigger } from '@/components/ui/sheet'
1818import { Skeleton } from '@/components/ui/skeleton'
1919import { cn } from '@/lib/utils'
20+ import { toast } from '@/components/ui/use-toast'
2021
2122const sections = [
2223 {
@@ -82,6 +83,7 @@ function ProfileSidebar({
8283
8384function 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