Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

fix loading state

Kiran K27690980dc91
diff --git a/packages/stripe-app/src/utils/oauth.ts b/packages/stripe-app/src/utils/oauth.ts
index e69b3a7e1d..cb1862b684 100644
--- a/packages/stripe-app/src/utils/oauth.ts
+++ b/packages/stripe-app/src/utils/oauth.ts
@@ -1,15 +1,14 @@
-// Handle the Dub OAuth flow
-
import Stripe from "stripe";
import { DUB_CLIENT_ID, DUB_HOST } from "./constants";
import { getSecret } from "./secrets";
import { Token, Workspace } from "./types";
-const getRedirectURL = (mode: "live" | "test") => {
+// Get the redirect URL for the OAuth flow based on the mode
+function getRedirectURL(mode: "live" | "test") {
return `https://dashboard.stripe.com/${
mode === "test" ? "test/" : ""
}apps-oauth/dub.co`;
-};
+}
// Returns the authorization URL
export function getOAuthUrl({
diff --git a/packages/stripe-app/src/views/AppSettings.tsx b/packages/stripe-app/src/views/AppSettings.tsx
index 8cca096c00..4e4892b71e 100644
--- a/packages/stripe-app/src/views/AppSettings.tsx
+++ b/packages/stripe-app/src/views/AppSettings.tsx
@@ -21,7 +21,6 @@ import { setSecret } from "../utils/secrets";
// TODO:
// Handle errors and display them to the user
-// Proper loading state
// You don't need an API Key here, because the app uses the
// dashboard credentials to make requests.
@@ -34,7 +33,6 @@ const AppSettings = ({ userContext, oauthContext }: ExtensionContextValue) => {
const credentialsUsed = useRef(false);
const [oauthState, setOAuthState] = useState("");
const [challenge, setChallenge] = useState("");
- // const [workspaces, setWorkspace] = useState<Workspace | null>(null);
const [disconnecting, setDisconnecting] = useState(false);
const [connecting, setConnecting] = useState(false);
const { workspace, isLoading, mutate } = useWorkspace(stripe);
@@ -88,7 +86,7 @@ const AppSettings = ({ userContext, oauthContext }: ExtensionContextValue) => {
useEffect(() => {
// if there is a workspace, we're done here
- if (workspace || !isLoading) {
+ if (workspace) {
return;
}
@@ -107,7 +105,7 @@ const AppSettings = ({ userContext, oauthContext }: ExtensionContextValue) => {
}
}, [workspace, oauthState, code, verifier]);
- if (isLoading) {
+ if (isLoading || connecting) {
return <Spinner size="large" />;
}