@@ -4,19 +4,27 @@ import { logBonsaiError } from '@/bonsai/logs';
44import { useTurnkey } from '@turnkey/sdk-react' ;
55import styled , { css } from 'styled-components' ;
66
7+ import { AlertType } from '@/constants/alerts' ;
78import { ButtonAction , ButtonSize , ButtonType } from '@/constants/buttons' ;
89import { STRING_KEYS } from '@/constants/localization' ;
10+ import { ConnectorType , WalletInfo , wallets } from '@/constants/wallets' ;
911
12+ import { useAccounts } from '@/hooks/useAccounts' ;
13+ import { useDisplayedWallets } from '@/hooks/useDisplayedWallets' ;
1014import { useStringGetter } from '@/hooks/useStringGetter' ;
1115import { useURLConfigs } from '@/hooks/useURLConfigs' ;
1216import { useTurnkeyAuth } from '@/providers/TurnkeyAuthProvider' ;
1317
18+ import breakpoints from '@/styles/breakpoints' ;
19+
20+ import { AlertMessage } from '@/components/AlertMessage' ;
1421import { Button } from '@/components/Button' ;
1522import { FormInput } from '@/components/FormInput' ;
1623import { Icon , IconName } from '@/components/Icon' ;
1724import { InputType } from '@/components/Input' ;
1825import { Link } from '@/components/Link' ;
1926import { HorizontalSeparatorFiller } from '@/components/Separator' ;
27+ import { WalletIcon } from '@/components/WalletIcon' ;
2028
2129import { useAppSelector } from '@/state/appTypes' ;
2230import { AppTheme } from '@/state/appUiConfigs' ;
@@ -30,10 +38,12 @@ import { GoogleAuth } from './AuthButtons/GoogleAuth';
3038
3139export const SignIn = ( {
3240 onDisplayChooseWallet,
41+ onChooseWallet,
3342 // eslint-disable-next-line @typescript-eslint/no-unused-vars
3443 onSignInWithPasskey,
3544 onSubmitEmail,
3645} : {
46+ onChooseWallet : ( wallet : WalletInfo ) => void ;
3747 onDisplayChooseWallet : ( ) => void ;
3848 onSignInWithPasskey : ( ) => void ;
3949 onSubmitEmail : ( { userEmail } : { userEmail : string } ) => void ;
@@ -45,6 +55,8 @@ export const SignIn = ({
4555 const { signInWithOtp } = useTurnkeyAuth ( ) ;
4656 const appTheme = useAppSelector ( getAppTheme ) ;
4757 const { tos, privacy } = useURLConfigs ( ) ;
58+ const displayedWallets = useDisplayedWallets ( ) ;
59+ const { selectedWallet, selectedWalletError } = useAccounts ( ) ;
4860
4961 const onSubmit = useCallback (
5062 async ( e : React . FormEvent < HTMLFormElement > ) => {
@@ -64,6 +76,25 @@ export const SignIn = ({
6476
6577 const hasValidEmail = isValidEmail ( email ) ;
6678
79+ const walletError = selectedWallet && selectedWalletError && (
80+ < $AlertMessage type = { AlertType . Error } >
81+ < h4 >
82+ { stringGetter ( {
83+ key : STRING_KEYS . COULD_NOT_CONNECT ,
84+ params : {
85+ WALLET :
86+ selectedWallet . connectorType === ConnectorType . Injected
87+ ? selectedWallet . name
88+ : stringGetter ( {
89+ key : wallets [ selectedWallet . name as keyof typeof wallets ] . stringKey ,
90+ } ) ,
91+ } ,
92+ } ) }
93+ </ h4 >
94+ { selectedWalletError }
95+ </ $AlertMessage >
96+ ) ;
97+
6798 return (
6899 < form onSubmit = { onSubmit } tw = "flexColumn gap-1.25" >
69100 < div tw = "row gap-1" >
@@ -121,6 +152,23 @@ export const SignIn = ({
121152 <Icon tw="text-color-layer-7" iconName={IconName.ChevronRight} />
122153 </$OtherOptionButton> */ }
123154
155+ { displayedWallets
156+ . filter ( ( wallet ) => wallet . connectorType === ConnectorType . Injected )
157+ . map ( ( wallet ) => (
158+ < $OtherOptionButton
159+ key = { wallet . name }
160+ type = { ButtonType . Button }
161+ action = { ButtonAction . Base }
162+ size = { ButtonSize . BasePlus }
163+ onClick = { ( ) => onChooseWallet ( wallet ) }
164+ >
165+ < div tw = "row gap-0.5" >
166+ < WalletIcon wallet = { wallet } />
167+ { wallet . name }
168+ </ div >
169+ </ $OtherOptionButton >
170+ ) ) }
171+
124172 < $OtherOptionButton
125173 type = { ButtonType . Button }
126174 action = { ButtonAction . Base }
@@ -129,13 +177,15 @@ export const SignIn = ({
129177 >
130178 < div tw = "row gap-0.5" >
131179 < Icon iconName = { IconName . Wallet2 } />
132- { stringGetter ( { key : STRING_KEYS . SIGN_IN_WITH_WALLET } ) }
180+ { stringGetter ( { key : STRING_KEYS . VIEW_MORE_WALLETS } ) }
133181 </ div >
134182
135183 < Icon tw = "text-color-layer-7" iconName = { IconName . ChevronRight } />
136184 </ $OtherOptionButton >
137185 </ div >
138186
187+ { walletError }
188+
139189 < span tw = "text-center font-mini-book" >
140190 { stringGetter ( {
141191 key : STRING_KEYS . TOS_SHORT ,
@@ -193,7 +243,17 @@ const $HorizontalSeparatorFiller = styled(HorizontalSeparatorFiller)<{ $isLightM
193243
194244const $OtherOptionButton = styled ( Button ) `
195245 width: 100%;
196- border-radius: 1rem ;
246+ border-radius: 0.75rem ;
197247 justify-content: space-between;
198248 --icon-size: 1rem;
249+
250+ @media ${ breakpoints . tablet } {
251+ border-radius: 1rem;
252+ }
253+ ` ;
254+
255+ const $AlertMessage = styled ( AlertMessage ) `
256+ h4 {
257+ font: var(--font-small-medium);
258+ }
199259` ;
0 commit comments