11import { abstractWallet } from "@abstract-foundation/agw-react/thirdweb" ;
22import { XIcon } from "lucide-react" ;
3- import { useRouter } from "next/navigation" ;
4- import { useEffect , useMemo } from "react" ;
3+ import { usePathname } from "next/navigation" ;
4+ import { useEffect , useState } from "react" ;
55import {
66 arbitrumSepolia ,
77 baseSepolia ,
@@ -25,21 +25,26 @@ import { cn } from "../../../../lib/utils";
2525import { CodeGen } from "../components/CodeGen" ;
2626import type { ConnectPlaygroundOptions } from "../components/types" ;
2727
28+ type Tab = "modal" | "button" | "code" ;
29+
2830export function RightSection ( props : {
2931 connectOptions : ConnectPlaygroundOptions ;
3032 tab ?: string ;
3133} ) {
32- const router = useRouter ( ) ;
33- const previewTab = useMemo (
34- ( ) =>
35- [ "modal" , "button" , "code" ] . includes ( props . tab || "" )
36- ? ( props . tab as "modal" | "button" | "code" )
37- : "modal" ,
38- [ props . tab ] ,
39- ) ;
40- const setPreviewTab = ( tab : "modal" | "button" | "code" ) => {
41- router . push ( `/connect/sign-in?tab=${ tab } ` ) ;
42- } ;
34+ const pathname = usePathname ( ) ;
35+ const [ previewTab , _setPreviewTab ] = useState < Tab > ( ( ) => {
36+ return props . tab === "code"
37+ ? "code"
38+ : props . tab === "button"
39+ ? "button"
40+ : "modal" ;
41+ } ) ;
42+
43+ function setPreviewTab ( tab : "modal" | "button" | "code" ) {
44+ _setPreviewTab ( tab ) ;
45+ window . history . replaceState ( { } , "" , `${ pathname } ?tab=${ tab } ` ) ;
46+ }
47+
4348 const { connectOptions } = props ;
4449 const wallet = useActiveWallet ( ) ;
4550 const account = useActiveAccount ( ) ;
0 commit comments