This commit is contained in:
Nikita
2025-12-21 13:37:19 -08:00
commit 8cd4b943a5
173 changed files with 44266 additions and 0 deletions

View 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>
)
}