diff options
| author | GitHub Action <[email protected]> | 2026-01-22 18:17:10 +0000 |
|---|---|---|
| committer | GitHub Action <[email protected]> | 2026-01-22 18:17:10 +0000 |
| commit | 5a4eec5b08be6c36561fa06f056a330d3b402b34 (patch) | |
| tree | aa1e158844fd361b81157a9444bc2f6b1a49924a /packages/console | |
| parent | e17b8756412f293b2383c29583339eb0a7d25ce3 (diff) | |
| download | opencode-5a4eec5b08be6c36561fa06f056a330d3b402b34.tar.gz opencode-5a4eec5b08be6c36561fa06f056a330d3b402b34.zip | |
chore: generate
Diffstat (limited to 'packages/console')
| -rw-r--r-- | packages/console/app/src/routes/workspace/[id]/billing/black-section.tsx | 60 | ||||
| -rw-r--r-- | packages/console/core/script/lookup-user.ts | 10 | ||||
| -rw-r--r-- | packages/console/core/src/black.ts | 15 |
3 files changed, 47 insertions, 38 deletions
diff --git a/packages/console/app/src/routes/workspace/[id]/billing/black-section.tsx b/packages/console/app/src/routes/workspace/[id]/billing/black-section.tsx index 448dafadc..98d4debbb 100644 --- a/packages/console/app/src/routes/workspace/[id]/billing/black-section.tsx +++ b/packages/console/app/src/routes/workspace/[id]/billing/black-section.tsx @@ -97,41 +97,41 @@ export function BlackSection() { <Show when={subscription()}> {(sub) => ( <> - <div data-slot="section-title"> - <h2>Subscription</h2> - <div data-slot="title-row"> - <p>You are subscribed to OpenCode Black for ${sub().plan} per month.</p> - <button - data-color="primary" - disabled={sessionSubmission.pending || store.sessionRedirecting} - onClick={onClickSession} - > - {sessionSubmission.pending || store.sessionRedirecting ? "Loading..." : "Manage Subscription"} - </button> - </div> - </div> - <div data-slot="usage"> - <div data-slot="usage-item"> - <div data-slot="usage-header"> - <span data-slot="usage-label">5-hour Usage</span> - <span data-slot="usage-value">{sub().rollingUsage.usagePercent}%</span> + <div data-slot="section-title"> + <h2>Subscription</h2> + <div data-slot="title-row"> + <p>You are subscribed to OpenCode Black for ${sub().plan} per month.</p> + <button + data-color="primary" + disabled={sessionSubmission.pending || store.sessionRedirecting} + onClick={onClickSession} + > + {sessionSubmission.pending || store.sessionRedirecting ? "Loading..." : "Manage Subscription"} + </button> </div> - <div data-slot="progress"> - <div data-slot="progress-bar" style={{ width: `${sub().rollingUsage.usagePercent}%` }} /> - </div> - <span data-slot="reset-time">Resets in {formatResetTime(sub().rollingUsage.resetInSec)}</span> </div> - <div data-slot="usage-item"> - <div data-slot="usage-header"> - <span data-slot="usage-label">Weekly Usage</span> - <span data-slot="usage-value">{sub().weeklyUsage.usagePercent}%</span> + <div data-slot="usage"> + <div data-slot="usage-item"> + <div data-slot="usage-header"> + <span data-slot="usage-label">5-hour Usage</span> + <span data-slot="usage-value">{sub().rollingUsage.usagePercent}%</span> + </div> + <div data-slot="progress"> + <div data-slot="progress-bar" style={{ width: `${sub().rollingUsage.usagePercent}%` }} /> + </div> + <span data-slot="reset-time">Resets in {formatResetTime(sub().rollingUsage.resetInSec)}</span> </div> - <div data-slot="progress"> - <div data-slot="progress-bar" style={{ width: `${sub().weeklyUsage.usagePercent}%` }} /> + <div data-slot="usage-item"> + <div data-slot="usage-header"> + <span data-slot="usage-label">Weekly Usage</span> + <span data-slot="usage-value">{sub().weeklyUsage.usagePercent}%</span> + </div> + <div data-slot="progress"> + <div data-slot="progress-bar" style={{ width: `${sub().weeklyUsage.usagePercent}%` }} /> + </div> + <span data-slot="reset-time">Resets in {formatResetTime(sub().weeklyUsage.resetInSec)}</span> </div> - <span data-slot="reset-time">Resets in {formatResetTime(sub().weeklyUsage.resetInSec)}</span> </div> - </div> </> )} </Show> diff --git a/packages/console/core/script/lookup-user.ts b/packages/console/core/script/lookup-user.ts index 355716d1d..6c76d42c9 100644 --- a/packages/console/core/script/lookup-user.ts +++ b/packages/console/core/script/lookup-user.ts @@ -1,7 +1,13 @@ import { Database, and, eq, sql } from "../src/drizzle/index.js" import { AuthTable } from "../src/schema/auth.sql.js" import { UserTable } from "../src/schema/user.sql.js" -import { BillingTable, PaymentTable, SubscriptionTable, SubscriptionPlan, UsageTable } from "../src/schema/billing.sql.js" +import { + BillingTable, + PaymentTable, + SubscriptionTable, + SubscriptionPlan, + UsageTable, +} from "../src/schema/billing.sql.js" import { WorkspaceTable } from "../src/schema/workspace.sql.js" import { BlackData } from "../src/black.js" import { centsToMicroCents } from "../src/util/price.js" @@ -226,7 +232,7 @@ function formatRetryTime(seconds: number) { function getSubscriptionStatus(row: { subscription: { - plan: typeof SubscriptionPlan[number] + plan: (typeof SubscriptionPlan)[number] } | null timeSubscriptionCreated: Date | null fixedUsage: number | null diff --git a/packages/console/core/src/black.ts b/packages/console/core/src/black.ts index 85e16f1a1..13314a62d 100644 --- a/packages/console/core/src/black.ts +++ b/packages/console/core/src/black.ts @@ -28,12 +28,15 @@ export namespace BlackData { return input }) - export const get = fn(z.object({ + export const get = fn( + z.object({ plan: z.enum(SubscriptionPlan), - }), ({ plan }) => { - const json = JSON.parse(Resource.ZEN_BLACK_LIMITS.value) - return Schema.parse(json)[plan] - }) + }), + ({ plan }) => { + const json = JSON.parse(Resource.ZEN_BLACK_LIMITS.value) + return Schema.parse(json)[plan] + }, + ) } export namespace Black { @@ -75,7 +78,7 @@ export namespace Black { export const analyzeWeeklyUsage = fn( z.object({ - plan:z.enum(SubscriptionPlan), + plan: z.enum(SubscriptionPlan), usage: z.number().int(), timeUpdated: z.date(), }), |
