Skip to content

Commit

Permalink
Merge pull request #180 from SWM-KAWAI-MANS/PAR-355
Browse files Browse the repository at this point in the history
 #PAR-355 : 회원탈퇴 시 약관동의부터 다시 받도록 보장
  • Loading branch information
nohjunh authored Sep 18, 2023
2 parents 9f1cae0 + be0becf commit 9765a00
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import online.partyrun.partyrunapplication.core.common.result.onFailure
import online.partyrun.partyrunapplication.core.common.result.onSuccess
import online.partyrun.partyrunapplication.core.domain.agreement.SaveAgreementStateUseCase
import online.partyrun.partyrunapplication.core.domain.auth.GoogleSignOutUseCase
import online.partyrun.partyrunapplication.core.domain.member.DeleteAccountUseCase
import timber.log.Timber
Expand All @@ -17,8 +18,8 @@ import javax.inject.Inject
@HiltViewModel
class SettingsViewModel @Inject constructor(
private val deleteAccountUseCase: DeleteAccountUseCase,
private val googleSignOutUseCase: GoogleSignOutUseCase

private val googleSignOutUseCase: GoogleSignOutUseCase,
private val saveAgreementStateUseCase: SaveAgreementStateUseCase
) : ViewModel() {
private val _settingsUiState = MutableStateFlow(SettingsUiState())
val settingsUiState: StateFlow<SettingsUiState> = _settingsUiState
Expand All @@ -33,16 +34,20 @@ class SettingsViewModel @Inject constructor(
fun deleteAccount() = viewModelScope.launch {
deleteAccountUseCase().collect { result ->
result.onSuccess {
googleSignOutUseCase()
_settingsUiState.update { state ->
state.copy(
isAccountDeletionSuccess = true,
)
}
googleSignOutUseCase()
}.onFailure { errorMessage, code ->
Timber.e("$code $errorMessage")
}
}
}

}
fun saveAgreementState(isChecked: Boolean) = viewModelScope.launch {
saveAgreementStateUseCase(isChecked)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ private fun ConfirmButton(
) {
PartyRunGradientButton(
onClick = {
settingsViewModel.saveAgreementState(isChecked = false)
settingsViewModel.deleteAccount()
},
modifier = Modifier
Expand Down

0 comments on commit 9765a00

Please sign in to comment.