Skip to content

Instantly share code, notes, and snippets.

@Aldikitta
Created June 14, 2023 09:40
Show Gist options
  • Save Aldikitta/eaed69fa2433a46987ab293652eefe37 to your computer and use it in GitHub Desktop.
Save Aldikitta/eaed69fa2433a46987ab293652eefe37 to your computer and use it in GitHub Desktop.
fun getAgentVisitDetailFullResponse() {
val visitId = savedStateHandle.get<Int>("visitId")
viewModelScope.launch {
val visitDetail = visitId?.let { useCase.getDetailAgentVisitWithFullResponse(id = it) }
when (visitDetail) {
is SallyResponseResource.Loading -> {
_uiStateDetail.value = VisitingDetailUiState.Loading
}
is SallyResponseResource.Success -> {
_uiStateDetail.value = VisitingDetailUiState.Success(visitDetail.data.data)
}
is SallyResponseResource.Error -> {
_eventFlow.emit(
VisitingUiEvent.ShowErrorMessageStatic(
staticError = visitDetail.exception.message,
dynamicError = visitDetail.exception.cause?.message.toString(),
errorCode = visitDetail.errorCode
)
)
_uiStateDetail.value =
VisitingDetailUiState.Error(error = visitDetail.exception.toString())
}
else -> {
AnalyticsUtils.analytic(
Constant.EVENT_FAILURE,
"Exception in getAgentVisit Detail"
)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment