MCPcopy Create free account
hub / github.com/CodebuffAI/codebuff / BillingSetupPage

Function BillingSetupPage

web/src/app/orgs/[slug]/billing/setup/page.tsx:32–272  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30const stripePromise = loadStripe(env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY!)
31
32export default function BillingSetupPage() {
33 // All hooks must be called before any conditional returns
34 const params = useParams() ?? {}
35 const orgSlug = (params.slug as string) ?? ''
36 const { data: session, status } = useSession()
37 const _router = useRouter()
38
39 const [settingUp, setSettingUp] = useState(false)
40
41 // Use the custom hook for organization data
42 const { organization, isLoading, error } = useOrganizationData(orgSlug)
43
44 // BILLING_DISABLED: Show unavailable message when org billing is disabled
45 if (!ORG_BILLING_ENABLED) {
46 return (
47 <div className="container mx-auto px-4 py-8">
48 <div className="max-w-2xl mx-auto">
49 <Card>
50 <CardHeader>
51 <CardTitle className="flex items-center">
52 <CreditCard className="h-5 w-5 mr-2" />
53 Feature Unavailable
54 </CardTitle>
55 </CardHeader>
56 <CardContent>
57 <p className="mb-4">
58 Organization billing setup is temporarily unavailable.
59 </p>
60 <Link href={`/orgs/${orgSlug}`}>
61 <Button>
62 <ArrowLeft className="h-4 w-4 mr-2" />
63 Back to Organization
64 </Button>
65 </Link>
66 </CardContent>
67 </Card>
68 </div>
69 </div>
70 )
71 }
72
73 const handleSetupBilling = async () => {
74 if (!organization) return
75
76 setSettingUp(true)
77 try {
78 const response = await fetch(
79 `/api/orgs/${organization.id}/billing/setup`,
80 {
81 method: 'POST',
82 headers: {
83 'Content-Type': 'application/json',
84 },
85 },
86 )
87
88 if (!response.ok) {
89 const error = await response.json()

Callers

nothing calls this directly

Calls 1

useOrganizationDataFunction · 0.90

Tested by

no test coverage detected