22
33import { WarningIcon } from "@phosphor-icons/react" ;
44import { useQuery } from "@tanstack/react-query" ;
5- import { useRouter } from "next/navigation " ;
6- import { Button } from "@/components/ui/button" ;
5+ import Link from "next/link " ;
6+ import { buttonVariants } from "@/components/ui/button" ;
77import { orpc } from "@/lib/orpc" ;
88
99export function EventLimitIndicator ( ) {
10- const router = useRouter ( ) ;
1110 const { data } = useQuery ( {
1211 ...orpc . organizations . getUsage . queryOptions ( ) ,
1312 } ) ;
@@ -18,12 +17,17 @@ export function EventLimitIndicator() {
1817
1918 const balance = data . balance ?? 0 ;
2019 const planLimit = data . includedUsage ?? 0 ;
20+ const overageAllowed = data . overageAllowed ?? false ;
2121
2222 // Balance > Plan limit = Bonus credits, show remaining
2323 // Balance < Plan limit = Normal usage, balance is remaining
2424 // Balance < 0 = Overage
2525
2626 if ( balance < 0 ) {
27+ // Don't show overage warning if user is allowed to have overage
28+ if ( overageAllowed ) {
29+ return null ;
30+ }
2731 // Overage state
2832 const overage = Math . abs ( balance ) ;
2933 return (
@@ -40,14 +44,16 @@ export function EventLimitIndicator() {
4044 </ div >
4145 </ div >
4246 { data . canUserUpgrade ? (
43- < Button
44- className = "h-6 px-2 text-xs"
45- onClick = { ( ) => router . push ( "/billing?tab=plans" ) }
46- size = "sm"
47- variant = "ghost"
47+ < Link
48+ className = { buttonVariants ( {
49+ variant : "ghost" ,
50+ size : "sm" ,
51+ className : "h-6 px-2 text-xs" ,
52+ } ) }
53+ href = "/billing/plans"
4854 >
4955 Upgrade
50- </ Button >
56+ </ Link >
5157 ) : (
5258 < span className = "text-muted-foreground text-xs" > Contact owner</ span >
5359 ) }
@@ -86,14 +92,16 @@ export function EventLimitIndicator() {
8692 </ div >
8793 </ div >
8894 { data . canUserUpgrade ? (
89- < Button
90- className = "h-6 px-2 text-xs"
91- onClick = { ( ) => router . push ( "/billing?tab=plans" ) }
92- size = "sm"
93- variant = "ghost"
95+ < Link
96+ className = { buttonVariants ( {
97+ variant : "ghost" ,
98+ size : "sm" ,
99+ className : "h-6 px-2 text-xs" ,
100+ } ) }
101+ href = "/billing/plans"
94102 >
95103 Upgrade
96- </ Button >
104+ </ Link >
97105 ) : (
98106 < span className = "text-muted-foreground text-xs" > Contact owner</ span >
99107 ) }
0 commit comments