billing.tsx42 lines · main
1import { useParams } from 'common'
2import { useEffect } from 'react'
3
4import { BillingSettings } from '@/components/interfaces/Organization/BillingSettings/BillingSettings'
5import { DefaultLayout } from '@/components/layouts/DefaultLayout'
6import OrganizationLayout from '@/components/layouts/OrganizationLayout'
7import { UnknownInterface } from '@/components/ui/UnknownInterface'
8import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
9import {
10 ORG_SETTINGS_PANEL_KEYS,
11 useOrgSettingsPageStateSnapshot,
12} from '@/state/organization-settings'
13import type { NextPageWithLayout } from '@/types'
14
15const OrgBillingSettings: NextPageWithLayout = () => {
16 const { panel, slug } = useParams()
17 const snap = useOrgSettingsPageStateSnapshot()
18
19 const showBilling = useIsFeatureEnabled('billing:all')
20
21 useEffect(() => {
22 const allowedValues = ['subscriptionPlan', 'costControl']
23 if (panel && typeof panel === 'string' && allowedValues.includes(panel)) {
24 snap.setPanelKey(panel as ORG_SETTINGS_PANEL_KEYS)
25 document.getElementById('billing-page-top')?.scrollIntoView({ behavior: 'smooth' })
26 }
27 // eslint-disable-next-line react-hooks/exhaustive-deps
28 }, [panel])
29
30 if (!showBilling) {
31 return <UnknownInterface urlBack={`/org/${slug}`} />
32 }
33
34 return <BillingSettings />
35}
36
37OrgBillingSettings.getLayout = (page) => (
38 <DefaultLayout>
39 <OrganizationLayout title="Billing">{page}</OrganizationLayout>
40 </DefaultLayout>
41)
42export default OrgBillingSettings