()
| 38 | import { useOrganizationData } from '@/hooks/use-organization-data' |
| 39 | |
| 40 | export default function OrganizationPage() { |
| 41 | const { data: session, status } = useSession() |
| 42 | const params = useParams() ?? {} |
| 43 | const router = useRouter() |
| 44 | const searchParams = useSearchParams() ?? new URLSearchParams() |
| 45 | const orgSlug = (params.slug as string) ?? '' |
| 46 | const isMobile = useIsMobile() |
| 47 | |
| 48 | // BILLING_DISABLED: Removed settingUpBilling state |
| 49 | // const [settingUpBilling, setSettingUpBilling] = useState(false) |
| 50 | |
| 51 | // Collapsible states - only one can be open at a time |
| 52 | const [activeSection, setActiveSection] = useState< |
| 53 | 'members' | 'repositories' | 'creditBalance' | null |
| 54 | >('creditBalance') // Default to showing credit monitor |
| 55 | |
| 56 | // Use the custom hook for organization data |
| 57 | // BILLING_DISABLED: billingStatus renamed to _billingStatus (unused while billing is disabled) |
| 58 | const { organization, billingStatus: _billingStatus, isLoading, error } = |
| 59 | useOrganizationData(orgSlug) |
| 60 | |
| 61 | // BILLING_DISABLED: Removed low credit threshold check |
| 62 | // const LOW_CREDIT_THRESHOLD = 2000 |
| 63 | |
| 64 | // Check for subscription success |
| 65 | useEffect(() => { |
| 66 | if (searchParams.get('subscription_success') === 'true') { |
| 67 | toast({ |
| 68 | title: 'Subscription Active!', |
| 69 | description: |
| 70 | 'Your organization subscription has been set up successfully.', |
| 71 | }) |
| 72 | // Clean up the URL |
| 73 | router.replace(`/orgs/${orgSlug}`, { scroll: false }) |
| 74 | } |
| 75 | }, [searchParams, orgSlug, router]) |
| 76 | |
| 77 | // BILLING_DISABLED: Removed handleSetupBilling function |
| 78 | /* |
| 79 | const handleSetupBilling = async () => { |
| 80 | if (!organization) return |
| 81 | |
| 82 | setSettingUpBilling(true) |
| 83 | try { |
| 84 | const response = await fetch( |
| 85 | `/api/orgs/${organization.id}/billing/setup`, |
| 86 | { |
| 87 | method: 'POST', |
| 88 | headers: { |
| 89 | 'Content-Type': 'application/json', |
| 90 | }, |
| 91 | }, |
| 92 | ) |
| 93 | |
| 94 | if (!response.ok) { |
| 95 | const error = await response.json() |
| 96 | throw new Error(error.error || 'Failed to setup billing') |
| 97 | } |
nothing calls this directly
no test coverage detected