Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Refactor usage
Jakub Novak5b8b9e8a7b1d
diff --git a/apps/docs/src/app/usage/Credits.tsx b/apps/docs/src/app/usage/Credits.tsxindex 5de244a12..a80857dd9 100644--- a/apps/docs/src/app/usage/Credits.tsx+++ b/apps/docs/src/app/usage/Credits.tsx@@ -42,7 +42,7 @@ function Credits() {<span className="text-sm">Will be used when generating invoice</span>{isLoading && <SpinnerIcon />}{!isLoading && (- <span className="text-sm font-mono text-green-300/80">${credits}</span>+ <span className="text-sm font-mono text-green-300/80">${formatCurrency(credits)}</span>)}</div>diff --git a/apps/docs/src/utils/useUsage.tsx b/apps/docs/src/utils/useUsage.tsxindex 8b11bdc9f..cc2e6cf42 100644--- a/apps/docs/src/utils/useUsage.tsx+++ b/apps/docs/src/utils/useUsage.tsx@@ -17,7 +17,6 @@ export interface MonthlyCosts {}const usageUrl = `${process.env.NEXT_PUBLIC_BILLING_API_URL}/usage`-const creditsUrl = `${process.env.NEXT_PUBLIC_BILLING_API_URL}/credits`export function useUsage() {const { user } = useUser()@@ -34,24 +33,15 @@ export function useUsage() {if (teams.length === 0) returnif (!apiKey) return- const [- { credits: c },- u,- ] = await Promise.all([- fetch(creditsUrl, {- headers: {- 'X-Team-API-Key': apiKey,- },- }).then(res => res.json()),+ const teamUsage = awaitfetch(usageUrl, {headers: {'X-Team-API-Key': apiKey,},- }).then(res => res.json()),- ])+ }).then(res => res.json())- setCredits(c)- setUsage(u)+ setCredits(teamUsage.credits)+ setUsage(teamUsage.usages as MonthlyCosts[])setIsLoading(false)}, [user, supabase, apiKey])