From 4d81f90dded0ad3d57a75c880c919e6809087948 Mon Sep 17 00:00:00 2001 From: Jay V Date: Thu, 28 Aug 2025 17:10:41 -0400 Subject: [PATCH] ignore: cloud --- cloud/app/src/context/auth.tsx | 37 ++++++++----------- cloud/app/src/routes/index.tsx | 3 +- .../routes/{ => workspace}/[workspaceID].tsx | 9 +++-- 3 files changed, 22 insertions(+), 27 deletions(-) rename cloud/app/src/routes/{ => workspace}/[workspaceID].tsx (97%) diff --git a/cloud/app/src/context/auth.tsx b/cloud/app/src/context/auth.tsx index afcd3fea..59fbff6e 100644 --- a/cloud/app/src/context/auth.tsx +++ b/cloud/app/src/context/auth.tsx @@ -1,5 +1,3 @@ - - import { useSession } from "vinxi/http" import { createClient } from "@openauthjs/openauth/client" import { getRequestEvent } from "solid-js/web" @@ -20,7 +18,7 @@ export const getActor = query(async (): Promise => { const evt = getRequestEvent() const url = new URL(evt!.request.headers.get("referer") ?? evt!.request.url) const auth = await useAuthSession() - const [workspaceHint] = url.pathname.split("/").filter((x) => x.length > 0) + const [, workspaceHint] = url.pathname.split("/").filter((x) => x.length > 0) if (!workspaceHint) { if (auth.data.current) { const current = auth.data.account[auth.data.current] @@ -34,7 +32,7 @@ export const getActor = query(async (): Promise => { } if (Object.keys(auth.data.account ?? {}).length > 0) { const current = Object.values(auth.data.account)[0] - await auth.update(val => ({ + await auth.update((val) => ({ ...val, current: current.id, })) @@ -53,18 +51,14 @@ export const getActor = query(async (): Promise => { } const accounts = Object.keys(auth.data.account) const result = await Database.transaction(async (tx) => { - return await tx.select({ - user: UserTable - }) + return await tx + .select({ + user: UserTable, + }) .from(AccountTable) .innerJoin(UserTable, and(eq(UserTable.email, AccountTable.email))) .innerJoin(WorkspaceTable, eq(WorkspaceTable.id, UserTable.workspaceID)) - .where( - and( - inArray(AccountTable.id, accounts), - eq(WorkspaceTable.id, workspaceHint), - ) - ) + .where(and(inArray(AccountTable.id, accounts), eq(WorkspaceTable.id, workspaceHint))) .limit(1) .execute() .then((x) => x[0]) @@ -81,17 +75,19 @@ export const getActor = query(async (): Promise => { throw redirect("/auth/authorize") }, "actor") - export const AuthClient = createClient({ clientID: "app", issuer: import.meta.env.VITE_AUTH_URL, }) export interface AuthSession { - account: Record + account: Record< + string, + { + id: string + email: string + } + > current?: string } @@ -106,7 +102,4 @@ export function useAuthSession() { }) } - -export function AuthProvider() { -} - +export function AuthProvider() { } diff --git a/cloud/app/src/routes/index.tsx b/cloud/app/src/routes/index.tsx index 7f8433e7..7a43f262 100644 --- a/cloud/app/src/routes/index.tsx +++ b/cloud/app/src/routes/index.tsx @@ -23,9 +23,10 @@ function CopyStatus() { const isLoggedIn = query(async () => { "use server" const actor = await getActor() + console.log(actor) if (actor.type === "account") { const workspaces = await withActor(() => Account.workspaces()) - throw redirect("/" + workspaces[0].id) + throw redirect(`/workspace/${workspaces[0].id}`) } return false }, "isLoggedIn") diff --git a/cloud/app/src/routes/[workspaceID].tsx b/cloud/app/src/routes/workspace/[workspaceID].tsx similarity index 97% rename from cloud/app/src/routes/[workspaceID].tsx rename to cloud/app/src/routes/workspace/[workspaceID].tsx index 1afcc979..00e61a0c 100644 --- a/cloud/app/src/routes/[workspaceID].tsx +++ b/cloud/app/src/routes/workspace/[workspaceID].tsx @@ -42,11 +42,12 @@ const createCheckoutUrl = action(async (successUrl: string, cancelUrl: string) = return withActor(() => Billing.generateCheckoutUrl({ successUrl, cancelUrl })) }, "checkoutUrl") -//export const route = { -// preload: () => listKeys(), -//} +const createPortalUrl = action(async (returnUrl: string) => { + "use server" + return withActor(() => Billing.generatePortalUrl({ returnUrl })) +}, "portalUrl") -export default function () { +export default function() { const actor = createAsync(() => getActor()) /////////////////