Skip to content

Commit 8b7deb7

Browse files
committed
feat: show query devtools in development env only
1 parent 3b766f0 commit 8b7deb7

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

src/hooks/useGateway.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ export function useGateway() {
66

77
useEffect(() => {
88
const baseURL = process.env.ZEALOT_GATEWAY_URL;
9+
if (!baseURL) {
10+
console.warn("ZEALOT_GATEWAY_URL is not defined");
11+
return;
12+
}
913

1014
if (baseURL) {
1115
try {

src/pages/checkout/index.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@ import { useHistory } from "@docusaurus/router";
77
import { usePaddleClient } from "@site/src/hooks/usePaddlePrices";
88
import { useGateway } from "@site/src/hooks/useGateway";
99

10-
export default function CheckoutPage() {
11-
return (
12-
<Layout title="Checkout">
13-
<BrowserOnly fallback={<div>Loading checkout...</div>}>
14-
{() => <CheckoutClient />}
15-
</BrowserOnly>
16-
</Layout>
17-
);
18-
}
19-
// 客户端渲染的主体组件,避免 SSR 触发 window 报错
2010
function CheckoutClient() {
2111
const { i18n } = useDocusaurusContext();
2212
const history = useHistory();
@@ -97,7 +87,7 @@ function CheckoutClient() {
9787
return (
9888
<main className="flex flex-col items-center px-4 py-8 gap-10">
9989
<div className="checkout-container"></div>
100-
{(query.isLoading || !query.data) && <div>Loading your orders...</div>}
90+
{(query.isLoading || !query.data) && <div>Preparing checkout ...</div>}
10191
{query.isError && <div>Error loading your orders.</div>}
10292

10393
{query.data && query.data.orders.length > 0 && (
@@ -116,3 +106,13 @@ function CheckoutClient() {
116106
</main>
117107
);
118108
}
109+
110+
export default function CheckoutPage() {
111+
return (
112+
<Layout title="Checkout">
113+
<BrowserOnly fallback={<div>Loading checkout...</div>}>
114+
{() => <CheckoutClient />}
115+
</BrowserOnly>
116+
</Layout>
117+
);
118+
}

src/theme/Root/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
44
const queryClient = new QueryClient();
55

66
export default function Root({ children }) {
7+
const env = process.env.ENVIRONMENT || "production";
78
return (
89
<QueryClientProvider client={queryClient}>
910
<>{children}</>
10-
<ReactQueryDevtools initialIsOpen={false} />
11+
{env === "development" && <ReactQueryDevtools initialIsOpen={false} />}
1112
</QueryClientProvider>
1213
);
1314
}

0 commit comments

Comments
 (0)