Skip to content

Commit 3d60da3

Browse files
committed
Fix inApp wallet config form values + show loading state (#4323)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview The focus of this PR is to improve the loading state handling in the in-app wallets section and refactor the form values handling in the Configure component. ### Detailed summary - Improved loading state handling in in-app wallets section - Refactored form values handling in the Configure component > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 3e425ec commit 3d60da3

File tree

2 files changed

+26
-31
lines changed

2 files changed

+26
-31
lines changed

apps/dashboard/src/components/embedded-wallets/Configure/index.tsx

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import {
2626
} from "components/settings/ApiKeys/validations";
2727
import { useTrack } from "hooks/analytics/useTrack";
2828
import { useTxNotifications } from "hooks/useTxNotifications";
29-
import { useEffect } from "react";
3029
import { useFieldArray, useForm } from "react-hook-form";
3130
import { LuTrash2 } from "react-icons/lu";
3231
import {
@@ -70,7 +69,7 @@ export const Configure: React.FC<ConfigureProps> = ({
7069

7170
const form = useForm<ApiKeyEmbeddedWalletsValidationSchema>({
7271
resolver: zodResolver(apiKeyEmbeddedWalletsValidationSchema),
73-
defaultValues: {
72+
values: {
7473
customAuthEndpoint: config.customAuthEndpoint,
7574
customAuthentication: config.customAuthentication,
7675
...(hasCustomBranding
@@ -84,28 +83,12 @@ export const Configure: React.FC<ConfigureProps> = ({
8483
redirectUrls: apiKey.redirectUrls.join("\n"),
8584
},
8685
});
86+
8787
const customHeaderFields = useFieldArray({
8888
control: form.control,
8989
name: "customAuthEndpoint.customHeaders",
9090
});
9191

92-
// FIXME: jesus do we need this? - there has to be a better way
93-
// eslint-disable-next-line no-restricted-syntax
94-
useEffect(() => {
95-
form.reset({
96-
customAuthEndpoint: config.customAuthEndpoint,
97-
customAuthentication: config.customAuthentication,
98-
...(hasCustomBranding
99-
? {
100-
branding: {
101-
applicationName: config.applicationName,
102-
applicationImageUrl: config.applicationImageUrl,
103-
},
104-
}
105-
: undefined),
106-
});
107-
}, [config, form, hasCustomBranding]);
108-
10992
const { onSuccess, onError } = useTxNotifications(
11093
"In-App Wallet API Key configuration updated",
11194
"Failed to update an API Key",
@@ -630,7 +613,11 @@ export const Configure: React.FC<ConfigureProps> = ({
630613
<Divider />
631614

632615
<Box alignSelf="flex-end">
633-
<Button type="submit" colorScheme="primary">
616+
<Button
617+
type="submit"
618+
colorScheme="primary"
619+
isLoading={mutation.isLoading}
620+
>
634621
Save changes
635622
</Button>
636623
</Box>

apps/dashboard/src/pages/dashboard/connect/in-app-wallets.tsx

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,25 @@ const DashboardConnectEmbeddedWallets: ThirdwebNextPage = () => {
103103
</Text>
104104
</Flex>
105105

106-
{!hasApiKeys && <NoApiKeys service="in-app wallets" />}
107-
108-
{hasApiKeys && selectedKey && (
109-
<EmbeddedWallets
110-
apiKey={selectedKey}
111-
wallets={wallets}
112-
isLoading={walletsQuery.isLoading}
113-
isFetched={walletsQuery.isFetched}
114-
trackingCategory={TRACKING_CATEGORY}
115-
defaultTabIndex={defaultTabIndex}
116-
/>
106+
{keysQuery.isLoading ? (
107+
<div className="flex h-[500px] items-center justify-center">
108+
<Spinner className="size-10" />
109+
</div>
110+
) : (
111+
<>
112+
{!hasApiKeys && <NoApiKeys service="in-app wallets" />}
113+
114+
{hasApiKeys && selectedKey && (
115+
<EmbeddedWallets
116+
apiKey={selectedKey}
117+
wallets={wallets}
118+
isLoading={walletsQuery.isLoading}
119+
isFetched={walletsQuery.isFetched}
120+
trackingCategory={TRACKING_CATEGORY}
121+
defaultTabIndex={defaultTabIndex}
122+
/>
123+
)}
124+
</>
117125
)}
118126

119127
<Spacer height={20} />

0 commit comments

Comments
 (0)