mirror of
https://github.com/linsa-io/linsa.git
synced 2026-01-12 12:20:23 +01:00
.
This commit is contained in:
28
packages/web/src/components/BillingProvider.tsx
Normal file
28
packages/web/src/components/BillingProvider.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
import { FlowgladProvider } from "@flowglad/react"
|
||||
import { authClient } from "@/lib/auth-client"
|
||||
|
||||
type BillingProviderProps = {
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
export function BillingProvider({ children }: BillingProviderProps) {
|
||||
const flowgladEnabled = import.meta.env.VITE_FLOWGLAD_ENABLED === "true"
|
||||
|
||||
// Skip billing entirely when Flowglad isn't configured
|
||||
if (!flowgladEnabled) {
|
||||
return <>{children}</>
|
||||
}
|
||||
|
||||
const { data: session, isPending } = authClient.useSession()
|
||||
|
||||
// Don't load billing until we know auth state
|
||||
if (isPending) {
|
||||
return <>{children}</>
|
||||
}
|
||||
|
||||
return (
|
||||
<FlowgladProvider loadBilling={!!session?.user} serverRoute="/api/flowglad">
|
||||
{children}
|
||||
</FlowgladProvider>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user