diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/EnterTanDialog.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/EnterTanDialog.kt index f280cb1..984ce74 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/EnterTanDialog.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/EnterTanDialog.kt @@ -18,13 +18,16 @@ import bankmeister.composeapp.generated.resources.zoom_in import bankmeister.composeapp.generated.resources.zoom_out import kotlinx.datetime.TimeZone import kotlinx.datetime.toLocalDateTime +import net.codinux.banking.client.model.tan.ActionRequiringTan import net.codinux.banking.client.model.tan.AllowedTanFormat import net.codinux.banking.client.model.tan.EnterTanResult import net.codinux.banking.ui.composables.BankIcon +import net.codinux.banking.ui.config.DI import net.codinux.banking.ui.config.Internationalization import net.codinux.banking.ui.forms.OutlinedTextField import net.codinux.banking.ui.forms.Select import net.codinux.banking.ui.model.TanChallengeReceived +import net.codinux.banking.ui.model.error.ErroneousAction import net.codinux.banking.ui.service.createImageBitmap import net.codinux.log.Log import org.jetbrains.compose.resources.imageResource @@ -50,12 +53,29 @@ fun EnterTanDialog(tanChallengeReceived: TanChallengeReceived, onDismiss: () -> var enteredTan by remember { mutableStateOf("") } + challenge.addTanExpiredCallback { + val erroneousAction = when (challenge.forAction) { + ActionRequiringTan.GetTransactions -> ErroneousAction.UpdateAccountTransactions + ActionRequiringTan.TransferMoney -> ErroneousAction.TransferMoney + else -> ErroneousAction.AddAccount + } + DI.uiState.applicationErrorOccurred(erroneousAction, "TAN ist abgelaufen und kann nicht mehr eingegeben werden") + + onDismiss() + } if (isDecoupledMethod) { challenge.addUserApprovedDecoupledTanCallback { onDismiss() } } + + fun dismiss() { + tanChallengeReceived.callback(EnterTanResult(null)) + + onDismiss() + } + fun confirmCalled() { if (enteredTan.length > 2) { tanChallengeReceived.callback(EnterTanResult(enteredTan))