@@ -41,7 +41,7 @@ export interface LoginWithPasswordProps {
41
41
buttons ?: LoginButtonProviderType [ ] ;
42
42
privacyURL ?: LoginAgreementProps [ "privacyURL" ] ;
43
43
serviceURL ?: LoginAgreementProps [ "serviceURL" ] ;
44
- accountHistory : Array < { key : string ; password : string ; countryCode : string | null } > | [ ] ;
44
+ accountHistory : Array < { key : string ; password : string ; countryCode ? : string | null } > ;
45
45
login : ( type : PasswordLoginType , key : LoginKeyType , password : string ) => Promise < boolean > ;
46
46
register : ( ) => void ;
47
47
onClickButton : LoginButtonsProps [ "onClick" ] ;
@@ -89,8 +89,9 @@ export const LoginWithPassword: React.FC<LoginWithPasswordProps> = ({
89
89
const [ agreed , setAgreed ] = useState ( false ) ;
90
90
const [ clickedLogin , setClickedLogin ] = useState ( false ) ;
91
91
const [ clickedReset , setClickedReset ] = useState ( false ) ;
92
+ const firstAccount = accountHistory . length > 0 ? accountHistory [ 0 ] : null ;
92
93
const [ countryCode , setCountryCode ] = useState (
93
- accountHistory ?. [ 0 ] ?. countryCode || defaultCountryCode ,
94
+ ( firstAccount && firstAccount . countryCode ) || defaultCountryCode ,
94
95
) ;
95
96
const [ type , setType ] = useState ( PasswordLoginType . Phone ) ;
96
97
@@ -102,8 +103,8 @@ export const LoginWithPassword: React.FC<LoginWithPasswordProps> = ({
102
103
const [ isAccountValidated , setIsAccountValidated ] = useState ( false ) ;
103
104
104
105
const defaultValues = {
105
- key : accountHistory ?. [ 0 ] ?. key || "" ,
106
- password : accountHistory ?. [ 0 ] ?. password || "" ,
106
+ key : firstAccount ?. key || "" ,
107
+ password : firstAccount ?. password || "" ,
107
108
code : undefined ,
108
109
} ;
109
110
const [ password , setPassword ] = useState ( defaultValues . password ) ;
0 commit comments