Feature/remove parents name kyc (#849)
* hide parents details from kyc * kyc remove parents detail handling done * rename fun * pr changes
This commit is contained in:
committed by
GitHub Enterprise
parent
82ce09811c
commit
b38785bed7
@@ -26,6 +26,7 @@ import com.naviapp.network.models.ErrorMessage
|
||||
import com.naviapp.network.models.GenericErrorResponse
|
||||
import com.naviapp.network.models.GenericWarningResponse
|
||||
import com.naviapp.utils.isNetworkAvailable
|
||||
import com.naviapp.utils.orZero
|
||||
import kotlinx.coroutines.CoroutineExceptionHandler
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -125,4 +126,25 @@ abstract class BaseVM : ViewModel() {
|
||||
fun setWarning(warning: GenericWarningResponse?, tag: String? = null) {
|
||||
warning?.let { warningResponse.value = Pair(it, tag) }
|
||||
}
|
||||
|
||||
fun setErrorData(
|
||||
errors: List<GenericErrorResponse>? = null,
|
||||
error: ErrorMessage? = null,
|
||||
tag: String? = null,
|
||||
cancelable: Boolean = true
|
||||
) {
|
||||
if (errors?.size.orZero() > 0) {
|
||||
setError(
|
||||
errors,
|
||||
tag,
|
||||
cancelable
|
||||
)
|
||||
} else {
|
||||
updateErrorMessage(
|
||||
error,
|
||||
tag,
|
||||
cancelable
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,16 +49,13 @@ import com.naviapp.models.RedirectPageStatus
|
||||
import com.naviapp.models.UiStatusValue
|
||||
import com.naviapp.models.request.Address
|
||||
import com.naviapp.models.request.KycRequest
|
||||
import com.naviapp.models.request.ParentDetails
|
||||
import com.naviapp.network.ApiConstants
|
||||
import com.naviapp.network.ApiErrorTagType
|
||||
import com.naviapp.network.models.GenericErrorResponse
|
||||
import com.naviapp.utils.Constants
|
||||
import com.naviapp.utils.Constants.MIN_ADDRESS_SIZE
|
||||
import com.naviapp.utils.Constants.MIN_NAME_SIZE
|
||||
import com.naviapp.utils.Constants.SHOULD_SET_PROGRESS
|
||||
import com.naviapp.utils.isDead
|
||||
import com.naviapp.utils.isValidName
|
||||
import com.naviapp.utils.observeNonNull
|
||||
import com.naviapp.utils.observeNullable
|
||||
import com.naviapp.utils.orFalse
|
||||
@@ -243,8 +240,6 @@ class KycFragment : BaseFragment(), RadioGroup.OnCheckedChangeListener, View.OnC
|
||||
binding.aadhaarLayout.addressLayout.addressRg.yes_rb.isChecked = true
|
||||
}
|
||||
kycDetails.documentType?.let { documentUploadSuccessLayout(it) }
|
||||
kycDetails.fatherName?.let { binding.parentsNameLayout.fatherNameEt.setText(it) }
|
||||
kycDetails.motherName?.let { binding.parentsNameLayout.motherNameEt.setText(it) }
|
||||
kycDetails.pinCodeData?.let {
|
||||
binding.aadhaarLayout.addressLayout.pinCodeAddressTv.text =
|
||||
getString(R.string.pincode_state_format, it.pinCode, it.city, it.state)
|
||||
@@ -264,8 +259,6 @@ class KycFragment : BaseFragment(), RadioGroup.OnCheckedChangeListener, View.OnC
|
||||
observeSelfieAsyncData()
|
||||
binding.aadhaarLayout.addressLayout.addressRg.setOnCheckedChangeListener(this)
|
||||
binding.aadhaarLayout.addressLayout.currentAddress.addTextChangedListener { enableNextButton() }
|
||||
binding.parentsNameLayout.fatherNameEt.addTextChangedListener { changeStateOfParentsField() }
|
||||
binding.parentsNameLayout.motherNameEt.addTextChangedListener { changeStateOfParentsField() }
|
||||
binding.nextBtn.setOnClickListener(this)
|
||||
binding.aadhaarLayout.addressLayout.uploadLl.setOnClickListener(this)
|
||||
binding.aadhaarLayout.addressLayout.billTypeLl.setOnClickListener(this)
|
||||
@@ -326,19 +319,6 @@ class KycFragment : BaseFragment(), RadioGroup.OnCheckedChangeListener, View.OnC
|
||||
editTextFocusChanged()
|
||||
}
|
||||
|
||||
private fun changeStateOfParentsField() {
|
||||
if (fathersName().length >= MIN_NAME_SIZE
|
||||
&& mothersName().length >= MIN_NAME_SIZE
|
||||
) {
|
||||
binding.parentsNameLayout.indexTv.visibility = View.GONE
|
||||
binding.parentsNameLayout.completedIv.visibility = View.VISIBLE
|
||||
} else {
|
||||
binding.parentsNameLayout.indexTv.visibility = View.VISIBLE
|
||||
binding.parentsNameLayout.completedIv.visibility = View.GONE
|
||||
}
|
||||
enableNextButton()
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, intent)
|
||||
when (requestCode) {
|
||||
@@ -615,9 +595,7 @@ class KycFragment : BaseFragment(), RadioGroup.OnCheckedChangeListener, View.OnC
|
||||
binding.aadhaarLayout.addressLayout.root.visibility == View.VISIBLE &&
|
||||
(binding.aadhaarLayout.addressLayout.addressRg.checkedRadioButtonId == R.id.yes_rb ||
|
||||
(binding.aadhaarLayout.addressLayout.currentAddress.text.toString()
|
||||
.isNotBlank())) &&
|
||||
fathersName().isNotBlank() &&
|
||||
mothersName().isNotBlank()
|
||||
.isNotBlank()))
|
||||
) {
|
||||
binding.nextBtn.setViewBg(bgColor = R.color.active_button_color)
|
||||
} else {
|
||||
@@ -634,24 +612,12 @@ class KycFragment : BaseFragment(), RadioGroup.OnCheckedChangeListener, View.OnC
|
||||
}
|
||||
}
|
||||
|
||||
private fun fathersName(): String {
|
||||
return binding.parentsNameLayout.fatherNameEt.text.toString().trim()
|
||||
}
|
||||
|
||||
private fun mothersName(): String {
|
||||
return binding.parentsNameLayout.motherNameEt.text.toString().trim()
|
||||
}
|
||||
|
||||
private fun submitKycDetails() {
|
||||
analyticsEventTracker.onKycNextButtonTap()
|
||||
if (validateForms().not()) return
|
||||
apiPollScheduler?.stopApiPoll()
|
||||
deInitializeFirebaseListener()
|
||||
showLoader()
|
||||
val parentsDetails = ParentDetails(
|
||||
fathersName(),
|
||||
mothersName()
|
||||
)
|
||||
val address = when (binding.aadhaarLayout.addressLayout.addressRg.checkedRadioButtonId) {
|
||||
R.id.yes_rb -> Address(
|
||||
type = PERMANENT,
|
||||
@@ -679,11 +645,9 @@ class KycFragment : BaseFragment(), RadioGroup.OnCheckedChangeListener, View.OnC
|
||||
else -> NaviAnalytics.NO
|
||||
}
|
||||
analyticsEventTracker.onKycNextButtonTap(
|
||||
parentsDetails.fatherName,
|
||||
parentsDetails.motherName,
|
||||
currentAddress
|
||||
)
|
||||
viewModel.submitKycDetails(KycRequest(address, parentsDetails))
|
||||
viewModel.submitKycDetails(KycRequest(address))
|
||||
}
|
||||
|
||||
private fun validateForms(): Boolean {
|
||||
@@ -694,14 +658,6 @@ class KycFragment : BaseFragment(), RadioGroup.OnCheckedChangeListener, View.OnC
|
||||
if (binding.aadhaarLayout.completedIv.visibility != View.VISIBLE) {
|
||||
validated = false
|
||||
}
|
||||
if (fathersName().isValidName().not() || fathersName().length < MIN_NAME_SIZE) {
|
||||
binding.parentsNameLayout.fatherNameEt.setError(getString(R.string.enter_valid_name))
|
||||
validated = false
|
||||
}
|
||||
if (mothersName().isValidName().not() || mothersName().length < MIN_NAME_SIZE) {
|
||||
binding.parentsNameLayout.motherNameEt.setError(getString(R.string.enter_valid_name))
|
||||
validated = false
|
||||
}
|
||||
if (binding.aadhaarLayout.addressLayout.addressRg.checkedRadioButtonId == R.id.no_rb &&
|
||||
binding.aadhaarLayout.addressLayout.currentAddress.length() < MIN_ADDRESS_SIZE
|
||||
) {
|
||||
@@ -770,14 +726,6 @@ class KycFragment : BaseFragment(), RadioGroup.OnCheckedChangeListener, View.OnC
|
||||
|
||||
override fun onFocusChange(v: View?, hasFocus: Boolean) {
|
||||
when (v?.id) {
|
||||
binding.parentsNameLayout.fatherNameEt.id -> {
|
||||
if (hasFocus)
|
||||
analyticsEventTracker.onFatherNameTap()
|
||||
}
|
||||
binding.parentsNameLayout.motherNameEt.id -> {
|
||||
if (hasFocus)
|
||||
analyticsEventTracker.onMotherNameTap()
|
||||
}
|
||||
binding.aadhaarLayout.addressLayout.currentAddress.id -> {
|
||||
if (hasFocus)
|
||||
analyticsEventTracker.onCurrentAddressFirstLineSelect()
|
||||
@@ -786,8 +734,6 @@ class KycFragment : BaseFragment(), RadioGroup.OnCheckedChangeListener, View.OnC
|
||||
}
|
||||
|
||||
private fun editTextFocusChanged() {
|
||||
binding.parentsNameLayout.fatherNameEt.onFocusChangeListener = this
|
||||
binding.parentsNameLayout.motherNameEt.onFocusChangeListener = this
|
||||
binding.aadhaarLayout.addressLayout.currentAddress.onFocusChangeListener = this
|
||||
}
|
||||
|
||||
|
||||
@@ -118,17 +118,11 @@ class KycVM : BaseVM() {
|
||||
if (response.error == null && response.errors?.isEmpty().orTrue()) {
|
||||
_kycDetailsSubmitAsyncData.value = response.data
|
||||
} else {
|
||||
response.errors?.let {
|
||||
setError(
|
||||
response.errors,
|
||||
ApiErrorTagType.SUBMIT_KYC_API_ERROR
|
||||
)
|
||||
} ?: run {
|
||||
updateErrorMessage(
|
||||
response.error,
|
||||
ApiErrorTagType.SUBMIT_KYC_API_ERROR
|
||||
)
|
||||
}
|
||||
setErrorData(
|
||||
response.errors,
|
||||
response.error,
|
||||
ApiErrorTagType.SUBMIT_KYC_API_ERROR
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class KycRequest(
|
||||
@SerializedName("address") val address: Address?,
|
||||
@SerializedName("parentDetails") val parentDetails: ParentDetails?
|
||||
@SerializedName("parentDetails") val parentDetails: ParentDetails? = null
|
||||
)
|
||||
|
||||
data class ParentDetails(
|
||||
|
||||
@@ -93,6 +93,7 @@
|
||||
android:layout_marginStart="@dimen/layout_dp_32"
|
||||
android:layout_marginTop="@dimen/layout_dp_36"
|
||||
android:layout_marginEnd="@dimen/layout_dp_32"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/aadhaar_layout" />
|
||||
|
||||
Reference in New Issue
Block a user