|
3 | 3 | import { useEffect, useRef, useState } from 'react' |
4 | 4 | import { X } from 'lucide-react' |
5 | 5 | import { Button, Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui' |
6 | | -import { client } from '@/lib/auth-client' |
| 6 | +import { isBillingEnabled } from '@/lib/environment' |
7 | 7 | import { createLogger } from '@/lib/logs/console/logger' |
8 | 8 | import { cn } from '@/lib/utils' |
9 | 9 | import { |
@@ -82,7 +82,14 @@ export function SettingsModal({ open, onOpenChange }: SettingsModalProps) { |
82 | 82 | } |
83 | 83 | }, [onOpenChange]) |
84 | 84 |
|
85 | | - const isSubscriptionEnabled = !!client.subscription |
| 85 | + // Redirect away from billing tabs if billing is disabled |
| 86 | + useEffect(() => { |
| 87 | + if (!isBillingEnabled && (activeSection === 'subscription' || activeSection === 'team')) { |
| 88 | + setActiveSection('general') |
| 89 | + } |
| 90 | + }, [activeSection]) |
| 91 | + |
| 92 | + const isSubscriptionEnabled = isBillingEnabled |
86 | 93 |
|
87 | 94 | return ( |
88 | 95 | <Dialog open={open} onOpenChange={onOpenChange}> |
@@ -134,9 +141,11 @@ export function SettingsModal({ open, onOpenChange }: SettingsModalProps) { |
134 | 141 | <Subscription onOpenChange={onOpenChange} /> |
135 | 142 | </div> |
136 | 143 | )} |
137 | | - <div className={cn('h-full', activeSection === 'team' ? 'block' : 'hidden')}> |
138 | | - <TeamManagement /> |
139 | | - </div> |
| 144 | + {isBillingEnabled && ( |
| 145 | + <div className={cn('h-full', activeSection === 'team' ? 'block' : 'hidden')}> |
| 146 | + <TeamManagement /> |
| 147 | + </div> |
| 148 | + )} |
140 | 149 | <div className={cn('h-full', activeSection === 'privacy' ? 'block' : 'hidden')}> |
141 | 150 | <Privacy /> |
142 | 151 | </div> |
|
0 commit comments