fix redirect to checkout when the org has not a subscription
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user