Skip to content

Commit 6865df6

Browse files
committed
fix badge logic
1 parent 534244a commit 6865df6

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/usage-indicator/usage-indicator.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const PLAN_NAMES = {
2222
} as const
2323

2424
interface UsageIndicatorProps {
25-
onClick?: (badgeType: 'add' | 'upgrade') => void
25+
onClick?: () => void
2626
}
2727

2828
export function UsageIndicator({ onClick }: UsageIndicatorProps) {
@@ -39,7 +39,7 @@ export function UsageIndicator({ onClick }: UsageIndicatorProps) {
3939
// Show skeleton while loading
4040
if (isLoading) {
4141
return (
42-
<div className={CONTAINER_STYLES} onClick={() => onClick?.('upgrade')}>
42+
<div className={CONTAINER_STYLES} onClick={() => onClick?.()}>
4343
<div className='space-y-2'>
4444
{/* Plan and usage info skeleton */}
4545
<div className='flex items-center justify-between'>
@@ -69,13 +69,10 @@ export function UsageIndicator({ onClick }: UsageIndicatorProps) {
6969
// Determine badge to show
7070
const billingStatus = useSubscriptionStore.getState().getBillingStatus()
7171
const isBlocked = billingStatus === 'blocked'
72-
const showAddBadge =
73-
!isBlocked && planType !== 'free' && planType !== 'enterprise' && usage.percentUsed >= 50
74-
const badgeText = isBlocked ? 'Payment Failed' : planType === 'free' ? 'Upgrade' : 'Add'
75-
const badgeType = isBlocked ? 'upgrade' : planType === 'free' ? 'upgrade' : 'add'
72+
const badgeText = isBlocked ? 'Payment Failed' : planType === 'free' ? 'Upgrade' : undefined
7673

7774
return (
78-
<div className={CONTAINER_STYLES} onClick={() => onClick?.(badgeType)}>
75+
<div className={CONTAINER_STYLES} onClick={() => onClick?.()}>
7976
<div className='space-y-2'>
8077
{/* Plan and usage info */}
8178
<div className='flex items-center justify-between'>
@@ -88,9 +85,7 @@ export function UsageIndicator({ onClick }: UsageIndicatorProps) {
8885
>
8986
{PLAN_NAMES[planType]}
9087
</span>
91-
{(showAddBadge || planType === 'free') && (
92-
<Badge className={GRADIENT_BADGE_STYLES}>{badgeText}</Badge>
93-
)}
88+
{badgeText ? <Badge className={GRADIENT_BADGE_STYLES}>{badgeText}</Badge> : null}
9489
</div>
9590
<span className='text-muted-foreground text-xs tabular-nums'>
9691
{isBlocked ? 'Payment required' : `$${usage.current.toFixed(2)} / $${usage.limit}`}

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/sidebar.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,10 +1008,9 @@ export function Sidebar() {
10081008
style={{ bottom: `${navigationBottom + SIDEBAR_HEIGHTS.NAVIGATION + SIDEBAR_GAP}px` }} // Navigation height + gap
10091009
>
10101010
<UsageIndicator
1011-
onClick={(badgeType) => {
1011+
onClick={() => {
10121012
const isBlocked = useSubscriptionStore.getState().getBillingStatus() === 'blocked'
1013-
1014-
if (isBlocked || badgeType === 'add') {
1013+
if (isBlocked) {
10151014
if (typeof window !== 'undefined') {
10161015
window.dispatchEvent(
10171016
new CustomEvent('open-settings', { detail: { tab: 'subscription' } })

0 commit comments

Comments
 (0)