Skip to content

Commit

Permalink
[MERGE] #116 -> develop
Browse files Browse the repository at this point in the history
[FEAT/#116] κ³„μ •νƒˆν‡΄ / μ„œλ²„ν†΅μ‹  κ΅¬ν˜„
  • Loading branch information
leeeyubin authored Jul 17, 2024
2 parents 2dc83de + 11e8ea9 commit 2effe98
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import com.terning.core.R
import com.terning.core.designsystem.component.button.DeleteRoundButton
import com.terning.core.designsystem.component.button.RoundButton
import com.terning.core.designsystem.theme.TerningTheme
import kotlinx.coroutines.launch

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand Down Expand Up @@ -50,12 +49,7 @@ fun MyPageQuitBottomSheet(
cornerRadius = 10.dp,
text = R.string.my_page_quit_button,
onButtonClick = {
scope.launch { sheetState.hide() }
.invokeOnCompletion {
if (!sheetState.isVisible) {
onQuitClick()
}
}
onQuitClick()
},
modifier = modifier.padding(
start = 24.dp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ import com.terning.data.dto.NonDataBaseResponse

interface MyPageDataSource {
suspend fun postLogout(): NonDataBaseResponse

suspend fun deleteQuit(): NonDataBaseResponse
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ class MyPageDataSourceImpl @Inject constructor(
private val myPageService: MyPageService
) : MyPageDataSource {
override suspend fun postLogout(): NonDataBaseResponse = myPageService.postLogout()

override suspend fun deleteQuit(): NonDataBaseResponse = myPageService.deleteQuit()
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ class MyPageRepositoryImpl @Inject constructor(
runCatching {
myPageDataSource.postLogout()
}

override suspend fun deleteQuit(): Result<Unit> =
runCatching{
myPageDataSource.deleteQuit()
}
}
4 changes: 4 additions & 0 deletions data/src/main/java/com/terning/data/service/MyPageService.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.terning.data.service

import com.terning.data.dto.NonDataBaseResponse
import retrofit2.http.DELETE
import retrofit2.http.POST

interface MyPageService {
@POST("api/v1/auth/logout")
suspend fun postLogout(): NonDataBaseResponse

@DELETE("api/v1/auth/withdraw")
suspend fun deleteQuit(): NonDataBaseResponse
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ package com.terning.domain.repository

interface MyPageRepository {
suspend fun postLogout() : Result<Unit>

suspend fun deleteQuit() : Result<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fun MyPageRoute(
MyPageQuitBottomSheet(
onDismiss = { showQuitBottomSheet = false },
onQuitClick = {
viewModel.patchQuit()
viewModel.quitKakao()
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,24 @@ class MyPageViewModel @Inject constructor(
}
}

fun patchQuit() {
fun quitKakao() {
UserApiClient.instance.unlink { error ->
if (error == null) {
deleteQuit()
} else {
_state.value = _state.value.copy(isSuccess = UiState.Failure(error.toString()))
}
}
}

private fun deleteQuit() {
viewModelScope.launch {
myPageRepository.deleteQuit().onSuccess {
tokenRepository.clearInfo()
_state.value = _state.value.copy(isSuccess = UiState.Success(true))
}.onFailure {
_state.value = _state.value.copy(isSuccess = UiState.Failure(it.toString()))
}
}
}
}

0 comments on commit 2effe98

Please sign in to comment.