Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
added developer panel
Mish Ushakovd5816fe43923
diff --git a/apps/web/src/app/(dashboard)/dashboard/page.tsx b/apps/web/src/app/(dashboard)/dashboard/page.tsxindex a24e1a30a..b05573636 100644--- a/apps/web/src/app/(dashboard)/dashboard/page.tsx+++ b/apps/web/src/app/(dashboard)/dashboard/page.tsx@@ -1,6 +1,8 @@'use client'import { Suspense, useEffect, useState } from 'react'+import { useLocalStorage } from 'usehooks-ts'+import {BarChart,CreditCard,@@ -23,6 +25,7 @@ import { useRouter, useSearchParams } from 'next/navigation'import { PersonalContent } from '@/components/Dashboard/Personal'import { TemplatesContent } from '@/components/Dashboard/Templates'import { SandboxesContent } from '@/components/Dashboard/Sandboxes'+import { DeveloperContent } from '@/components/Dashboard/Developer'function redirectToCurrentURL() {const url = typeof window !== 'undefined' ? window.location.href : undefined@@ -82,6 +85,15 @@ const Dashboard = ({ user }) => {const [teams, setTeams] = useState<Team[]>([])const [currentTeam, setCurrentTeam] = useState<Team | null>(null)+ const apiUrlState = useLocalStorage(+ 'apiUrl',+ process.env.NEXT_PUBLIC_API_URL || ''+ )+ const billingUrlState = useLocalStorage(+ 'billingUrl',+ process.env.NEXT_PUBLIC_BILLING_API_URL || ''+ )+const initialTab =tab && menuLabels.includes(tab as MenuLabel)? (tab as MenuLabel)@@ -152,6 +164,8 @@ const Dashboard = ({ user }) => {teams={teams}setTeams={setTeams}setCurrentTeam={setCurrentTeam}+ apiUrlState={apiUrlState}+ billingUrlState={billingUrlState}/></div></>@@ -175,6 +189,9 @@ const Sidebar = ({currentTeam={currentTeam}setCurrentTeam={setCurrentTeam}setTeams={setTeams}+ openDevSettings={() => {+ setSelectedItem('developer')+ }}/><div className="flex flex-row justify-center space-x-4 md:space-x-0 md:space-y-2 md:flex-col">@@ -238,6 +255,8 @@ function MainContent({teams,setTeams,setCurrentTeam,+ apiUrlState,+ billingUrlState,}: {selectedItem: MenuLabeluser: E2BUser@@ -245,20 +264,34 @@ function MainContent({teams: Team[]setTeams: (teams: Team[]) => voidsetCurrentTeam: (team: Team) => void+ apiUrlState: [string, (value: string) => void]+ billingUrlState: [string, (value: string) => void]}) {switch (selectedItem) {case 'personal':- return <PersonalContent user={user} />+ return <PersonalContent user={user} billingUrl={billingUrlState[0]} />case 'keys':- return <KeysContent currentTeam={team} user={user} />+ return (+ <KeysContent+ currentTeam={team}+ user={user}+ billingUrl={billingUrlState[0]}+ />+ )case 'sandboxes':- return <SandboxesContent team={team} />+ return <SandboxesContent team={team} apiUrl={apiUrlState[0]} />case 'templates':- return <TemplatesContent user={user} teamId={team.id} />+ return (+ <TemplatesContent+ user={user}+ teamId={team.id}+ apiUrl={apiUrlState[0]}+ />+ )case 'usage':- return <UsageContent team={team} />+ return <UsageContent team={team} billingUrl={billingUrlState[0]} />case 'billing':- return <BillingContent team={team} />+ return <BillingContent team={team} billingUrl={billingUrlState[0]} />case 'team':return (<TeamContent@@ -267,6 +300,14 @@ function MainContent({teams={teams}setTeams={setTeams}setCurrentTeam={setCurrentTeam}+ billingUrl={billingUrlState[0]}+ />+ )+ case 'developer' as string:+ return (+ <DeveloperContent+ apiUrlState={apiUrlState}+ billingUrlState={billingUrlState}/>)default:diff --git a/apps/web/src/components/Dashboard/AccountSelector.tsx b/apps/web/src/components/Dashboard/AccountSelector.tsxindex eecd57bc6..52add6e85 100644--- a/apps/web/src/components/Dashboard/AccountSelector.tsx+++ b/apps/web/src/components/Dashboard/AccountSelector.tsx@@ -5,9 +5,9 @@ import {DropdownMenuSeparator,DropdownMenuTrigger,} from '@/components/ui/dropdown-menu'-import { ChevronRight, PlusCircle } from 'lucide-react'+import { Bug, ChevronRight, PlusCircle, Settings } from 'lucide-react'import { toast } from '../ui/use-toast'-import {+import {AlertDialog,AlertDialogAction,AlertDialogCancel,@@ -22,13 +22,19 @@ import { Button } from '../Button'const createTeamUrl = `${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams`-export const AccountSelector = ({ teams, user, currentTeam, setCurrentTeam, setTeams }) => {-+export const AccountSelector = ({+ teams,+ user,+ currentTeam,+ setCurrentTeam,+ setTeams,+ openDevSettings,+}) => {const [isDialogOpen, setIsDialogOpen] = useState(false)const [teamName, setTeamName] = useState('')const closeDialog = () => setIsDialogOpen(false)- const createNewTeam = async() => {+ const createNewTeam = async () => {const res = await fetch(createTeamUrl, {method: 'POST',headers: {@@ -54,52 +60,80 @@ export const AccountSelector = ({ teams, user, currentTeam, setCurrentTeam, setTtoast({title: `Team ${team.name} created`,})-+setTeams([...teams, team])setCurrentTeam(team)setTeamName('')}-- return(++ return (<><DropdownMenu>- <DropdownMenuTrigger- className='dropdown-trigger group outline-none flex w-full items-center justify-between rounded-lg p-2 mb-6 hover:bg-zinc-800 hover:cursor-pointer'- >- <div className='flex items-start flex-col'>- <p className='text-sm'>Current team</p>- <h3 className='font-bold text-left'>{currentTeam.name}</h3>- </div>- <ChevronRight className='transform transition-transform duration-300 group-hover:rotate-90' />- </DropdownMenuTrigger>- <DropdownMenuContent className='flex flex-col w-48 bg-zinc-900 border border-white/30'>- {teams?.map((team: any) => (- <DropdownMenuItem key={team.id} onClick={() => setCurrentTeam(team)}>- {team.name}+ <DropdownMenuTrigger className="dropdown-trigger group outline-none flex w-full items-center justify-between rounded-lg p-2 mb-6 hover:bg-zinc-800 hover:cursor-pointer">+ <div className="flex items-start flex-col">+ <p className="text-sm">Current team</p>+ <h3 className="font-bold text-left">{currentTeam.name}</h3>+ </div>+ <ChevronRight className="transform transition-transform duration-300 group-hover:rotate-90" />+ </DropdownMenuTrigger>+ <DropdownMenuContent className="flex flex-col w-48 bg-zinc-900 border border-white/30">+ {teams?.map((team: any) => (+ <DropdownMenuItem+ key={team.id}+ onClick={() => setCurrentTeam(team)}+ >+ {team.name}+ </DropdownMenuItem>+ ))}+ <DropdownMenuSeparator />+ <DropdownMenuItem+ className="flex items-center space-x-1"+ onClick={() => setIsDialogOpen(true)}+ >+ <PlusCircle width={15} height={15} />+ <span>Create Team</span>+ </DropdownMenuItem>+ <DropdownMenuSeparator />+ <DropdownMenuItem+ className="flex items-center space-x-1"+ onClick={openDevSettings}+ >+ <Bug width={15} height={15} />+ <span>Developer</span></DropdownMenuItem>- ))}- <DropdownMenuSeparator />- <DropdownMenuItem className='flex items-center space-x-1'>- <PlusCircle width={15} height={15} />- <p onClick={() => setIsDialogOpen(true)}>Create Team</p>- </DropdownMenuItem>- </DropdownMenuContent>+ </DropdownMenuContent></DropdownMenu><AlertDialog open={isDialogOpen} onOpenChange={setIsDialogOpen}>- <AlertDialogTrigger asChild>- <Button variant="outline" style={{ display: 'none' }}>Show Dialog</Button>- </AlertDialogTrigger>- <AlertDialogContent className="bg-inherit text-white border-black">- <AlertDialogHeader>- <AlertDialogTitle>Give your team a name</AlertDialogTitle>- <input className='border border-white/10 text-sm focus:outline-none outline-none rounded-md p-2' value={teamName} onChange={(e) => setTeamName(e.target.value)} />- </AlertDialogHeader>- <AlertDialogFooter>- <AlertDialogCancel className='border-white/10' onClick={closeDialog}>Cancel</AlertDialogCancel>- <AlertDialogAction className='bg-[#995100] text-white hover:bg-[#995100]' onClick={() => createNewTeam()}>Create</AlertDialogAction>- </AlertDialogFooter>- </AlertDialogContent>+ <AlertDialogTrigger asChild>+ <Button variant="outline" style={{ display: 'none' }}>+ Show Dialog+ </Button>+ </AlertDialogTrigger>+ <AlertDialogContent className="bg-inherit text-white border-black">+ <AlertDialogHeader>+ <AlertDialogTitle>Give your team a name</AlertDialogTitle>+ <input+ className="border border-white/10 text-sm focus:outline-none outline-none rounded-md p-2"+ value={teamName}+ onChange={(e) => setTeamName(e.target.value)}+ />+ </AlertDialogHeader>+ <AlertDialogFooter>+ <AlertDialogCancel+ className="border-white/10"+ onClick={closeDialog}+ >+ Cancel+ </AlertDialogCancel>+ <AlertDialogAction+ className="bg-[#995100] text-white hover:bg-[#995100]"+ onClick={() => createNewTeam()}+ >+ Create+ </AlertDialogAction>+ </AlertDialogFooter>+ </AlertDialogContent></AlertDialog></>)diff --git a/apps/web/src/components/Dashboard/Billing.tsx b/apps/web/src/components/Dashboard/Billing.tsxindex d683feb7e..33011ad38 100644--- a/apps/web/src/components/Dashboard/Billing.tsx+++ b/apps/web/src/components/Dashboard/Billing.tsx@@ -2,12 +2,22 @@ import { useEffect, useState } from 'react'import Link from 'next/link'import { Team, useUser } from '@/utils/useUser'import { Button } from '../Button'-import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '../ui/table'+import {+ Table,+ TableBody,+ TableCell,+ TableHead,+ TableHeader,+ TableRow,+} from '../ui/table'import SwitchToHobbyButton from '@/components/Pricing/SwitchToHobbyButton'import SwitchToProButton from '@/components/Pricing/SwitchToProButton'function formatCurrency(value: number) {- return value.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })+ return value.toLocaleString('en-US', {+ minimumFractionDigits: 2,+ maximumFractionDigits: 2,+ })}interface Invoice {@@ -17,14 +27,20 @@ interface Invoice {date_created: string}-export const BillingContent = ({ team }: { team: Team }) => {+export const BillingContent = ({+ team,+ billingUrl,+}: {+ team: Team+ billingUrl: string+}) => {const [invoices, setInvoices] = useState<Invoice[]>([])const [credits, setCredits] = useState<number | null>(null)useEffect(() => {const getInvoices = async function getInvoices() {setInvoices([])- const res = await fetch(`${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams/${team.id}/invoices`, {+ const res = await fetch(`${billingUrl}/teams/${team.id}/invoices`, {headers: {'X-Team-API-Key': team.apiKeys[0],},@@ -35,11 +51,11 @@ export const BillingContent = ({ team }: { team: Team }) => {return}- const invoices = await res.json() as Invoice[]+ const invoices = (await res.json()) as Invoice[]setInvoices(invoices)setCredits(null)- const creditsRes = await fetch(`${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams/${team.id}/usage`, {+ const creditsRes = await fetch(`${billingUrl}/teams/${team.id}/usage`, {headers: {'X-Team-API-Key': team.apiKeys[0],},@@ -53,31 +69,35 @@ export const BillingContent = ({ team }: { team: Team }) => {return (<div className="flex flex-col w-full h-full pb-10">- <div className='flex items-center space-x-4 pb-10'>- <h2 className='font-bold text-xl'>Make changes to your billing</h2>+ <div className="flex items-center space-x-4 pb-10">+ <h2 className="font-bold text-xl">Make changes to your billing</h2><ManageBilling /></div>- <div className='flex flex-col space-y-2 pb-10'>- <h2 className='font-bold text-xl'>Credits left</h2>- <span className="text-sm">Credits are used to bill your team automatically</span>+ <div className="flex flex-col space-y-2 pb-10">+ <h2 className="font-bold text-xl">Credits left</h2>+ <span className="text-sm">+ Credits are used to bill your team automatically+ </span>{credits === null ? (<span className="text-sm font-mono text-neutral-400">Loading...</span>) : (- <span className="text-sm font-mono text-green-300/80">${formatCurrency(credits ?? 0)}</span>+ <span className="text-sm font-mono text-green-300/80">+ ${formatCurrency(credits ?? 0)}+ </span>)}</div>- <div className='flex items-center space-x-4 pb-4'>- <h2 className='font-bold text-xl'>Change tier</h2>+ <div className="flex items-center space-x-4 pb-4">+ <h2 className="font-bold text-xl">Change tier</h2></div>- <div className='flex flex-col items-start justify-center pb-10'>- <div className='flex items-center space-x-4'>+ <div className="flex flex-col items-start justify-center pb-10">+ <div className="flex items-center space-x-4"><h2>Hobby tier</h2><SwitchToHobbyButton team={team} /></div>- <ul className='flex flex-col list-disc list-inside text-neutral-400'>+ <ul className="flex flex-col list-disc list-inside text-neutral-400"><li>One-time $100 credits</li><li>Community support</li><li>Up to 1 hour sandbox session length</li>@@ -85,28 +105,36 @@ export const BillingContent = ({ team }: { team: Team }) => {</ul></div>- <div className='flex flex-col items-start justify-center pb-10'>- <div className='flex items-center space-x-4'>+ <div className="flex flex-col items-start justify-center pb-10">+ <div className="flex items-center space-x-4"><h2>Pro tier</h2>- <SwitchToProButton team={team} />+ <SwitchToProButton billingApiURL={billingUrl} team={team} /></div>- <ul className='flex flex-col list-disc list-inside text-neutral-400'>+ <ul className="flex flex-col list-disc list-inside text-neutral-400"><li>One-time $100 credits</li><li>Dedicated Slack channel with live Pro support from our team</li><li>Prioritized features</li>- <li>Customize your <Link className="text-[#ff8800] underline" href="/docs/sandbox/compute">sandbox compute</Link></li>+ <li>+ Customize your{' '}+ <Link+ className="text-[#ff8800] underline"+ href="/docs/sandbox/compute"+ >+ sandbox compute+ </Link>+ </li><li>Up to 24 hours sandbox session length</li><li>Up to 100 concurrently running sandboxes</li></ul></div><div>- <h2 className='font-bold pb-4 text-xl'>Billing history</h2>+ <h2 className="font-bold pb-4 text-xl">Billing history</h2></div><Table><TableHeader>- <TableRow className='hover:bg-inherit dark:hover:bg-inherit border-b border-white/5 '>+ <TableRow className="hover:bg-inherit dark:hover:bg-inherit border-b border-white/5 "><TableHead>Date</TableHead><TableHead>Cost</TableHead><TableHead>Paid</TableHead>@@ -117,25 +145,35 @@ export const BillingContent = ({ team }: { team: Team }) => {{invoices && invoices.length > 0 ? (invoices.map((item, index) => (<TableRow- className='hover:bg-orange-300/10 dark:hover:bg-orange-300/10 border-b border-white/5'+ className="hover:bg-orange-300/10 dark:hover:bg-orange-300/10 border-b border-white/5"key={index}>- <TableCell>{new Date(item.date_created).toLocaleDateString()}</TableCell>+ <TableCell>+ {new Date(item.date_created).toLocaleDateString()}+ </TableCell><TableCell>${item.cost.toFixed(2)}</TableCell><TableCell>{item.paid ? 'Paid' : 'Unpaid'}</TableCell>- <TableCell><a className='hover:cursor-pointer' href={item.url} target="_blank" rel="noreferrer noopener">View invoice</a></TableCell>+ <TableCell>+ <a+ className="hover:cursor-pointer"+ href={item.url}+ target="_blank"+ rel="noreferrer noopener"+ >+ View invoice+ </a>+ </TableCell></TableRow>))) : (- <TableRow className='border-b border-white/5'>- <TableCell colSpan={4} className='text-center'>+ <TableRow className="border-b border-white/5">+ <TableCell colSpan={4} className="text-center">No invoices found</TableCell></TableRow>)}</TableBody></Table>-</div>)}@@ -144,23 +182,24 @@ const ManageBilling = () => {const { user } = useUser()const [url, setURL] = useState('')- useEffect(function getBillingURL() {- if (!user) return- const u = `${process.env.NEXT_PUBLIC_STRIPE_BILLING_URL}?prefilled_email=${user.teams[0].email}`- setURL(u)- }, [user])+ useEffect(+ function getBillingURL() {+ if (!user) return+ const u = `${process.env.NEXT_PUBLIC_STRIPE_BILLING_URL}?prefilled_email=${user.teams[0].email}`+ setURL(u)+ },+ [user]+ )if (!user || !url) {return null}return (- <Button variant='secondary' className='w-fit'>+ <Button variant="secondary" className="w-fit"><Link href={url} target="_blank" rel="noreferrer">To billing portal</Link></Button>)}--diff --git a/apps/web/src/components/Dashboard/Developer.tsx b/apps/web/src/components/Dashboard/Developer.tsxnew file mode 100644index 000000000..54425ad0d--- /dev/null+++ b/apps/web/src/components/Dashboard/Developer.tsx@@ -0,0 +1,57 @@+'use client'++import { useToast } from '../ui/use-toast'+import { Button } from '../Button'++export const DeveloperContent = ({+ apiUrlState,+ billingUrlState,+}: {+ apiUrlState: [string, (value: string) => void]+ billingUrlState: [string, (value: string) => void]+}) => {+ const [apiUrl, setApiUrl] = apiUrlState+ const [billingUrl, setBillingUrl] = billingUrlState++ return (+ <div className="flex flex-col w-full h-full">+ <div className="flex flex-col h-full">+ <h1 className="font-bold pb-10 text-xl">Developer settings</h1>++ <span className="font-bold text-neutral-300 pb-2">API URL</span>+ <div className="flex w-full items-center space-x-2 pb-4">+ <input+ type="text"+ className="w-1/2 border border-white/10 text-sm focus:outline-none outline-none rounded-md p-2"+ value={apiUrl}+ onChange={(e) => setApiUrl(e.target.value)}+ />+ <Button+ variant="desctructive"+ onClick={() => setApiUrl(process.env.NEXT_PUBLIC_API_URL || '')}+ >+ Reset to default+ </Button>+ </div>++ <span className="font-bold text-neutral-300 pb-2">Billing URL</span>+ <div className="flex w-full items-center space-x-2 pb-4">+ <input+ type="text"+ className="w-1/2 border border-white/10 text-sm focus:outline-none outline-none rounded-md p-2"+ value={billingUrl}+ onChange={(e) => setBillingUrl(e.target.value)}+ />+ <Button+ variant="desctructive"+ onClick={() =>+ setBillingUrl(process.env.NEXT_PUBLIC_BILLING_API_URL || '')+ }+ >+ Reset to default+ </Button>+ </div>+ </div>+ </div>+ )+}diff --git a/apps/web/src/components/Dashboard/Keys.tsx b/apps/web/src/components/Dashboard/Keys.tsxindex 95fecbcbd..a0a26e13a 100644--- a/apps/web/src/components/Dashboard/Keys.tsx+++ b/apps/web/src/components/Dashboard/Keys.tsx@@ -46,9 +46,11 @@ type TeamApiKey = {export const KeysContent = ({currentTeam,user,+ billingUrl,}: {currentTeam: Teamuser: E2BUser+ billingUrl: string}) => {const { toast } = useToast()const [isKeyDialogOpen, setIsKeyDialogOpen] = useState(false)@@ -61,7 +63,7 @@ export const KeysContent = ({useEffect(() => {async function fetchApiKeys() {const res = await fetch(- `${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams/${currentTeam.id}/api-keys`,+ `${billingUrl}/teams/${currentTeam.id}/api-keys`,{headers: {'X-USER-ACCESS-TOKEN': user.accessToken,@@ -95,7 +97,7 @@ export const KeysContent = ({}const res = await fetch(- `${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams/${currentTeam.id}/api-keys/${currentKey?.id}`,+ `${billingUrl}/teams/${currentTeam.id}/api-keys/${currentKey?.id}`,{method: 'DELETE',headers: {@@ -117,19 +119,16 @@ export const KeysContent = ({}async function createApiKey() {- const res = await fetch(- `${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams/${currentTeam.id}/api-keys`,- {- method: 'POST',- headers: {- 'X-USER-ACCESS-TOKEN': user.accessToken,- 'Content-Type': 'application/json',- },- body: JSON.stringify({- name: newApiKeyInput,- }),- }- )+ const res = await fetch(`${billingUrl}/teams/${currentTeam.id}/api-keys`, {+ method: 'POST',+ headers: {+ 'X-USER-ACCESS-TOKEN': user.accessToken,+ 'Content-Type': 'application/json',+ },+ body: JSON.stringify({+ name: newApiKeyInput,+ }),+ })if (!res.ok) {toast({@@ -150,7 +149,7 @@ export const KeysContent = ({async function updateApiKey() {const res = await fetch(- `${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams/${currentTeam.id}/api-keys/${currentKey?.id}`,+ `${billingUrl}/teams/${currentTeam.id}/api-keys/${currentKey?.id}`,{method: 'PATCH',headers: {diff --git a/apps/web/src/components/Dashboard/Personal.tsx b/apps/web/src/components/Dashboard/Personal.tsxindex 637c0aaf9..673988e20 100644--- a/apps/web/src/components/Dashboard/Personal.tsx+++ b/apps/web/src/components/Dashboard/Personal.tsx@@ -7,9 +7,13 @@ import { useState } from 'react'import { Copy } from 'lucide-react'import { E2BUser } from '@/utils/useUser'-const updateUserUrl = `${process.env.NEXT_PUBLIC_BILLING_API_URL}/users`--export const PersonalContent = ({ user }: { user: E2BUser }) => {+export const PersonalContent = ({+ user,+ billingUrl,+}: {+ user: E2BUser+ billingUrl: string+}) => {const { toast } = useToast()const [hovered, setHovered] = useState<boolean>(false)const [email, setEmail] = useState(user.email)@@ -29,7 +33,7 @@ export const PersonalContent = ({ user }: { user: E2BUser }) => {}const updateUserEmail = async () => {- const res = await fetch(updateUserUrl, {+ const res = await fetch(`${billingUrl}/users`, {method: 'PATCH',headers: {'Content-Type': 'application/json',@@ -37,8 +41,7 @@ export const PersonalContent = ({ user }: { user: E2BUser }) => {},body: JSON.stringify({email,- }- )+ }),})if (!res.ok) {@@ -59,13 +62,10 @@ export const PersonalContent = ({ user }: { user: E2BUser }) => {return (<div className="flex flex-col w-full h-full"><div className="flex flex-col h-full">+ <h1 className="font-bold pb-10 text-xl">Personal settings</h1>- <h1 className="font-bold pb-10 text-xl">- Personal settings- </h1>-- <span className='font-bold text-neutral-300 pb-2'>Email</span>- <div className='flex w-full items-center space-x-2 pb-4'>+ <span className="font-bold text-neutral-300 pb-2">Email</span>+ <div className="flex w-full items-center space-x-2 pb-4"><inputtype="text"className="w-1/2 border border-white/10 text-sm focus:outline-none outline-none rounded-md p-2"@@ -73,11 +73,13 @@ export const PersonalContent = ({ user }: { user: E2BUser }) => {value={email}onChange={(e) => setEmail(e.target.value)}/>- <Button variant='outline' onClick={updateUserEmail}>Save changes</Button>+ <Button variant="outline" onClick={updateUserEmail}>+ Save changes+ </Button></div>- <span className='font-bold text-neutral-300 pb-2'>User ID</span>- <div className='flex items-center space-x-2 pb-4'>+ <span className="font-bold text-neutral-300 pb-2">User ID</span>+ <div className="flex items-center space-x-2 pb-4"><inputreadOnlytype="text"@@ -86,7 +88,7 @@ export const PersonalContent = ({ user }: { user: E2BUser }) => {/></div><span- className='flex pb-10 w-fit text-sm text-orange-500 hover:cursor-pointer hover:text-orange-500/30 space-x-2 items-center'+ className="flex pb-10 w-fit text-sm text-orange-500 hover:cursor-pointer hover:text-orange-500/30 space-x-2 items-center"onClick={() => {navigator.clipboard.writeText(user.id)toast({@@ -95,15 +97,15 @@ export const PersonalContent = ({ user }: { user: E2BUser }) => {}}><p>Copy your user ID</p>- <Copy className='h-4 w-4' />+ <Copy className="h-4 w-4" /></span>-- <span className='font-bold text-neutral-300 pb-2'>Access token</span>- <span className='text-sm text-neutral-300 pb-4'>- This is your personal access token. It is used in CLI (e.g. for building new templates).+ <span className="font-bold text-neutral-300 pb-2">Access token</span>+ <span className="text-sm text-neutral-300 pb-4">+ This is your personal access token. It is used in CLI (e.g. for+ building new templates).</span>- <div className='flex w-full justify-between items-center border border-white/5 rounded-lg p-2 mb-4 space-x-4'>+ <div className="flex w-full justify-between items-center border border-white/5 rounded-lg p-2 mb-4 space-x-4"><divclassName="font-mono cursor-pointer text-xs md:text-sm"onMouseEnter={() => setHovered(true)}@@ -116,24 +118,19 @@ export const PersonalContent = ({ user }: { user: E2BUser }) => {{user.app_metadata.provider === 'email' && (<>- <h1 className="font-bold pb-4 text-xl">- Reset password- </h1>- <span className='text-neutral-300 pb-4'>- Resetting will send an email with a link to reset the password. <br />+ <h1 className="font-bold pb-4 text-xl">Reset password</h1>+ <span className="text-neutral-300 pb-4">+ Resetting will send an email with a link to reset the password.{' '}+ <br /></span>- <div className='flex items-center space-x-2 pb-10'>+ <div className="flex items-center space-x-2 pb-10"><Link href={'/sign-in?view=forgotten-password'}>- <Button variant='desctructive'>- Reset password- </Button>+ <Button variant="desctructive">Reset password</Button></Link></div></>)}-</div></div>)}-diff --git a/apps/web/src/components/Dashboard/Sandboxes.tsx b/apps/web/src/components/Dashboard/Sandboxes.tsxindex b57f5a23b..0a5e7b90e 100644--- a/apps/web/src/components/Dashboard/Sandboxes.tsx+++ b/apps/web/src/components/Dashboard/Sandboxes.tsx@@ -23,14 +23,20 @@ interface Sandbox {templateID: string}-export function SandboxesContent({ team }: { team: Team }) {+export function SandboxesContent({+ team,+ apiUrl,+}: {+ team: Team+ apiUrl: string+}) {const [runningSandboxes, setRunningSandboxes] = useState<Sandbox[]>([])useEffect(() => {function f() {const apiKey = team.apiKeys[0]if (apiKey) {- fetchSandboxes(apiKey).then((newSandboxes) => {+ fetchSandboxes(apiUrl, apiKey).then((newSandboxes) => {if (newSandboxes) {setRunningSandboxes(newSandboxes)}@@ -94,8 +100,11 @@ export function SandboxesContent({ team }: { team: Team }) {)}-async function fetchSandboxes(apiKey: string): Promise<Sandbox[]> {- const res = await fetch('https://api.e2b.dev/sandboxes', {+async function fetchSandboxes(+ apiUrl: string,+ apiKey: string+): Promise<Sandbox[]> {+ const res = await fetch(`${apiUrl}/sandboxes`, {method: 'GET',headers: {'X-API-KEY': apiKey,diff --git a/apps/web/src/components/Dashboard/Team.tsx b/apps/web/src/components/Dashboard/Team.tsxindex c13f9787a..b6283d347 100644--- a/apps/web/src/components/Dashboard/Team.tsx+++ b/apps/web/src/components/Dashboard/Team.tsx@@ -45,12 +45,14 @@ export const TeamContent = ({teams,setTeams,setCurrentTeam,+ billingUrl,}: {team: Teamuser: E2BUserteams: Team[]setTeams: (teams: Team[]) => voidsetCurrentTeam: (team: Team) => void+ billingUrl: string}) => {const [isDialogOpen, setIsDialogOpen] = useState(false)const [currentMemberId, setCurrentMemberId] = useState<string | null>(null)@@ -62,15 +64,12 @@ export const TeamContent = ({useEffect(() => {const getTeamMembers = async () => {- const res = await fetch(- `${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams/${team.id}/users`,- {- headers: {- 'X-User-Access-Token': user.accessToken,- 'X-Team-API-Key': team.apiKeys[0],- },- }- )+ const res = await fetch(`${billingUrl}/teams/${team.id}/users`, {+ headers: {+ 'X-User-Access-Token': user.accessToken,+ 'X-Team-API-Key': team.apiKeys[0],+ },+ })if (!res.ok) {toast({@@ -102,17 +101,14 @@ export const TeamContent = ({}const deleteUserFromTeam = async () => {- const res = await fetch(- `${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams/${team.id}/users`,- {- method: 'DELETE',- headers: {- 'X-User-Access-Token': user.accessToken,- 'Content-Type': 'application/json',- },- body: JSON.stringify({ user_id: currentMemberId }),- }- )+ const res = await fetch(`${billingUrl}/teams/${team.id}/users`, {+ method: 'DELETE',+ headers: {+ 'X-User-Access-Token': user.accessToken,+ 'Content-Type': 'application/json',+ },+ body: JSON.stringify({ user_id: currentMemberId }),+ })if (!res.ok) {toast({@@ -128,17 +124,14 @@ export const TeamContent = ({}const changeTeamName = async () => {- const res = await fetch(- `${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams/${team.id}`,- {- headers: {- 'X-Team-API-Key': team.apiKeys[0],- 'Content-Type': 'application/json',- },- method: 'PATCH',- body: JSON.stringify({ name: teamName }),- }- )+ const res = await fetch(`${billingUrl}/teams/${team.id}`, {+ headers: {+ 'X-Team-API-Key': team.apiKeys[0],+ 'Content-Type': 'application/json',+ },+ method: 'PATCH',+ body: JSON.stringify({ name: teamName }),+ })if (!res.ok) {toast({@@ -168,17 +161,14 @@ export const TeamContent = ({return}- const res = await fetch(- `${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams/${team.id}/users`,- {- headers: {- 'X-User-Access-Token': user.accessToken,- 'Content-Type': 'application/json',- },- method: 'POST',- body: JSON.stringify({ user_email: userToAdd.trim() }),- }- )+ const res = await fetch(`${billingUrl}/teams/${team.id}/users`, {+ headers: {+ 'X-User-Access-Token': user.accessToken,+ 'Content-Type': 'application/json',+ },+ method: 'POST',+ body: JSON.stringify({ user_email: userToAdd.trim() }),+ })if (!res.ok) {toast({diff --git a/apps/web/src/components/Dashboard/Templates.tsx b/apps/web/src/components/Dashboard/Templates.tsxindex 87d157a18..04b645e04 100644--- a/apps/web/src/components/Dashboard/Templates.tsx+++ b/apps/web/src/components/Dashboard/Templates.tsx@@ -23,9 +23,11 @@ interface Template {export function TemplatesContent({user,teamId,+ apiUrl,}: {user: E2BUserteamId: string+ apiUrl: string}) {const [templates, setTemplates] = useState<Template[]>([])@@ -33,7 +35,7 @@ export function TemplatesContent({function f() {const accessToken = user.accessTokenif (accessToken) {- fetchTemplates(accessToken, teamId).then((newTemplates) => {+ fetchTemplates(apiUrl, accessToken, teamId).then((newTemplates) => {if (newTemplates) {setTemplates(newTemplates)}@@ -88,10 +90,11 @@ export function TemplatesContent({}async function fetchTemplates(+ apiUrl: string,accessToken: string,teamId: string): Promise<Template[]> {- const res = await fetch(`https://api.e2b.dev/templates?teamID=${teamId}`, {+ const res = await fetch(`${apiUrl}/templates?teamID=${teamId}`, {method: 'GET',headers: {Authorization: `Bearer ${accessToken}`,diff --git a/apps/web/src/components/Dashboard/Usage.tsx b/apps/web/src/components/Dashboard/Usage.tsxindex 3efe71b5b..af5cfaedf 100644--- a/apps/web/src/components/Dashboard/Usage.tsx+++ b/apps/web/src/components/Dashboard/Usage.tsx@@ -5,7 +5,6 @@ import Spinner from '@/components/Spinner'import { toast } from '@/components/ui/use-toast'import { Team } from '@/utils/useUser'-type Usage = {month: numberyear: number@@ -22,11 +21,21 @@ type Series = {data: PlotData[]}-export const UsageContent = ({ team }: { team: Team }) => {+export const UsageContent = ({+ team,+ billingUrl,+}: {+ team: Team+ billingUrl: string+}) => {const [vcpuData, setVcpuData] = useState<Series[]>([])- const [vcpuHoursThisMonth, setVcpuHoursThisMonth] = useState<number | undefined>()+ const [vcpuHoursThisMonth, setVcpuHoursThisMonth] = useState<+ number | undefined+ >()const [ramData, setRamData] = useState<Series[]>([])- const [ramHoursThisMonth, setRamHoursThisMonth] = useState<number | undefined>()+ const [ramHoursThisMonth, setRamHoursThisMonth] = useState<+ number | undefined+ >()const [costUsage, setCostUsage] = useState<Series[]>([])const [costThisMonth, setCostMonth] = useState<number | undefined>()@@ -36,10 +45,10 @@ export const UsageContent = ({ team }: { team: Team }) => {setRamData([])setCostUsage([])- const response = await fetch( `${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams/${team.id}/usage`, {+ const response = await fetch(`${billingUrl}/teams/${team.id}/usage`, {headers: {- 'X-Team-API-Key': team.apiKeys[0]- }+ 'X-Team-API-Key': team.apiKeys[0],+ },})if (!response.ok) {// TODO: Add sentry event here@@ -70,71 +79,89 @@ export const UsageContent = ({ team }: { team: Team }) => {}, [team])return (- <div className='flex flex-col w-full h-full pb-10'>- <div className='pb-10'>- <h2 className='font-bold pb-4 text-xl'>Usage history</h2>+ <div className="flex flex-col w-full h-full pb-10">+ <div className="pb-10">+ <h2 className="font-bold pb-4 text-xl">Usage history</h2><p>- The graphs show the total monthly vCPU-hours and RAM-hours used by the team. <br />+ The graphs show the total monthly vCPU-hours and RAM-hours used by the+ team. <br /></p></div>- <div className='flex flex-col 2xl:flex-row w-full space-y-4 2xl:space-y-0 2xl:space-x-4'>-- <div className='flex flex-col w-full md:w-2/3'>- <h2 className='font-bold pb-4 text-xl'>Costs in USD</h2>- {costUsage && costUsage.length > 0 ?+ <div className="flex flex-col 2xl:flex-row w-full space-y-4 2xl:space-y-0 2xl:space-x-4">+ <div className="flex flex-col w-full md:w-2/3">+ <h2 className="font-bold pb-4 text-xl">Costs in USD</h2>+ {costUsage && costUsage.length > 0 ? (<div className="flex flex-col space-y-2">- <span className='text-sm text-white/50'>Total costs this month: <b>${costThisMonth?.toFixed(2)}</b></span>- <Card className='w-full bg-inherit/10 border border-white/20 mb-10'>+ <span className="text-sm text-white/50">+ Total costs this month: <b>${costThisMonth?.toFixed(2)}</b>+ </span>+ <Card className="w-full bg-inherit/10 border border-white/20 mb-10"><CardContent>- <LineChart className='aspect-[4/3]' series={costUsage} type='Cost' />+ <LineChart+ className="aspect-[4/3]"+ series={costUsage}+ type="Cost"+ /></CardContent></Card></div>- : (- <div className="flex items-center justify-center w-full">- <Spinner />- </div>- )- }+ ) : (+ <div className="flex items-center justify-center w-full">+ <Spinner />+ </div>+ )}</div>- <div className='flex flex-col w-full md:w-2/3'>- <h2 className='font-bold pb-4 text-xl'>vCPU hours</h2>- {vcpuData && vcpuData.length > 0 ?+ <div className="flex flex-col w-full md:w-2/3">+ <h2 className="font-bold pb-4 text-xl">vCPU hours</h2>+ {vcpuData && vcpuData.length > 0 ? (<div className="flex flex-col space-y-2">- <span className='text-sm text-white/50'>Total vCPU hours this month: <b>{vcpuHoursThisMonth?.toFixed(2)}</b></span>- <Card className='w-full bg-inherit/10 border border-white/20 mb-10'>+ <span className="text-sm text-white/50">+ Total vCPU hours this month:{' '}+ <b>{vcpuHoursThisMonth?.toFixed(2)}</b>+ </span>+ <Card className="w-full bg-inherit/10 border border-white/20 mb-10"><CardContent>- <LineChart className='aspect-[4/3]' series={vcpuData} type='vCPU' />+ <LineChart+ className="aspect-[4/3]"+ series={vcpuData}+ type="vCPU"+ /></CardContent></Card></div>- : (- <div className="flex items-center justify-center w-full">- <Spinner />- </div>- )}+ ) : (+ <div className="flex items-center justify-center w-full">+ <Spinner />+ </div>+ )}</div>- <div className='flex flex-col w-full md:w-2/3'>- <h2 className='font-bold pb-4 text-xl'>RAM hours</h2>- {ramData && ramData.length > 0 ?+ <div className="flex flex-col w-full md:w-2/3">+ <h2 className="font-bold pb-4 text-xl">RAM hours</h2>+ {ramData && ramData.length > 0 ? (<div className="flex flex-col space-y-2">- <span className='text-sm text-white/50'>Total RAM hours this month: <b>{ramHoursThisMonth?.toFixed(2)}</b></span>- <Card className='w-full bg-inherit/10 border border-white/20 mb-10'>+ <span className="text-sm text-white/50">+ Total RAM hours this month:{' '}+ <b>{ramHoursThisMonth?.toFixed(2)}</b>+ </span>+ <Card className="w-full bg-inherit/10 border border-white/20 mb-10"><CardContent>- <LineChart className='aspect-[4/3]' series={ramData} type='RAM' />+ <LineChart+ className="aspect-[4/3]"+ series={ramData}+ type="RAM"+ /></CardContent></Card></div>- : (- <div className="flex items-center justify-center w-full">- <Spinner />- </div>- )}+ ) : (+ <div className="flex items-center justify-center w-full">+ <Spinner />+ </div>+ )}</div>-</div></div>)@@ -144,9 +171,13 @@ const transformCostData = (usage: Usage[]): Series[] => {const costData = usage.map((usage: any) => {return {x: `${String(usage.month).padStart(2, '0')}/${usage.year}`,- y: usage.template_usage.length > 0- ? usage.template_usage.reduce((acc: number, template: any) => acc + template.total_cost, 0)- : 0,+ y:+ usage.template_usage.length > 0+ ? usage.template_usage.reduce(+ (acc: number, template: any) => acc + template.total_cost,+ 0+ )+ : 0,}})@@ -158,22 +189,32 @@ const transformCostData = (usage: Usage[]): Series[] => {]}-const transformData = (usages: any): { vcpuSeries: Series[], ramSeries: Series[] } => {+const transformData = (+ usages: any+): { vcpuSeries: Series[]; ramSeries: Series[] } => {const ramData = usages.map((usage: any) => {return {x: `${String(usage.month).padStart(2, '0')}/${usage.year}`,- y: usage.template_usage.length > 0- ? usage.template_usage.reduce((acc: number, template: any) => acc + template.ram_gb_hours, 0)- : 0,+ y:+ usage.template_usage.length > 0+ ? usage.template_usage.reduce(+ (acc: number, template: any) => acc + template.ram_gb_hours,+ 0+ )+ : 0,}})const vpcData = usages.map((usage: any) => {return {x: `${String(usage.month).padStart(2, '0')}/${usage.year}`,- y: usage.template_usage.length > 0- ? usage.template_usage.reduce((acc: number, template: any) => acc + template.sandbox_hours, 0)- : 0,+ y:+ usage.template_usage.length > 0+ ? usage.template_usage.reduce(+ (acc: number, template: any) => acc + template.sandbox_hours,+ 0+ )+ : 0,}})@@ -192,4 +233,3 @@ const transformData = (usages: any): { vcpuSeries: Series[], ramSeries: Series[]],}}-diff --git a/apps/web/src/components/Pricing/SwitchToProButton.tsx b/apps/web/src/components/Pricing/SwitchToProButton.tsxindex 34eb35201..b0d0aee03 100644--- a/apps/web/src/components/Pricing/SwitchToProButton.tsx+++ b/apps/web/src/components/Pricing/SwitchToProButton.tsx@@ -9,8 +9,7 @@ import Spinner from '@/components/Spinner'import { TierActiveTag } from './TierActiveTag'-const billingApiURL = process.env.NEXT_PUBLIC_BILLING_API_URL-function createCheckout(tierID: string, teamID: string) {+function createCheckout(billingApiURL: string, tierID: string, teamID: string) {return fetch(`${billingApiURL}/checkouts`, {method: 'POST',headers: {@@ -23,7 +22,13 @@ function createCheckout(tierID: string, teamID: string) {})}-function SwitchTierButton({ team }: { team: Team }) {+function SwitchTierButton({+ team,+ billingApiURL,+}: {+ team: Team+ billingApiURL: string+}) {const { user, isLoading } = useUser()const [error, setError] = useState('')@@ -34,7 +39,11 @@ function SwitchTierButton({ team }: { team: Team }) {return setError('You must be logged in to switch to Pro.')}- const response = await createCheckout(tiers.pro.id, user.teams[0].id)+ const response = await createCheckout(+ billingApiURL,+ tiers.pro.id,+ user.teams[0].id+ )const responseData = await response.json()if (responseData.error) {@@ -48,7 +57,6 @@ function SwitchTierButton({ team }: { team: Team }) {return <Spinner />}-if (!user) {return (<Link href="/auth/sign-up">@@ -57,31 +65,25 @@ function SwitchTierButton({ team }: { team: Team }) {)}-// 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 || (team.tier !== tiers.hobby.id && team.tier !== 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">- {team.tier === tiers.pro.id && (- <TierActiveTag />- )}+ {team.tier === tiers.pro.id && <TierActiveTag />}{team.tier !== tiers.pro.id && (- <Button- onClick={createCheckoutSession}- >- Switch to Pro- </Button>+ <Button onClick={createCheckoutSession}>Switch to Pro</Button>)}</div>- {error && (- <span className="text-red-500 font-medium">{error}</span>- )}+ {error && <span className="text-red-500 font-medium">{error}</span>}</div>)}