Skip to content

Commit

Permalink
[IDLE-000] 센터 인증 대기 화면에서 승인됬을 시 Register, Home 화면 분기
Browse files Browse the repository at this point in the history
  • Loading branch information
tgyuuAn committed Nov 22, 2024
1 parent 0527dd4 commit b62a5cc
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 14 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
namespace = "com.idle.care"

defaultConfig {
versionCode = 18
versionName = "1.2.3"
versionCode = 19
versionName = "1.2.4"
targetSdk = 34

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ internal fun JobPostingScreen(

CareProgressBar(
currentStep = jobPostingStep.step,
totalSteps = JobPostingStep.entries.size - 1,
totalSteps = JobPostingStep.entries.size - 2,
modifier = Modifier
.fillMaxWidth()
.padding(start = 8.dp, top = 8.dp, bottom = 8.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ import com.idle.binding.EventHelper
import com.idle.binding.MainEvent
import com.idle.binding.ToastType.SUCCESS
import com.idle.center.pending.R
import com.idle.domain.model.error.ApiErrorCode
import com.idle.domain.model.error.ErrorHelper
import com.idle.domain.model.error.HttpResponseException
import com.idle.domain.model.profile.CenterManagerAccountStatus
import com.idle.domain.usecase.auth.LogoutCenterUseCase
import com.idle.domain.usecase.auth.SendCenterVerificationRequestUseCase
import com.idle.domain.usecase.profile.GetCenterStatusUseCase
import com.idle.navigation.DeepLinkDestination
import com.idle.domain.usecase.profile.GetMyCenterProfileUseCase
import com.idle.navigation.DeepLinkDestination.CenterHome
import com.idle.navigation.DeepLinkDestination.CenterRegister
import com.idle.navigation.NavigationEvent
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.delay
Expand All @@ -26,6 +30,7 @@ class CenterPendingViewModel @Inject constructor(
private val logoutCenterUseCase: LogoutCenterUseCase,
private val sendCenterVerificationRequestUseCase: SendCenterVerificationRequestUseCase,
private val getCenterStatusUseCase: GetCenterStatusUseCase,
private val getMyCenterProfileUseCase: GetMyCenterProfileUseCase,
private val errorHelper: ErrorHelper,
private val eventHelper: EventHelper,
private val navigationHelper: com.idle.navigation.NavigationHelper,
Expand Down Expand Up @@ -75,19 +80,30 @@ class CenterPendingViewModel @Inject constructor(
getCenterStatusUseCase().onSuccess {
when (it.centerManagerAccountStatus) {
CenterManagerAccountStatus.APPROVED -> {
pollingJob.emit(false)
navigationHelper.navigateTo(
NavigationEvent.NavigateTo(
destination = DeepLinkDestination.CenterHome,
popUpTo = R.id.centerPendingFragment,
)
)

handleApprovedCenterStatus()
eventHelper.sendEvent(MainEvent.ShowToast("센터 인증이 완료되었습니다.", SUCCESS))
}

else -> Unit
}
}.onFailure { errorHelper.sendError(it) }
}

private fun handleApprovedCenterStatus() = viewModelScope.launch {
getMyCenterProfileUseCase().onSuccess {
navigationHelper.navigateTo(
NavigationEvent.NavigateTo(CenterHome, R.id.centerPendingFragment)
)
}.onFailure {
val error = it as HttpResponseException
if (error.apiErrorCode == ApiErrorCode.CenterNotFound) {
navigationHelper.navigateTo(
NavigationEvent.NavigateTo(
CenterRegister,
R.id.centerPendingFragment,
)
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class MainActivity : AppCompatActivity() {

override fun onResume() {
super.onResume()
networkObserver.checkNetworkState()
networkObserver.subscribeNetworkCallback()
if (networkObserver.networkState.value == NetworkState.CONNECTED) {
viewModel.connectWebSocket()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class NetworkObserver @Inject constructor(context: Context) {
internal fun unsubscribeNetworkCallback() =
connectivityManager.unregisterNetworkCallback(networkCallback)

private fun subscribeNetworkCallback() {
internal fun subscribeNetworkCallback() {
val networkRequest = NetworkRequest.Builder()
.addTransportType(TRANSPORT_WIFI)
.addTransportType(TRANSPORT_CELLULAR)
Expand Down

0 comments on commit b62a5cc

Please sign in to comment.