@@ -16,7 +16,8 @@ import {
1616 FileText ,
1717 Gauge ,
1818 MessageCircle ,
19- Globe
19+ Globe ,
20+ Coins
2021} from "lucide-react" ;
2122import { useNavigate } from "@tanstack/react-router" ;
2223import { useLocalState } from "@/state/useLocalState" ;
@@ -42,6 +43,11 @@ export function UpgradePromptDialog({
4243 navigate ( { to : "/pricing" } ) ;
4344 } ;
4445
46+ const handleBuyCredits = ( ) => {
47+ onOpenChange ( false ) ;
48+ navigate ( { to : "/" , search : { api_settings : true } } ) ;
49+ } ;
50+
4551 const handleNewChat = ( ) => {
4652 onOpenChange ( false ) ;
4753 // Trigger new chat event
@@ -57,6 +63,7 @@ export function UpgradePromptDialog({
5763 const isFreeTier = ! localState . billingStatus ?. product_name || currentPlan === "free" ;
5864 const isPro = currentPlan . includes ( "pro" ) && ! currentPlan . includes ( "max" ) ;
5965 const isMax = currentPlan . includes ( "max" ) ;
66+ const hasApiAccess = isPro || isMax || currentPlan . includes ( "team" ) ;
6067
6168 const getNextPlan = ( ) => {
6269 if ( isFreeTier ) return "Pro" ;
@@ -130,8 +137,8 @@ export function UpgradePromptDialog({
130137 description : isFreeTier
131138 ? "You've reached your daily free tier limit. Upgrade to Pro for unlimited daily usage."
132139 : isPro
133- ? "You've reached your Pro plan's monthly limit. Upgrade to Max for 10x more usage."
134- : "You've reached your monthly usage limit. Please wait for the next billing cycle." ,
140+ ? "You've reached your Pro plan's monthly limit. Upgrade to Max for 10x more usage, or purchase API credits to continue chatting ."
141+ : "You've reached your monthly usage limit. Purchase API credits to continue chatting, or wait for the next billing cycle." ,
135142 requiredPlan : nextPlan ,
136143 benefits : isFreeTier
137144 ? [
@@ -147,11 +154,12 @@ export function UpgradePromptDialog({
147154 "10x more monthly messages with Max plan" ,
148155 "Access to all premium models including DeepSeek R1" ,
149156 "Highest priority during peak times" ,
150- "Maximum rate limits for power users"
157+ "Maximum rate limits for power users" ,
158+ "Or purchase API credits to keep chatting now"
151159 ]
152160 : [
153161 "You're already on our highest individual plan" ,
154- "Consider Team plans for shared usage" ,
162+ "Purchase API credits to extend your usage" ,
155163 "Monthly usage automatically refreshes" ,
156164 "Contact support for custom enterprise plans"
157165 ]
@@ -230,23 +238,30 @@ export function UpgradePromptDialog({
230238 ) : null }
231239 </ div >
232240
233- < DialogFooter className = "gap-2 sm:gap-0" >
241+ < DialogFooter className = "flex flex-col gap-2 sm:flex-col sm:justify-stretch sm:space-x-0" >
242+ { ( info . requiredPlan !== "Max" || ! isMax ) && (
243+ < Button onClick = { handleUpgrade } className = "w-full gap-2" >
244+ < Sparkles className = "h-4 w-4" />
245+ { isFreeTier ? "Upgrade to Pro" : isPro ? "Upgrade to Max" : "View Plans" }
246+ </ Button >
247+ ) }
248+ { /* Show Buy Credits button for paid users hitting usage limits */ }
249+ { feature === "usage" && hasApiAccess && (
250+ < Button variant = "outline" onClick = { handleBuyCredits } className = "w-full gap-2" >
251+ < Coins className = "h-4 w-4" />
252+ Buy API Credits
253+ </ Button >
254+ ) }
234255 { /* Show "Start New Chat" for free tier conversation limit, "Maybe Later" for others */ }
235256 { feature === "tokens" && isFreeTier ? (
236- < Button variant = "outline " onClick = { handleNewChat } >
257+ < Button variant = "ghost " onClick = { handleNewChat } className = "w-full" >
237258 Start New Chat
238259 </ Button >
239260 ) : (
240- < Button variant = "outline " onClick = { ( ) => onOpenChange ( false ) } >
261+ < Button variant = "ghost " onClick = { ( ) => onOpenChange ( false ) } className = "w-full" >
241262 Maybe Later
242263 </ Button >
243264 ) }
244- { ( info . requiredPlan !== "Max" || ! isMax ) && (
245- < Button onClick = { handleUpgrade } className = "gap-2" >
246- < Sparkles className = "h-4 w-4" />
247- { isFreeTier ? "Upgrade to Pro" : isPro ? "Upgrade to Max" : "View Plans" }
248- </ Button >
249- ) }
250265 </ DialogFooter >
251266 </ DialogContent >
252267 </ Dialog >
0 commit comments