mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-27 20:54:21 +01:00
wip: zen
This commit is contained in:
@@ -177,10 +177,35 @@
|
|||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
font-size: var(--font-size-md);
|
font-size: var(--font-size-md);
|
||||||
color: var(--color-text-muted);
|
color: var(--color-text-muted);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: var(--space-4);
|
||||||
|
|
||||||
|
@media (max-width: 48rem) {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: var(--space-3);
|
||||||
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: var(--color-text-muted);
|
color: var(--color-text-muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[data-slot="billing-info"] {
|
||||||
|
flex-shrink: 0;
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-slot="balance"] {
|
||||||
|
font-size: var(--font-size-sm);
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
|
||||||
|
b {
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--color-text);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,24 +3,58 @@ import { UsageSection } from "./usage-section"
|
|||||||
import { ModelSection } from "./model-section"
|
import { ModelSection } from "./model-section"
|
||||||
import { ProviderSection } from "./provider-section"
|
import { ProviderSection } from "./provider-section"
|
||||||
import { IconLogo } from "~/component/icon"
|
import { IconLogo } from "~/component/icon"
|
||||||
import { createAsync, useParams } from "@solidjs/router"
|
import { createAsync, useParams, useAction, useSubmission } from "@solidjs/router"
|
||||||
import { querySessionInfo } from "../common"
|
import { querySessionInfo, queryBillingInfo, createCheckoutUrl } from "../common"
|
||||||
import { Show } from "solid-js"
|
import { Show, createMemo } from "solid-js"
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
const params = useParams()
|
const params = useParams()
|
||||||
const userInfo = createAsync(() => querySessionInfo(params.id))
|
const userInfo = createAsync(() => querySessionInfo(params.id))
|
||||||
|
const billingInfo = createAsync(() => queryBillingInfo(params.id))
|
||||||
|
const createCheckoutUrlAction = useAction(createCheckoutUrl)
|
||||||
|
const createCheckoutUrlSubmission = useSubmission(createCheckoutUrl)
|
||||||
|
|
||||||
|
const balanceAmount = createMemo(() => {
|
||||||
|
return ((billingInfo()?.balance ?? 0) / 100000000).toFixed(2)
|
||||||
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div data-page="workspace-[id]">
|
<div data-page="workspace-[id]">
|
||||||
<section data-component="header-section">
|
<section data-component="header-section">
|
||||||
<IconLogo />
|
<IconLogo />
|
||||||
<p>
|
<p>
|
||||||
Curated list of models provided by opencode.{" "}
|
<span>
|
||||||
<a target="_blank" href="/docs/zen">
|
Reliable optimized models for coding agents.{" "}
|
||||||
Learn more
|
<a target="_blank" href="/docs/zen">
|
||||||
</a>
|
Learn more
|
||||||
.
|
</a>
|
||||||
|
.
|
||||||
|
</span>
|
||||||
|
<span data-slot="billing-info">
|
||||||
|
<Show
|
||||||
|
when={billingInfo()?.reload}
|
||||||
|
fallback={
|
||||||
|
<button
|
||||||
|
data-color="primary"
|
||||||
|
data-size="sm"
|
||||||
|
disabled={createCheckoutUrlSubmission.pending}
|
||||||
|
onClick={async () => {
|
||||||
|
const baseUrl = window.location.href
|
||||||
|
const checkoutUrl = await createCheckoutUrlAction(params.id, baseUrl, baseUrl)
|
||||||
|
if (checkoutUrl) {
|
||||||
|
window.location.href = checkoutUrl
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{createCheckoutUrlSubmission.pending ? "Loading..." : "Enable billing"}
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<span data-slot="balance">
|
||||||
|
Current balance: <b>${balanceAmount() === "-0.00" ? "0.00" : balanceAmount()}</b>
|
||||||
|
</span>
|
||||||
|
</Show>
|
||||||
|
</span>
|
||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|||||||
@@ -44,3 +44,8 @@ export const createCheckoutUrl = action(async (workspaceID: string, successUrl:
|
|||||||
"use server"
|
"use server"
|
||||||
return withActor(() => Billing.generateCheckoutUrl({ successUrl, cancelUrl }), workspaceID)
|
return withActor(() => Billing.generateCheckoutUrl({ successUrl, cancelUrl }), workspaceID)
|
||||||
}, "checkoutUrl")
|
}, "checkoutUrl")
|
||||||
|
|
||||||
|
export const queryBillingInfo = query(async (workspaceID: string) => {
|
||||||
|
"use server"
|
||||||
|
return withActor(() => Billing.get(), workspaceID)
|
||||||
|
}, "billing.get")
|
||||||
|
|||||||
Reference in New Issue
Block a user