diff options
| author | Frank <[email protected]> | 2026-01-07 01:55:36 -0500 |
|---|---|---|
| committer | Frank <[email protected]> | 2026-01-07 02:45:57 -0500 |
| commit | e91cc7e5142ea6568836c463de69b06d35fc3fc3 (patch) | |
| tree | b4b2f54d1d24eca9c1630425045270e229f184ab /packages/console/app/src/routes/workspace | |
| parent | c961072d20f1dcafa5e608a1f28a79a1b6bc7334 (diff) | |
| download | opencode-e91cc7e5142ea6568836c463de69b06d35fc3fc3.tar.gz opencode-e91cc7e5142ea6568836c463de69b06d35fc3fc3.zip | |
wip: black
Diffstat (limited to 'packages/console/app/src/routes/workspace')
| -rw-r--r-- | packages/console/app/src/routes/workspace/[id]/billing/black-section.module.css | 6 | ||||
| -rw-r--r-- | packages/console/app/src/routes/workspace/[id]/billing/black-section.tsx | 50 |
2 files changed, 54 insertions, 2 deletions
diff --git a/packages/console/app/src/routes/workspace/[id]/billing/black-section.module.css b/packages/console/app/src/routes/workspace/[id]/billing/black-section.module.css index c3a2af639..c189f0d64 100644 --- a/packages/console/app/src/routes/workspace/[id]/billing/black-section.module.css +++ b/packages/console/app/src/routes/workspace/[id]/billing/black-section.module.css @@ -1,2 +1,8 @@ .root { + [data-slot="title-row"] { + display: flex; + justify-content: space-between; + align-items: center; + gap: var(--space-4); + } } 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 d4876b242..2eece1b62 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 @@ -1,11 +1,57 @@ +import { action, useParams, useAction, useSubmission, json } from "@solidjs/router" +import { createStore } from "solid-js/store" +import { Billing } from "@opencode-ai/console-core/billing.js" +import { withActor } from "~/context/auth.withActor" +import { queryBillingInfo } from "../../common" import styles from "./black-section.module.css" +const createSessionUrl = action(async (workspaceID: string, returnUrl: string) => { + "use server" + return json( + await withActor( + () => + Billing.generateSessionUrl({ returnUrl }) + .then((data) => ({ error: undefined, data })) + .catch((e) => ({ + error: e.message as string, + data: undefined, + })), + workspaceID, + ), + { revalidate: queryBillingInfo.key }, + ) +}, "sessionUrl") + export function BlackSection() { + const params = useParams() + const sessionAction = useAction(createSessionUrl) + const sessionSubmission = useSubmission(createSessionUrl) + const [store, setStore] = createStore({ + sessionRedirecting: false, + }) + + async function onClickSession() { + const result = await sessionAction(params.id!, window.location.href) + if (result.data) { + setStore("sessionRedirecting", true) + window.location.href = result.data + } + } + return ( <section class={styles.root}> <div data-slot="section-title"> - <h2>Black</h2> - <p>You are subscribed to Black.</p> + <h2>Subscription</h2> + <div data-slot="title-row"> + <p>You are subscribed to OpenCode Black for $200 per month.</p> + <button + data-color="primary" + disabled={sessionSubmission.pending || store.sessionRedirecting} + onClick={onClickSession} + > + {sessionSubmission.pending || store.sessionRedirecting ? "Loading..." : "Manage Subscription"} + </button> + </div> </div> </section> ) |
