1- import { createEffect , createSignal , on } from "solid-js" ;
1+ import { createSignal , Show } from "solid-js" ;
22import Footer from "../Footer/Footer" ;
33import ConnectWallet from "./ConnectWallet" ;
44import Login from "./Login" ;
5- import { SocialLoginEventType , ExternalWalletEventType , StateEmitterEvents , ModalState , MODAL_STATUS } from "../../interfaces" ;
6- import { LOGIN_PROVIDER , type SafeEventEmitter } from "@web3auth/auth" ;
7- import { ADAPTER_NAMES , ChainNamespaceType , cloneDeep , log , WalletRegistry } from "@web3auth/base" ;
8- import deepmerge from "deepmerge" ;
9- // import { on } from "events";
5+ import { SocialLoginEventType , ExternalWalletEventType , StateEmitterEvents , ModalState , SocialLoginsConfig } from "../../interfaces" ;
6+ import { type SafeEventEmitter } from "@web3auth/auth" ;
7+ import { ChainNamespaceType , WalletRegistry } from "@web3auth/base/src" ;
8+
109export interface BodyProps {
1110 stateListener : SafeEventEmitter < StateEmitterEvents > ;
1211 appLogo ?: string ;
@@ -16,6 +15,16 @@ export interface BodyProps {
1615 handleSocialLoginClick : ( params : SocialLoginEventType ) => void ;
1716 handleExternalWalletClick : ( params : ExternalWalletEventType ) => void ;
1817 handleShowExternalWallets : ( externalWalletsInitialized : boolean ) => void ;
18+ showPasswordLessInput : boolean ;
19+ showExternalWalletButton : boolean ;
20+ socialLoginsConfig : SocialLoginsConfig ;
21+ areSocialLoginsVisible : boolean ;
22+ isEmailPrimary : boolean
23+ isExternalPrimary : boolean
24+ showExternalWalletPage : boolean ;
25+ handleExternalWalletBtnClick ?: ( flag : boolean ) => void ;
26+ modalState : ModalState ,
27+ preHandleExternalWalletClick : ( params : { adapter : string } ) => void ;
1928}
2029
2130const PAGES = {
@@ -26,10 +35,41 @@ const PAGES = {
2635const Body = ( props : BodyProps ) => {
2736 const [ currentPage , setCurrentPage ] = createSignal ( PAGES . LOGIN ) ;
2837
38+ const handleExternalWalletBtnClick = ( flag : boolean ) => {
39+ setCurrentPage ( PAGES . CONNECT_WALLET ) ;
40+ if ( props . handleExternalWalletBtnClick ) props . handleExternalWalletBtnClick ( flag )
41+ }
42+
43+ const handleBackClick = ( flag : boolean ) => {
44+ setCurrentPage ( PAGES . LOGIN ) ;
45+ if ( props . handleExternalWalletBtnClick ) props . handleExternalWalletBtnClick ( flag )
46+ }
47+
2948 return (
3049 < div class = "w3a--h-[760px] w3a--p-6 w3a--flex w3a--flex-col w3a--flex-1" >
31- { currentPage ( ) === PAGES . LOGIN && < Login onExternalWalletClick = { ( ) => setCurrentPage ( PAGES . CONNECT_WALLET ) } /> }
32- { currentPage ( ) === PAGES . CONNECT_WALLET && < ConnectWallet onBackClick = { ( ) => setCurrentPage ( PAGES . LOGIN ) } /> }
50+ < Show when = { currentPage ( ) === PAGES . LOGIN && ! props . showExternalWalletPage } >
51+ < Login
52+ showPasswordLessInput = { props . showPasswordLessInput }
53+ showExternalWalletButton = { props . showExternalWalletButton }
54+ handleSocialLoginClick = { props . handleSocialLoginClick }
55+ socialLoginsConfig = { props . socialLoginsConfig }
56+ areSocialLoginsVisible = { props . areSocialLoginsVisible }
57+ isEmailPrimary = { props . isEmailPrimary }
58+ isExternalPrimary = { props . isExternalPrimary }
59+ handleExternalWalletBtnClick = { handleExternalWalletBtnClick }
60+ />
61+ </ Show >
62+ < Show when = { currentPage ( ) === PAGES . CONNECT_WALLET && props . showExternalWalletPage } >
63+ < ConnectWallet
64+ onBackClick = { handleBackClick }
65+ modalStatus = { props . modalState . status }
66+ showBackButton = { props . areSocialLoginsVisible || props . showPasswordLessInput }
67+ handleExternalWalletClick = { props . preHandleExternalWalletClick }
68+ chainNamespace = { props . chainNamespace }
69+ walletConnectUri = { props . modalState . walletConnectUri }
70+ config = { props . modalState . externalWalletsConfig }
71+ walletRegistry = { props . walletRegistry } />
72+ </ Show >
3373 < Footer />
3474 </ div >
3575 ) ;
0 commit comments