TP-38793 | IFSC Check (#7689)
This commit is contained in:
@@ -14,6 +14,7 @@ data class DefaultConfigContent(
|
||||
@SerializedName("maxPaymentAmount") val maxPaymentAmount: Double = 1000000.0,
|
||||
@SerializedName("accountNumberMaxLength") val accountNumberMaxLength: Int = 16,
|
||||
@SerializedName("ifscLength") val ifscLength: Int = 11,
|
||||
@SerializedName("ifscRegex") val ifscRegex: String = "^[A-Za-z]{4}0[A-Za-z0-9]{6}$",
|
||||
@SerializedName("recipientNameMaxLength") val recipientNameMaxLength: Int = 50,
|
||||
@SerializedName("upiIdMaxLength") val upiIdMaxLength: Int = 50,
|
||||
@SerializedName("contactSearchQueryMaxLength") val contactSearchQueryMaxLength: Int = 50,
|
||||
|
||||
@@ -113,6 +113,7 @@ fun BankDetailInputScreen(
|
||||
val recipientNameInput by bankDetailInputViewModel.recipientNameInput.collectAsStateWithLifecycle()
|
||||
val confirmButtonEnabled by bankDetailInputViewModel.confirmButtonEnabledState.collectAsStateWithLifecycle()
|
||||
val reAccountNumberInvalidState by bankDetailInputViewModel.reAccountNumberInvalidState.collectAsStateWithLifecycle()
|
||||
val ifscInvalidState by bankDetailInputViewModel.ifscInvalidState.collectAsStateWithLifecycle()
|
||||
val ifscBranchValue by bankDetailInputViewModel.ifscBranchValue.collectAsStateWithLifecycle()
|
||||
val invalidInfoState by bankDetailInputViewModel.invalidInfoState.collectAsStateWithLifecycle()
|
||||
val isAccountNumberInputFocused by bankDetailInputViewModel.isAccountNumberInputFocused.collectAsStateWithLifecycle()
|
||||
@@ -150,6 +151,7 @@ fun BankDetailInputScreen(
|
||||
onReAccountNumberInputValueChanged = bankDetailInputViewModel::reAccountNumberInputChanged,
|
||||
reAccountNumberInvalidState = reAccountNumberInvalidState,
|
||||
ifscInput = ifscInput,
|
||||
ifscInvalidState = ifscInvalidState,
|
||||
onIfscInputValueChanged = bankDetailInputViewModel::ifscInputChanged,
|
||||
ifscBranchValue = ifscBranchValue,
|
||||
recipientNameInput = recipientNameInput,
|
||||
@@ -184,6 +186,7 @@ fun RenderBankDetailInputScreen(
|
||||
onReAccountNumberInputValueChanged: (String) -> Unit,
|
||||
reAccountNumberInvalidState: Boolean,
|
||||
ifscInput: String,
|
||||
ifscInvalidState: Boolean,
|
||||
onIfscInputValueChanged: (String) -> Unit,
|
||||
ifscBranchValue: String,
|
||||
recipientNameInput: String,
|
||||
@@ -288,7 +291,7 @@ fun RenderBankDetailInputScreen(
|
||||
placeHolderString = stringResource(id = R.string.bank_input_ifsc_placeholder),
|
||||
value = ifscInput,
|
||||
imeAction = ImeAction.Next,
|
||||
invalidInfoState = invalidInfoState.isInvalid,
|
||||
invalidInfoState = ifscInvalidState || invalidInfoState.isInvalid,
|
||||
onValueChangeListener = onIfscInputValueChanged,
|
||||
modifier = Modifier.padding(horizontal = 16.dp)
|
||||
)
|
||||
@@ -308,6 +311,21 @@ fun RenderBankDetailInputScreen(
|
||||
)
|
||||
}
|
||||
|
||||
if (ifscInvalidState) {
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
Text(
|
||||
text = "Wrong IFSC. Please try again!",
|
||||
fontFamily = ttComposeFontFamily,
|
||||
fontWeight = getFontWeight(FontWeightEnum.NAVI_BODY_REGULAR),
|
||||
color = NaviPayColor.inputFieldError,
|
||||
fontSize = 12.sp,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp)
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(24.dp))
|
||||
|
||||
InputTextFieldWithDescriptionHeader(
|
||||
|
||||
@@ -76,6 +76,9 @@ class BankDetailInputViewModel @Inject constructor(
|
||||
private val _reAccountNumberInvalidState = MutableStateFlow(false)
|
||||
val reAccountNumberInvalidState = _reAccountNumberInvalidState.asStateFlow()
|
||||
|
||||
private val _ifscInvalidState = MutableStateFlow(false)
|
||||
val ifscInvalidState = _ifscInvalidState.asStateFlow()
|
||||
|
||||
private val _navigateToNextScreen = MutableSharedFlow<Direction>()
|
||||
val navigateToNextScreen = _navigateToNextScreen.asSharedFlow()
|
||||
|
||||
@@ -167,6 +170,15 @@ class BankDetailInputViewModel @Inject constructor(
|
||||
.take(naviPayDefaultConfig.config.ifscLength)
|
||||
}
|
||||
}
|
||||
_ifscInvalidState.update {
|
||||
if (newInput.length < naviPayDefaultConfig.config.ifscLength) {
|
||||
false
|
||||
} else if (newInput.length == naviPayDefaultConfig.config.ifscLength) {
|
||||
naviPayDefaultConfig.config.ifscRegex.toRegex().matches(_ifscInput.value).not()
|
||||
} else {
|
||||
_ifscInvalidState.value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,6 +214,10 @@ class BankDetailInputViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun isValidIfsc(): Boolean =
|
||||
ifscInput.value.length == naviPayDefaultConfig.config.ifscLength &&
|
||||
naviPayDefaultConfig.config.ifscRegex.toRegex().matches(ifscInput.value)
|
||||
|
||||
private fun updateReAccountNumberInvalidState() =
|
||||
_reAccountNumberInvalidState.update {
|
||||
reAccountNumberInput.value.isNotEmpty() && !accountNumberInput.value.startsWith(
|
||||
@@ -251,6 +267,11 @@ class BankDetailInputViewModel @Inject constructor(
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (!isValidIfsc()) {
|
||||
_ifscInvalidState.update { true }
|
||||
return@launch
|
||||
}
|
||||
|
||||
updateShowBottomSheetState(showBottomSheet = true)
|
||||
|
||||
val vpaToBeValidated = generateVpaFromBankDetailsInput()
|
||||
|
||||
Reference in New Issue
Block a user