summaryrefslogtreecommitdiffhomepage
path: root/cloud
diff options
context:
space:
mode:
authorFrank <[email protected]>2025-08-29 19:45:17 -0400
committerFrank <[email protected]>2025-08-29 19:45:17 -0400
commit46927ee9a5830eaf8eaf5bf868a84765586b2b1e (patch)
tree9b2acd7c7a5541368573dbcfdcae2300604cdeec /cloud
parentc3a25eff78635725472096fe2626021ee50f36b0 (diff)
downloadopencode-46927ee9a5830eaf8eaf5bf868a84765586b2b1e.tar.gz
opencode-46927ee9a5830eaf8eaf5bf868a84765586b2b1e.zip
wip: cloud
Diffstat (limited to 'cloud')
-rw-r--r--cloud/app/src/routes/workspace/[id].tsx30
1 files changed, 20 insertions, 10 deletions
diff --git a/cloud/app/src/routes/workspace/[id].tsx b/cloud/app/src/routes/workspace/[id].tsx
index e3eac121b..07f4fc0d0 100644
--- a/cloud/app/src/routes/workspace/[id].tsx
+++ b/cloud/app/src/routes/workspace/[id].tsx
@@ -1,10 +1,12 @@
import { Billing } from "@opencode/cloud-core/billing.js"
import { Key } from "@opencode/cloud-core/key.js"
-import { action, createAsync, revalidate, query, useAction, useSubmission } from "@solidjs/router"
+import { action, createAsync, revalidate, query, useAction, useSubmission, json } from "@solidjs/router"
import { createEffect, createSignal, For, onMount, Show } from "solid-js"
import { getActor } from "~/context/auth"
import { withActor } from "~/context/auth.withActor"
import "./index.css"
+import { User } from "@opencode/cloud-core/user.js"
+import { Actor } from "@opencode/cloud-core/actor.js"
/////////////////////////////////////
// Keys related queries and actions
@@ -17,12 +19,18 @@ const listKeys = query(async () => {
const createKey = action(async (name: string) => {
"use server"
- return withActor(() => Key.create({ name }))
+ return json(
+ withActor(() => Key.create({ name })),
+ { revalidate: "keys" },
+ )
}, "createKey")
const removeKey = action(async (id: string) => {
"use server"
- return withActor(() => Key.remove({ id }))
+ return json(
+ withActor(() => Key.remove({ id })),
+ { revalidate: "keys" },
+ )
}, "removeKey")
/////////////////////////////////////
@@ -32,10 +40,14 @@ const removeKey = action(async (id: string) => {
const getBillingInfo = query(async () => {
"use server"
return withActor(async () => {
- const billing = await Billing.get()
- const payments = await Billing.payments()
- const usage = await Billing.usages()
- return { billing, payments, usage }
+ const actor = Actor.assert("user")
+ const [user, billing, payments, usage] = await Promise.all([
+ User.fromID(actor.properties.userID),
+ Billing.get(),
+ Billing.payments(),
+ Billing.usages(),
+ ])
+ return { user, billing, payments, usage }
})
}, "billingInfo")
@@ -130,7 +142,7 @@ const dummyPaymentData = [
},
]
-export default function() {
+export default function () {
const actor = createAsync(() => getActor())
onMount(() => {
console.log("MOUNTED", actor())
@@ -194,7 +206,6 @@ export default function() {
try {
await createKeyAction(keyName().trim())
- revalidate("keys")
setKeyName("")
setShowCreateForm(false)
} catch (error) {
@@ -209,7 +220,6 @@ export default function() {
try {
await removeKeyAction(keyId)
- revalidate("keys")
} catch (error) {
console.error("Failed to delete API key:", error)
}