chore: generate
This commit is contained in:
@@ -109,9 +109,9 @@ const zenPriceProps = {
|
|||||||
intervalCount: 1,
|
intervalCount: 1,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
const zenPrice200 = new stripe.Price("ZenBlackPrice", { ...zenPriceProps, unitAmount: 20000, })
|
const zenPrice200 = new stripe.Price("ZenBlackPrice", { ...zenPriceProps, unitAmount: 20000 })
|
||||||
const zenPrice100 = new stripe.Price("ZenBlack100Price", { ...zenPriceProps, unitAmount: 10000, })
|
const zenPrice100 = new stripe.Price("ZenBlack100Price", { ...zenPriceProps, unitAmount: 10000 })
|
||||||
const zenPrice20 = new stripe.Price("ZenBlack20Price", { ...zenPriceProps, unitAmount: 2000, })
|
const zenPrice20 = new stripe.Price("ZenBlack20Price", { ...zenPriceProps, unitAmount: 2000 })
|
||||||
const ZEN_BLACK_PRICE = new sst.Linkable("ZEN_BLACK_PRICE", {
|
const ZEN_BLACK_PRICE = new sst.Linkable("ZEN_BLACK_PRICE", {
|
||||||
properties: {
|
properties: {
|
||||||
product: zenProduct.id,
|
product: zenProduct.id,
|
||||||
|
|||||||
@@ -97,41 +97,41 @@ export function BlackSection() {
|
|||||||
<Show when={subscription()}>
|
<Show when={subscription()}>
|
||||||
{(sub) => (
|
{(sub) => (
|
||||||
<>
|
<>
|
||||||
<div data-slot="section-title">
|
<div data-slot="section-title">
|
||||||
<h2>Subscription</h2>
|
<h2>Subscription</h2>
|
||||||
<div data-slot="title-row">
|
<div data-slot="title-row">
|
||||||
<p>You are subscribed to OpenCode Black for ${sub().plan} per month.</p>
|
<p>You are subscribed to OpenCode Black for ${sub().plan} per month.</p>
|
||||||
<button
|
<button
|
||||||
data-color="primary"
|
data-color="primary"
|
||||||
disabled={sessionSubmission.pending || store.sessionRedirecting}
|
disabled={sessionSubmission.pending || store.sessionRedirecting}
|
||||||
onClick={onClickSession}
|
onClick={onClickSession}
|
||||||
>
|
>
|
||||||
{sessionSubmission.pending || store.sessionRedirecting ? "Loading..." : "Manage Subscription"}
|
{sessionSubmission.pending || store.sessionRedirecting ? "Loading..." : "Manage Subscription"}
|
||||||
</button>
|
</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>
|
</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>
|
||||||
<div data-slot="usage-item">
|
<div data-slot="usage">
|
||||||
<div data-slot="usage-header">
|
<div data-slot="usage-item">
|
||||||
<span data-slot="usage-label">Weekly Usage</span>
|
<div data-slot="usage-header">
|
||||||
<span data-slot="usage-value">{sub().weeklyUsage.usagePercent}%</span>
|
<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>
|
||||||
<div data-slot="progress">
|
<div data-slot="usage-item">
|
||||||
<div data-slot="progress-bar" style={{ width: `${sub().weeklyUsage.usagePercent}%` }} />
|
<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>
|
</div>
|
||||||
<span data-slot="reset-time">Resets in {formatResetTime(sub().weeklyUsage.resetInSec)}</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Show>
|
</Show>
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
import { Database, and, eq, sql } from "../src/drizzle/index.js"
|
import { Database, and, eq, sql } from "../src/drizzle/index.js"
|
||||||
import { AuthTable } from "../src/schema/auth.sql.js"
|
import { AuthTable } from "../src/schema/auth.sql.js"
|
||||||
import { UserTable } from "../src/schema/user.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 { WorkspaceTable } from "../src/schema/workspace.sql.js"
|
||||||
import { BlackData } from "../src/black.js"
|
import { BlackData } from "../src/black.js"
|
||||||
import { centsToMicroCents } from "../src/util/price.js"
|
import { centsToMicroCents } from "../src/util/price.js"
|
||||||
@@ -226,7 +232,7 @@ function formatRetryTime(seconds: number) {
|
|||||||
|
|
||||||
function getSubscriptionStatus(row: {
|
function getSubscriptionStatus(row: {
|
||||||
subscription: {
|
subscription: {
|
||||||
plan: typeof SubscriptionPlan[number]
|
plan: (typeof SubscriptionPlan)[number]
|
||||||
} | null
|
} | null
|
||||||
timeSubscriptionCreated: Date | null
|
timeSubscriptionCreated: Date | null
|
||||||
fixedUsage: number | null
|
fixedUsage: number | null
|
||||||
|
|||||||
@@ -28,12 +28,15 @@ export namespace BlackData {
|
|||||||
return input
|
return input
|
||||||
})
|
})
|
||||||
|
|
||||||
export const get = fn(z.object({
|
export const get = fn(
|
||||||
|
z.object({
|
||||||
plan: z.enum(SubscriptionPlan),
|
plan: z.enum(SubscriptionPlan),
|
||||||
}), ({ plan }) => {
|
}),
|
||||||
const json = JSON.parse(Resource.ZEN_BLACK_LIMITS.value)
|
({ plan }) => {
|
||||||
return Schema.parse(json)[plan]
|
const json = JSON.parse(Resource.ZEN_BLACK_LIMITS.value)
|
||||||
})
|
return Schema.parse(json)[plan]
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace Black {
|
export namespace Black {
|
||||||
@@ -75,7 +78,7 @@ export namespace Black {
|
|||||||
|
|
||||||
export const analyzeWeeklyUsage = fn(
|
export const analyzeWeeklyUsage = fn(
|
||||||
z.object({
|
z.object({
|
||||||
plan:z.enum(SubscriptionPlan),
|
plan: z.enum(SubscriptionPlan),
|
||||||
usage: z.number().int(),
|
usage: z.number().int(),
|
||||||
timeUpdated: z.date(),
|
timeUpdated: z.date(),
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user