diff options
| author | Frank <[email protected]> | 2025-08-29 23:02:27 -0400 |
|---|---|---|
| committer | Frank <[email protected]> | 2025-08-29 23:02:27 -0400 |
| commit | 0178eab29bda2f1b37a29543cd313ede48ad3977 (patch) | |
| tree | a0c9f40fc800875e9276f27fc90bcd842888654f /cloud | |
| parent | a3f4a030b4f6e94dc11dc3ce93f6f37620982cc6 (diff) | |
| download | opencode-0178eab29bda2f1b37a29543cd313ede48ad3977.tar.gz opencode-0178eab29bda2f1b37a29543cd313ede48ad3977.zip | |
wip cloud
Diffstat (limited to 'cloud')
| -rw-r--r-- | cloud/app/src/routes/workspace/[id].tsx | 34 |
1 files changed, 4 insertions, 30 deletions
diff --git a/cloud/app/src/routes/workspace/[id].tsx b/cloud/app/src/routes/workspace/[id].tsx index cf6c0bdd2..65b2a3887 100644 --- a/cloud/app/src/routes/workspace/[id].tsx +++ b/cloud/app/src/routes/workspace/[id].tsx @@ -265,44 +265,18 @@ export default function() { // Billing section ///////////////// const billingInfo = createAsync(() => getBillingInfo()) - const [isLoading, setIsLoading] = createSignal(false) const createCheckoutUrlAction = useAction(createCheckoutUrl) - - // Run once on component mount to check URL parameters - onMount(() => { - const url = new URL(window.location.href) - const result = url.hash - - console.log("STRIPE RESULT", result) - - if (url.hash === "#success") { - setIsLoading(true) - // Remove the hash from the URL - window.history.replaceState(null, "", window.location.pathname + window.location.search) - } - }) - - createEffect((old?: number) => { - if (old && old !== billingInfo()?.billing?.balance) { - setIsLoading(false) - } - return billingInfo()?.billing?.balance - }) + const createCheckoutUrlSubmission = useSubmission(createCheckoutUrl) const handleBuyCredits = async () => { try { - setIsLoading(true) const baseUrl = window.location.href - const successUrl = new URL(baseUrl) - successUrl.hash = "success" - - const checkoutUrl = await createCheckoutUrlAction(successUrl.toString(), baseUrl) + const checkoutUrl = await createCheckoutUrlAction(baseUrl, baseUrl) if (checkoutUrl) { window.location.href = checkoutUrl } } catch (error) { console.error("Failed to get checkout URL:", error) - setIsLoading(false) } } @@ -451,8 +425,8 @@ export default function() { })()} </span> </div> - <button color="primary" disabled={isLoading()} onClick={handleBuyCredits}> - {isLoading() ? "Loading..." : "Buy Credits"} + <button color="primary" disabled={createCheckoutUrlSubmission.pending} onClick={handleBuyCredits}> + {createCheckoutUrlSubmission.pending ? "Loading..." : "Buy Credits"} </button> </div> </section> |
