Merge pull request #2365 from medici/integration/pl_pan_error_in_basic_detais
Implemented PAN error handling in PL basic details screen
This commit is contained in:
@@ -38,6 +38,7 @@ import com.naviapp.homeloan.common.listener.HeaderInteractionListener
|
||||
import com.naviapp.models.UserDetail
|
||||
import com.naviapp.network.ApiErrorTagType.PROFILE_DETAILS_UPLOAD
|
||||
import com.naviapp.personalloan.getloan.kyc.fragments.KycFragment
|
||||
import com.naviapp.personalloan.useridentification.pan.fragments.PanErrorFragment
|
||||
import com.naviapp.personalloan.useridentification.profile.viewmodels.ProfileVM
|
||||
import com.naviapp.personalloan.useridentification.viewmodels.EligibilityShareVM
|
||||
import com.naviapp.utils.*
|
||||
@@ -170,6 +171,15 @@ class ProfileFragment : BaseFragment(),
|
||||
viewModel.postFinoramicData.observeNullable(this) {
|
||||
viewModel.fetchProfileData()
|
||||
}
|
||||
|
||||
viewModel.panError.observeNonNull(this) {
|
||||
if (!isAdded || activity?.isFinishing.orTrue()) {
|
||||
return@observeNonNull
|
||||
}
|
||||
hideLoader()
|
||||
PanErrorFragment.getInstance(it, listener)
|
||||
.show(childFragmentManager, PanErrorFragment.TAG)
|
||||
}
|
||||
}
|
||||
|
||||
@ExperimentalStdlibApi
|
||||
@@ -212,7 +222,9 @@ class ProfileFragment : BaseFragment(),
|
||||
apiPollScheduler?.invoke()
|
||||
return
|
||||
} else {
|
||||
viewModel.checkUiStatus(null, null)
|
||||
viewModel.profileAsyncResponse.value?.requestId?.let { requestId ->
|
||||
viewModel.fetchAsyncRequestDataWithError(requestId)
|
||||
} ?: viewModel.checkUiStatus(null, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,4 +27,7 @@ class ProfileRepository : ResponseCallback() {
|
||||
suspend fun fetchNextCta(requestId: String) =
|
||||
apiResponseCallback(retrofitService().fetchNextCta(requestId = requestId))
|
||||
|
||||
suspend fun fetchAsyncRequestDataWithError(requestId: String) =
|
||||
apiResponseCallback(retrofitService().fetchAsyncRequestWithError(requestId))
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import com.naviapp.models.request.ProfileRequest
|
||||
import com.naviapp.models.response.ProfileDetailsResponse
|
||||
import com.naviapp.models.response.SuccessResponse
|
||||
import com.naviapp.models.response.UploadDataAsyncResponse
|
||||
import com.naviapp.network.ApiConstants.E_PAN_NAME_MISMATCH
|
||||
import com.naviapp.network.ApiErrorTagType.PROFILE_DETAILS_UPLOAD
|
||||
import com.naviapp.network.models.GenericErrorResponse
|
||||
import com.naviapp.network.models.GenericWarningResponse
|
||||
@@ -43,6 +44,10 @@ class ProfileVM(private val repository: ProfileRepository = ProfileRepository())
|
||||
val nextCtaData: LiveData<String>
|
||||
get() = _nextCtaData
|
||||
|
||||
private val _panError = MutableLiveData<GenericErrorResponse>()
|
||||
val panError: LiveData<GenericErrorResponse>
|
||||
get() = _panError
|
||||
|
||||
fun fetchProfileData() {
|
||||
coroutineScope.launch {
|
||||
val response = repository.fetchProfileData()
|
||||
@@ -135,4 +140,27 @@ class ProfileVM(private val repository: ProfileRepository = ProfileRepository())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun fetchAsyncRequestDataWithError(requestId: String) {
|
||||
coroutineScope.launch {
|
||||
val response = repository.fetchAsyncRequestDataWithError(requestId)
|
||||
if (response.error == null && response.errors.isNullOrEmpty()) {
|
||||
if (TextUtils.equals(response.data?.status, FirebaseStatusType.FAILURE)) {
|
||||
checkUiStatus(response.errors, response.warning)
|
||||
return@launch
|
||||
}
|
||||
_dataAsyncResponse.value = response.data
|
||||
} else {
|
||||
val error = response.errors?.firstOrNull()
|
||||
when (error?.code) {
|
||||
E_PAN_NAME_MISMATCH -> {
|
||||
_panError.value = error
|
||||
}
|
||||
else -> {
|
||||
checkUiStatus(response.errors, response.warning)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user