Skip to content

Commit 4d4aefa

Browse files
fix(envvar): clear separation between server-side and client-side billing envvar (#988)
1 parent 2e027dd commit 4d4aefa

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/components/settings-navigation/settings-navigation.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import {
88
UserCircle,
99
Users,
1010
} from 'lucide-react'
11-
import { isBillingEnabled } from '@/lib/environment'
11+
import { getEnv, isTruthy } from '@/lib/env'
1212
import { cn } from '@/lib/utils'
1313
import { useSubscriptionStore } from '@/stores/subscription/store'
1414

15+
const isBillingEnabled = isTruthy(getEnv('NEXT_PUBLIC_BILLING_ENABLED'))
16+
1517
interface SettingsNavigationProps {
1618
activeSection: string
1719
onSectionChange: (

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { useEffect, useRef, useState } from 'react'
44
import { X } from 'lucide-react'
55
import { Button, Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui'
6-
import { isBillingEnabled } from '@/lib/environment'
6+
import { getEnv, isTruthy } from '@/lib/env'
77
import { createLogger } from '@/lib/logs/console/logger'
88
import { cn } from '@/lib/utils'
99
import {
@@ -22,6 +22,8 @@ import { useGeneralStore } from '@/stores/settings/general/store'
2222

2323
const logger = createLogger('SettingsModal')
2424

25+
const isBillingEnabled = isTruthy(getEnv('NEXT_PUBLIC_BILLING_ENABLED'))
26+
2527
interface SettingsModalProps {
2628
open: boolean
2729
onOpenChange: (open: boolean) => void

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { HelpCircle, LibraryBig, ScrollText, Search, Settings, Shapes } from 'lu
55
import { useParams, usePathname, useRouter } from 'next/navigation'
66
import { Button, ScrollArea, Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui'
77
import { useSession } from '@/lib/auth-client'
8-
import { isBillingEnabled } from '@/lib/environment'
8+
import { getEnv, isTruthy } from '@/lib/env'
99
import { createLogger } from '@/lib/logs/console/logger'
1010
import { generateWorkspaceName } from '@/lib/naming'
1111
import { cn } from '@/lib/utils'
@@ -38,6 +38,8 @@ const logger = createLogger('Sidebar')
3838

3939
const SIDEBAR_GAP = 12 // 12px gap between components - easily editable
4040

41+
const isBillingEnabled = isTruthy(getEnv('NEXT_PUBLIC_BILLING_ENABLED'))
42+
4143
/**
4244
* Optimized auto-scroll hook for smooth drag operations
4345
* Extracted outside component for better performance

apps/sim/lib/environment.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Environment utility functions for consistent environment detection across the application
33
*/
4-
import { env, getEnv, isTruthy } from './env'
4+
import { env, isTruthy } from './env'
55

66
/**
77
* Is the application running in production mode
@@ -26,8 +26,7 @@ export const isHosted = env.NEXT_PUBLIC_APP_URL === 'https://www.sim.ai'
2626
/**
2727
* Is billing enforcement enabled
2828
*/
29-
export const isBillingEnabled =
30-
isTruthy(getEnv('NEXT_PUBLIC_BILLING_ENABLED')) || isTruthy(env.BILLING_ENABLED)
29+
export const isBillingEnabled = isTruthy(env.BILLING_ENABLED)
3130

3231
/**
3332
* Get cost multiplier based on environment

0 commit comments

Comments
 (0)