Skip to content

armgit / E2B

Public Imported from GitHub
0

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

save progress

ErikKaumk04f114359924
diff --git a/apps/docs/src/app/(main)/dashboard/page.tsx b/apps/docs/src/app/(main)/dashboard/page.tsx
index 6d84c480b..59e170407 100644
--- a/apps/docs/src/app/(main)/dashboard/page.tsx
+++ b/apps/docs/src/app/(main)/dashboard/page.tsx
@@ -1,7 +1,7 @@
'use client'
import { useState } from 'react'
-import { ChevronRight, CreditCard, Key, LucideIcon, PlusCircle, Settings, Users } from 'lucide-react'
+import { BarChart, ChevronRight, CreditCard, Key, LucideIcon, PlusCircle, Settings, Users } from 'lucide-react'
import { GeneralContent } from '@/components/Dashboard/General'
import { BillingContent } from '@/components/Dashboard/Billing'
@@ -17,15 +17,16 @@ import {
import { useUser } from '@/utils/useUser'
import { User } from '@supabase/supabase-js'
import { KeysContent } from '@/components/Dashboard/Keys'
+import { UsageContent } from '@/components/Dashboard/Usage'
// TODO: Sandbox and Templates tab deleted for now
-const menuLabels = ['General', 'Keys' ,'Billing', 'Team',] as const
+const menuLabels = ['General', 'Keys', 'Usage' ,'Billing', 'Team',] as const
type MenuLabel = typeof menuLabels[number]
export default function Dashboard() {
const { user, isLoading, error } = useUser()
- const [selectedItem, setSelectedItem] = useState<MenuLabel>('General')
+ const [selectedItem, setSelectedItem] = useState<MenuLabel>('Billing')
if (error) {
return <div>Error: {error.message}</div>
@@ -64,6 +65,12 @@ const Sidebar = ({ selectedItem, setSelectedItem, user }) => (
selected={selectedItem === 'Keys'}
onClick={() => setSelectedItem('Keys')}
/>
+ <MenuItem
+ icon={BarChart}
+ label="Usage"
+ selected={selectedItem === 'Usage'}
+ onClick={() => setSelectedItem('Usage')}
+ />
<MenuItem
icon={CreditCard}
label="Billing"
@@ -132,6 +139,8 @@ const MainContent = ({ selectedItem, user }: { selectedItem: MenuLabel, user: Us
return <GeneralContent user={user} />
case 'Keys':
return <KeysContent user={user} />
+ case 'Usage':
+ return <UsageContent />
case 'Billing':
return <BillingContent />
case 'Team':
diff --git a/apps/docs/src/components/Dashboard/Billing.tsx b/apps/docs/src/components/Dashboard/Billing.tsx
index 963f0691c..b52cb3ef5 100644
--- a/apps/docs/src/components/Dashboard/Billing.tsx
+++ b/apps/docs/src/components/Dashboard/Billing.tsx
@@ -3,17 +3,20 @@ import Link from 'next/link'
import { useUser } from '@/utils/useUser'
import { Button } from '../Button'
import { useUsage } from '@/utils/useUsage'
+import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '../ui/table'
+import SwitchToHobbyButton from '@/app/(docs)/docs/pricing/SwitchToHobbyButton'
+import SwitchToProButton from '@/app/(docs)/docs/pricing/SwitchToProButton'
function formatCurrency(value: number) {
return value.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
}
export const BillingContent = () => {
- const { credits } = useUsage()
-
+ const { credits, usage } = useUsage()
+
return (
<div className="flex flex-col w-full h-full">
- <div className='flex items-center space-x-4'>
+ <div className='flex items-center space-x-4 pb-10'>
<h2 className='font-bold text-xl'>Make changes to your billing</h2>
<ManageBilling />
</div>
@@ -26,9 +29,60 @@ export const BillingContent = () => {
</div>
)}
+ <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'>
+ <h2>Hobby tier</h2>
+ <SwitchToHobbyButton/>
+ </div>
+ <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>
+ <li>Up to 20 concurrently running sandboxes</li>
+ </ul>
+ </div>
+
+ <div className='flex flex-col items-start justify-center pb-10'>
+ <div className='flex items-center space-x-4'>
+ <h2>Pro tier</h2>
+ <SwitchToProButton/>
+ </div>
+ <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>
+ <li>Up to 20 concurrently running sandboxes</li>
+ </ul>
+ </div>
+
<div>
- <h2 className='font-bold pb-10 text-xl'>Billing history</h2>
+ <h2 className='font-bold pb-4 text-xl'>Billing history</h2>
</div>
+
+ <Table>
+ <TableHeader>
+ <TableRow className='hover:bg-orange-500/10 dark:hover:bg-orange-500/10 border-b border-white/5 '>
+ <TableHead>Date</TableHead>
+ <TableHead>Cost</TableHead>
+ <TableHead>Billed</TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {usage.map((usageItem, index) => (
+ <TableRow
+ className='hover:bg-orange-300/10 dark:hover:bg-orange-300/10 border-b border-white/5'
+ key={index}>
+ <TableCell>{usageItem.month}/{usageItem.year}</TableCell>
+ <TableCell>{usageItem.total_cost}</TableCell>
+ <TableCell>{usageItem.unpaid_cost}</TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
</div>
)
diff --git a/apps/docs/src/components/Dashboard/Chart.tsx b/apps/docs/src/components/Dashboard/Chart.tsx
new file mode 100644
index 000000000..b6806444a
--- /dev/null
+++ b/apps/docs/src/components/Dashboard/Chart.tsx
@@ -0,0 +1,56 @@
+import { ResponsiveBar } from '@nivo/bar'
+
+// If you wonder how to style this chart, I highly recommend this interactive tool: https://nivo.rocks/bar/
+export default function BarChart({ ...props }) {
+ return (
+ <div {...props}>
+ <ResponsiveBar
+ data={[
+ { name: 'Jan', amount: 111 },
+ { name: 'Feb', amount: 157 },
+ { name: 'Mar', amount: 129 },
+ { name: 'Apr', amount: 150 },
+ { name: 'May', amount: 119 },
+ { name: 'Jun', amount: 72 },
+ ]}
+ keys={['amount']}
+ indexBy="name"
+ margin={{ top: 40, right: 40, bottom: 40, left: 40 }}
+ padding={0.2}
+ colors={['#FFAF78']}
+ axisBottom={{
+ tickSize: 0,
+ tickPadding: 16,
+ }}
+ axisLeft={{
+ tickSize: 0,
+ tickValues: 4,
+ tickPadding: 16,
+ }}
+ gridYValues={4}
+ theme={{
+ axis: {
+ ticks: {
+ text: {
+ fill: '#f3f4f6',
+ fontSize: 12,
+ },
+ },
+ },
+ grid: {
+ line: {
+ stroke: '#f3f4f6',
+ },
+ },
+ }}
+ isInteractive={false}
+ borderRadius={4} // Apply a border radius to the top corners of the bars
+ tooltipLabel={({ id }) => `${id}`}
+ enableLabel={true}
+ role="application"
+ ariaLabel="A bar chart showing data"
+ />
+ </div>
+ )
+}
+
diff --git a/apps/docs/src/components/Dashboard/Team.tsx b/apps/docs/src/components/Dashboard/Team.tsx
index 75349654a..3452d0e5b 100644
--- a/apps/docs/src/components/Dashboard/Team.tsx
+++ b/apps/docs/src/components/Dashboard/Team.tsx
@@ -64,6 +64,16 @@ export const TeamContent = () => {
<Button variant='outline'>Save changes</Button>
</div>
+ <h2 className="text-xl font-bold pb-4">Invite new members</h2>
+ <div className='flex items-center space-x-2 pb-10'>
+ <input
+ type="text"
+ className="w-1/3 border border-white/10 text-sm focus:outline-none outline-none rounded-md p-2"
+ placeholder="[email protected]"
+ />
+ <Button variant='outline'>Send invite</Button>
+ </div>
+
<h2 className="text-xl font-bold pb-4">Team members</h2>
<Table>
<TableHeader>
@@ -88,7 +98,6 @@ export const TeamContent = () => {
</TableBody>
</Table>
- <h2 className="text-xl font-bold pt-10 pb-4">Invite new members</h2>
<AlertDialog open={isDialogOpen} onOpenChange={setIsDialogOpen}>
<AlertDialogTrigger asChild>
diff --git a/apps/docs/src/components/Dashboard/Usage.tsx b/apps/docs/src/components/Dashboard/Usage.tsx
index e69de29bb..aee0b35bc 100644
--- a/apps/docs/src/components/Dashboard/Usage.tsx
+++ b/apps/docs/src/components/Dashboard/Usage.tsx
@@ -0,0 +1,20 @@
+import { Card, CardContent } from '../ui/card'
+import BarChart from './Chart'
+
+
+export const UsageContent = () => {
+
+ return (
+ <div className="flex flex-col w-full h-full">
+ <div>
+ <h2 className='font-bold pb-10 text-xl'>Usage history</h2>
+ </div>
+
+ <Card className="w-2/3 bg-inherit/10 border border-white/20">
+ <CardContent>
+ <BarChart className="aspect-[4/3]"/>
+ </CardContent>
+ </Card>
+ </div>
+ )
+}
\ No newline at end of file
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 4f7dddda3..6446b44fd 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -5826,7 +5826,7 @@ packages:
eslint: 8.49.0
eslint-import-resolver-node: 0.3.9
eslint-import-resolver-typescript: 3.6.0(@typescript-eslint/[email protected])([email protected])([email protected])([email protected])
- eslint-plugin-import: 2.28.1(@typescript-eslint/[email protected])([email protected])
+ eslint-plugin-import: 2.28.1(@typescript-eslint/[email protected])([email protected])([email protected])
eslint-plugin-jsx-a11y: 6.7.1([email protected])
eslint-plugin-react: 7.33.2([email protected])
eslint-plugin-react-hooks: 4.6.0([email protected])
@@ -5857,7 +5857,7 @@ packages:
enhanced-resolve: 5.15.0
eslint: 8.49.0
eslint-module-utils: 2.8.0(@typescript-eslint/[email protected])([email protected])([email protected])([email protected])
- eslint-plugin-import: 2.28.1(@typescript-eslint/[email protected])([email protected])
+ eslint-plugin-import: 2.28.1(@typescript-eslint/[email protected])([email protected])([email protected])
fast-glob: 3.3.1
get-tsconfig: 4.7.0
is-core-module: 2.13.0
@@ -5899,36 +5899,7 @@ packages:
- supports-color
dev: true
- resolution: {integrity: sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw==}
- engines: {node: '>=4'}
- peerDependencies:
- '@typescript-eslint/parser': '*'
- eslint: '*'
- eslint-import-resolver-node: '*'
- eslint-import-resolver-typescript: '*'
- eslint-import-resolver-webpack: '*'
- peerDependenciesMeta:
- '@typescript-eslint/parser':
- optional: true
- eslint:
- optional: true
- eslint-import-resolver-node:
- optional: true
- eslint-import-resolver-typescript:
- optional: true
- eslint-import-resolver-webpack:
- optional: true
- dependencies:
- '@typescript-eslint/parser': 6.7.2([email protected])([email protected])
- debug: 3.2.7
- eslint: 8.49.0
- eslint-import-resolver-node: 0.3.9
- transitivePeerDependencies:
- - supports-color
- dev: true
-
resolution: {integrity: sha512-9I9hFlITvOV55alzoKBI+K9q74kv0iKMeY6av5+umsNwayt59fz692daGyjR+oStBQgx6nwR9rXldDev3Clw+A==}
engines: {node: '>=4'}
peerDependencies:
@@ -5938,7 +5909,7 @@ packages:
'@typescript-eslint/parser':
optional: true
dependencies:
- '@typescript-eslint/parser': 6.7.2([email protected])([email protected])
+ '@typescript-eslint/parser': 6.7.2([email protected])([email protected])
array-includes: 3.1.7
array.prototype.findlastindex: 1.2.3
array.prototype.flat: 1.3.2
@@ -5947,7 +5918,7 @@ packages:
doctrine: 2.1.0
eslint: 8.49.0
eslint-import-resolver-node: 0.3.9
- eslint-module-utils: 2.8.0(@typescript-eslint/[email protected])([email protected])([email protected])
+ eslint-module-utils: 2.8.0(@typescript-eslint/[email protected])([email protected])([email protected])([email protected])
has: 1.0.3
is-core-module: 2.13.0
is-glob: 4.0.3
@@ -7455,7 +7426,7 @@ packages:
resolution: {integrity: sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==}
engines: {node: '>= 10.13.0'}
dependencies:
- '@types/node': 20.12.12
+ '@types/node': 20.6.3
merge-stream: 2.0.0
supports-color: 8.1.1
dev: false