fix redirect to checkout when the org has not a subscription

This commit is contained in:
2026-01-07 14:30:29 -03:00
parent d222872000
commit ded57b43f0
7 changed files with 173 additions and 113 deletions

View File

@@ -30,20 +30,8 @@ import { initials } from '@repo/ui/lib/utils'
import { Link } from 'react-router'
import type { Workspace, WorkspaceContextProps } from '@/middleware/workspace'
import type { Address } from '@/routes/_.$orgid.enrollments.buy/review'
type Subscription = {
billing_day: number
payment_method: 'PIX' | 'BANK_SLIP' | 'MANUAL'
}
const WorkspaceContext = createContext<
| (WorkspaceContextProps & {
subscription: Subscription | null
address: Address | null
})
| null
>(null)
const WorkspaceContext = createContext<WorkspaceContextProps | null>(null)
export function useWorksapce() {
const ctx = use(WorkspaceContext)
@@ -56,33 +44,12 @@ export function useWorksapce() {
}
export function WorkspaceProvider({
activeWorkspace,
workspaces,
subscription,
address,
children
}: {
activeWorkspace: Workspace
workspaces: Workspace[]
subscription?: Subscription
address?: Address
children,
...props
}: WorkspaceContextProps & {
children: React.ReactNode
}) {
return (
<WorkspaceContext
value={{
activeWorkspace,
workspaces,
address: address && Object.keys(address).length > 0 ? address : null,
subscription:
subscription && Object.keys(subscription).length > 0
? subscription
: null
}}
>
{children}
</WorkspaceContext>
)
return <WorkspaceContext value={props}>{children}</WorkspaceContext>
}
export function WorkspaceSwitcher() {