Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

user to team tier

ErikKaumk74a605d0c3c3
diff --git a/apps/docs/src/app/(docs)/docs/pricing/SwitchToHobbyButton.tsx b/apps/docs/src/app/(docs)/docs/pricing/SwitchToHobbyButton.tsx
index 964372ad8..72ab1184d 100644
--- a/apps/docs/src/app/(docs)/docs/pricing/SwitchToHobbyButton.tsx
+++ b/apps/docs/src/app/(docs)/docs/pricing/SwitchToHobbyButton.tsx
@@ -3,13 +3,13 @@
import Link from 'next/link'
import { useEffect, useState } from 'react'
import { Button } from '@/components/Button'
-import { useUser } from '@/utils/useUser'
+import { Team, useUser } from '@/utils/useUser'
import { tiers } from '@/utils/consts'
import Spinner from '@/components/Spinner'
import { TierActiveTag } from './TierActiveTag'
-function SwitchToHobbyButton() {
+function SwitchToHobbyButton(team: Team) {
const { user, isLoading } = useUser()
const [url, setURL] = useState('')
@@ -33,18 +33,18 @@ function SwitchToHobbyButton() {
// Only show the button if the user is on the base_v1 tier.
// Teams can have custom tiers. We only want the button to users on the free tier.
- if (user.pricingTier.id !== tiers.hobby.id && user.pricingTier.id !== tiers.pro.id) {
+ if (team.tier !== tiers.hobby.id && team.tier !== tiers.pro.id) {
return null
}
return (
<div className="flex flex-col items-start justify-start gap-1 my-4">
<div className="flex items-center justify-start gap-2">
- {user.pricingTier.id === tiers.hobby.id && (
+ {team.tier === tiers.hobby.id && (
<TierActiveTag />
)}
- {user.pricingTier.id !== tiers.hobby.id && (
+ {team.tier !== tiers.hobby.id && (
<a href={url} target="_blank" rel="noreferrer noopener">
<Button>Switch to {tiers.hobby.displayName}</Button>
</a>
diff --git a/apps/docs/src/app/(docs)/docs/pricing/SwitchToProButton.tsx b/apps/docs/src/app/(docs)/docs/pricing/SwitchToProButton.tsx
index 0c9de76f4..bd7465af6 100644
--- a/apps/docs/src/app/(docs)/docs/pricing/SwitchToProButton.tsx
+++ b/apps/docs/src/app/(docs)/docs/pricing/SwitchToProButton.tsx
@@ -2,7 +2,7 @@
import Link from 'next/link'
import { Button } from '@/components/Button'
-import { useUser } from '@/utils/useUser'
+import { Team, useUser } from '@/utils/useUser'
import { useState } from 'react'
import { tiers } from '@/utils/consts'
import Spinner from '@/components/Spinner'
@@ -23,7 +23,7 @@ function createCheckout(tierID: string, teamID: string) {
})
}
-function SwitchTierButton() {
+function SwitchTierButton(team: Team) {
const { user, isLoading } = useUser()
const [error, setError] = useState('')
@@ -60,20 +60,20 @@ function SwitchTierButton() {
// Only show the button if the user is on the base_v1 tier.
// Teams can have custom tiers. We only want the button to users on the free tier.
- if (!billingApiURL || (user.pricingTier.id !== tiers.hobby.id && user.pricingTier.id !== tiers.pro.id)) {
+ if (!billingApiURL || (team.tier !== tiers.hobby.id && team.tier !== tiers.pro.id)) {
return
}
return (
<div className="flex flex-col items-start justify-start gap-1 my-4">
<div className="flex items-center justify-start gap-2">
- {user.pricingTier.id === tiers.pro.id && (
+ {team.tier === tiers.pro.id && (
<TierActiveTag />
)}
- {user.pricingTier.id !== tiers.pro.id && (
+ {team.tier !== tiers.pro.id && (
<Button
onClick={createCheckoutSession}
>
diff --git a/apps/docs/src/utils/useUser.tsx b/apps/docs/src/utils/useUser.tsx
index 3bbe8f41d..224094722 100644
--- a/apps/docs/src/utils/useUser.tsx
+++ b/apps/docs/src/utils/useUser.tsx
@@ -104,7 +104,7 @@ export const CustomUserContextProvider = (props) => {
.from('users_teams')
.select('teams (id, name, is_default, tier, email)')
.eq('user_id', session?.user.id) // Due to RLS, we could also safely just fetch all, but let's be explicit for sure
-
+
if (teamsError) Sentry.captureException(teamsError)
// TODO: Adjust when user can be part of multiple teams
// @ts-ignore