Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Add text for pro users without credit card

Vasek Mlejnsky8682403a5dfa
diff --git a/apps/docs/src/app/pricing/SwitchToProButton.tsx b/apps/docs/src/app/pricing/SwitchToProButton.tsx
index 1d3069bca..9df020c49 100644
--- a/apps/docs/src/app/pricing/SwitchToProButton.tsx
+++ b/apps/docs/src/app/pricing/SwitchToProButton.tsx
@@ -52,6 +52,7 @@ function SwitchTierButton() {
)}
+
{user.pricingTier.id !== tiers.pro.id && (
<Button
onClick={createCheckoutSession}
@@ -59,6 +60,14 @@ function SwitchTierButton() {
Switch to Pro
</Button>
)}
+
+ {(user.pricingTier.id === tiers.pro.id && !user.teams[0].team_billing[0].credit_card_added) && (
+ <Button
+ onClick={createCheckoutSession}
+ >
+ Add Credit Card
+ </Button>
+ )}
</div>
{error && (
diff --git a/apps/docs/src/utils/useUser.tsx b/apps/docs/src/utils/useUser.tsx
index 81f94cac6..f319fe34c 100644
--- a/apps/docs/src/utils/useUser.tsx
+++ b/apps/docs/src/utils/useUser.tsx
@@ -13,6 +13,9 @@ type Team = {
tier: string
is_default: boolean
email: string
+ team_billing: {
+ credit_card_added: boolean
+ }[]
}
type UserContextType = {
@@ -103,12 +106,14 @@ export const CustomUserContextProvider = (props) => {
// @ts-ignore
const { data: userTeams, teamsError } = await supabase
.from('users_teams')
- .select('teams (id, name, is_default, tier, email)')
+ .select('teams (id, name, is_default, tier, email, team_billing (credit_card_added))')
.eq('user_id', session?.user.id) // Due to RLS, we could also safely just fetch all, but let's be explicit for sure
+ console.log('>>>>>>>>>>>>>>>>>>>> userTeams', userTeams)
if (teamsError) Sentry.captureException(teamsError)
// TODO: Adjust when user can be part of multiple teams
// @ts-ignore
const teams = userTeams?.map(userTeam => userTeam.teams as Team)
+
const defaultTeam = teams?.find(team => team.is_default)
if (!defaultTeam) {