fix personalIdNumber validation

This commit is contained in:
Jonathan Edenström 2021-11-30 14:24:43 +01:00
parent 281e796d1d
commit d8dbcf6887
1 changed files with 8 additions and 10 deletions

View File

@ -117,15 +117,17 @@ export const Login = () => {
}
}
const isUsingPersonalIdNumber =
loginMethodId === 'otherdevice' ||
(loginMethodId === 'thisdevice' && !loginBankIdSameDeviceWithoutId)
const startLogin = async (text: string) => {
if (loginMethodId === 'thisdevice' || loginMethodId === 'otherdevice') {
showModal(true)
let ssn
if (
loginMethodId === 'otherdevice' ||
(loginMethodId === 'thisdevice' && !loginBankIdSameDeviceWithoutId)
) {
if (isUsingPersonalIdNumber) {
ssn = Personnummer.parse(text).format(true)
setPersonalIdNumber(ssn)
}
@ -157,14 +159,10 @@ export const Login = () => {
loginMethods.find((method) => method.id === loginMethodId) ||
loginMethods[0]
const showInputField =
loginMethodId === 'otherdevice' ||
(loginMethodId === 'thisdevice' && !loginBankIdSameDeviceWithoutId)
return (
<>
<View style={styles.loginForm}>
{showInputField && (
{isUsingPersonalIdNumber && (
<Input
accessible={true}
label={t('general.socialSecurityNumber')}
@ -197,7 +195,7 @@ export const Login = () => {
onPress={() => startLogin(personalIdNumber)}
style={styles.loginButton}
appearance="ghost"
disabled={loginMethodId === 'otherdevice' && !valid}
disabled={isUsingPersonalIdNumber && !valid}
status="primary"
accessoryLeft={BankId}
size="medium"