Skip to content

armgit / E2B

Public Imported from GitHub
0

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

fix bugs

Vasek Mlejnskya7d5eb631289
diff --git a/apps/docs/src/app/pricing/Promo.tsx b/apps/docs/src/app/pricing/Promo.tsx
index 2094ec71f..3158e5225 100644
--- a/apps/docs/src/app/pricing/Promo.tsx
+++ b/apps/docs/src/app/pricing/Promo.tsx
@@ -2,7 +2,6 @@
import { useState } from 'react'
import { Button } from '@/components/Button'
-import { useSignIn } from '@/utils/useSignIn'
import { useUser } from '@/utils/useUser'
function sendPromoCode(promoCode: string, teamID: string) {
@@ -19,13 +18,13 @@ function Promo() {
const [code, setCode] = useState('')
const [error, setError] = useState('')
const { user } = useUser()
- const signIn = useSignIn()
async function applyPromoCode() {
if (!code) return
if (!user) {
setError('You must be signed in to apply a promo code')
}
+ setError('')
// TODO: Actually apply the promo code
const response = await sendPromoCode(code, user.teams[0].id)
@@ -36,10 +35,8 @@ function Promo() {
console.error('Error applying promo code:', responseData.error)
setError(responseData.error)
} else {
- // TODO: We applied the promo code, what now?
console.log('Promo code applied successfully')
-
- setCode('')
+ location.reload()
}
}
diff --git a/apps/docs/src/app/pricing/promo/route.ts b/apps/docs/src/app/pricing/promo/route.ts
index 062ae0b49..2ffdab0f5 100644
--- a/apps/docs/src/app/pricing/promo/route.ts
+++ b/apps/docs/src/app/pricing/promo/route.ts
@@ -53,7 +53,7 @@ export async function POST(request: Request) {
const teamTier: string = teamData[0].tier
// If team tier isn't a pro tier already, apply the promo tier
- if (teamTier.startsWith('promo')) {
+ if (teamTier.startsWith('free_')) {
const now = new Date()
const validFrom = new Date(tiersData[0].promo_starts_at)
@@ -75,8 +75,14 @@ export async function POST(request: Request) {
.update({ tier: tiersData[0].id })
.eq('id', teamID)
- } else {
- console.log('Team doesn\'t have a free tier, not applying promo')
+ } else if (teamTier.startsWith('promo_')) {
+ return Response.json({
+ error: 'Team already has promo active',
+ })
+ } else if (teamTier.startsWith('pro_')) {
+ return Response.json({
+ error: 'Team already has a pro tier',
+ })
}
return Response.json({