1- import { Spinner } from "@/components/ui/Spinner/Spinner" ;
1+ "use client" ;
2+
23import { TrackedLinkTW } from "@/components/ui/tracked-link" ;
3- import { type ApiKey , useApiKeys } from "@3rdweb-sdk/react/hooks/useApi" ;
4- import { useLoggedInUser } from "@3rdweb-sdk/react/hooks/useLoggedInUser" ;
5- import { AppLayout } from "components/app-layouts/app" ;
4+ import type { ApiKey } from "@3rdweb-sdk/react/hooks/useApi" ;
65import { EmbeddedWallets } from "components/embedded-wallets" ;
76import { ApiKeysMenu } from "components/settings/ApiKeys/Menu" ;
87import { NoApiKeys } from "components/settings/ApiKeys/NoApiKeys" ;
9- // import { ConnectSidebar } from "core-ui/sidebar/connect";
10- import { useRouter } from "next/router" ;
11- import { PageId } from "page-id" ;
128import { useMemo , useState } from "react" ;
13- import type { ThirdwebNextPage } from "utils/types" ;
14- import { ConnectSidebarLayout } from "../../../app/(dashboard)/dashboard/connect/DashboardConnectLayout" ;
15- import { AnalyticsCallout } from "../../../app/team/[team_slug]/[project_slug]/connect/in-app-wallets/_components/AnalyticsCallout" ;
16- import { InAppWaletFooterSection } from "../../../app/team/[team_slug]/[project_slug]/connect/in-app-wallets/_components/footer" ;
9+ import { AnalyticsCallout } from "../../../../team/[team_slug]/[project_slug]/connect/in-app-wallets/_components/AnalyticsCallout" ;
10+ import { InAppWaletFooterSection } from "../../../../team/[team_slug]/[project_slug]/connect/in-app-wallets/_components/footer" ;
1711
1812const TRACKING_CATEGORY = "embedded-wallet" ;
1913
20- const DashboardConnectEmbeddedWallets : ThirdwebNextPage = ( ) => {
21- const router = useRouter ( ) ;
22- const defaultClientId = router . query . clientId ?. toString ( ) ;
23- const { isPending } = useLoggedInUser ( ) ;
24- const keysQuery = useApiKeys ( ) ;
25-
14+ export function InAppWalletsPage ( props : {
15+ defaultClientId : string | undefined ;
16+ apiKeys : ApiKey [ ] ;
17+ } ) {
18+ const { defaultClientId, apiKeys : allApiKeys } = props ;
2619 const [ selectedKey_ , setSelectedKey ] = useState < undefined | ApiKey > ( ) ;
2720
2821 const apiKeys = useMemo ( ( ) => {
29- return ( keysQuery ?. data || [ ] ) . filter ( ( key ) => {
22+ return allApiKeys . filter ( ( key ) => {
3023 return ! ! ( key . services || [ ] ) . find (
3124 ( srv ) => srv . name === "embeddedWallets" ,
3225 ) ;
3326 } ) ;
34- } , [ keysQuery ] ) ;
27+ } , [ allApiKeys ] ) ;
3528
3629 const hasApiKeys = apiKeys . length > 0 ;
3730
@@ -49,14 +42,6 @@ const DashboardConnectEmbeddedWallets: ThirdwebNextPage = () => {
4942 return undefined ;
5043 } , [ apiKeys , defaultClientId , selectedKey_ ] ) ;
5144
52- if ( isPending ) {
53- return (
54- < div className = "grid w-full place-items-center" >
55- < Spinner className = "size-14" />
56- </ div >
57- ) ;
58- }
59-
6045 return (
6146 < div >
6247 < div className = "flex flex-col gap-4 lg:flex-row lg:justify-between" >
@@ -88,50 +73,35 @@ const DashboardConnectEmbeddedWallets: ThirdwebNextPage = () => {
8873 < ApiKeysMenu
8974 apiKeys = { apiKeys }
9075 selectedKey = { selectedKey }
91- onSelect = { setSelectedKey }
76+ onSelect = { ( key ) => {
77+ setSelectedKey ( key ) ;
78+ // add clientId search param to the url without affecting router
79+ window . history . replaceState (
80+ { } ,
81+ "" ,
82+ `/dashboard/connect/in-app-wallets?clientId=${ key . key } ` ,
83+ ) ;
84+ } }
9285 />
9386 ) }
9487 </ div >
9588 </ div >
9689
9790 < div className = "h-8" />
9891
99- { keysQuery . isPending ? (
100- < div className = "flex h-[500px] items-center justify-center" >
101- < Spinner className = "size-10" />
102- </ div >
103- ) : (
104- < >
105- { ! hasApiKeys && < NoApiKeys service = "in-app wallets" /> }
92+ { ! hasApiKeys && < NoApiKeys service = "in-app wallets" /> }
10693
107- { hasApiKeys && selectedKey && (
108- < EmbeddedWallets
109- apiKey = { selectedKey }
110- trackingCategory = { TRACKING_CATEGORY }
111- />
112- ) }
113- </ >
94+ { hasApiKeys && selectedKey && (
95+ < EmbeddedWallets
96+ apiKey = { selectedKey }
97+ trackingCategory = { TRACKING_CATEGORY }
98+ />
11499 ) }
115100
116101 < div className = "h-16" />
117102 < AnalyticsCallout trackingCategory = { TRACKING_CATEGORY } />
118103 < div className = "h-5" />
119-
120104 < InAppWaletFooterSection trackingCategory = { TRACKING_CATEGORY } />
121105 </ div >
122106 ) ;
123- } ;
124-
125- DashboardConnectEmbeddedWallets . getLayout = ( page , props ) => (
126- < AppLayout
127- { ...props }
128- pageContainerClassName = "!max-w-full !px-0"
129- mainClassName = "!pt-0"
130- >
131- < ConnectSidebarLayout > { page } </ ConnectSidebarLayout >
132- </ AppLayout >
133- ) ;
134-
135- DashboardConnectEmbeddedWallets . pageId = PageId . DashboardConnectEmbeddedWallets ;
136-
137- export default DashboardConnectEmbeddedWallets ;
107+ }
0 commit comments