diff --git a/core/src/main/java/com/terning/core/designsystem/component/bottomsheet/MyPageQuitBottomSheet.kt b/core/src/main/java/com/terning/core/designsystem/component/bottomsheet/MyPageQuitBottomSheet.kt index fe722d1aa..1f3d4414e 100644 --- a/core/src/main/java/com/terning/core/designsystem/component/bottomsheet/MyPageQuitBottomSheet.kt +++ b/core/src/main/java/com/terning/core/designsystem/component/bottomsheet/MyPageQuitBottomSheet.kt @@ -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 @@ -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, diff --git a/data/src/main/java/com/terning/data/datasource/MyPageDataSource.kt b/data/src/main/java/com/terning/data/datasource/MyPageDataSource.kt index aec35848d..b92bb80a5 100644 --- a/data/src/main/java/com/terning/data/datasource/MyPageDataSource.kt +++ b/data/src/main/java/com/terning/data/datasource/MyPageDataSource.kt @@ -4,4 +4,6 @@ import com.terning.data.dto.NonDataBaseResponse interface MyPageDataSource { suspend fun postLogout(): NonDataBaseResponse + + suspend fun deleteQuit(): NonDataBaseResponse } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/datasourceimpl/MyPageDataSourceImpl.kt b/data/src/main/java/com/terning/data/datasourceimpl/MyPageDataSourceImpl.kt index d884be7fc..f70adf162 100644 --- a/data/src/main/java/com/terning/data/datasourceimpl/MyPageDataSourceImpl.kt +++ b/data/src/main/java/com/terning/data/datasourceimpl/MyPageDataSourceImpl.kt @@ -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() } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/repositoryimpl/MyPageRepositoryImpl.kt b/data/src/main/java/com/terning/data/repositoryimpl/MyPageRepositoryImpl.kt index 580294a1d..447f7de68 100644 --- a/data/src/main/java/com/terning/data/repositoryimpl/MyPageRepositoryImpl.kt +++ b/data/src/main/java/com/terning/data/repositoryimpl/MyPageRepositoryImpl.kt @@ -11,4 +11,9 @@ class MyPageRepositoryImpl @Inject constructor( runCatching { myPageDataSource.postLogout() } + + override suspend fun deleteQuit(): Result = + runCatching{ + myPageDataSource.deleteQuit() + } } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/service/MyPageService.kt b/data/src/main/java/com/terning/data/service/MyPageService.kt index 9c73cd98c..6d5da1fc2 100644 --- a/data/src/main/java/com/terning/data/service/MyPageService.kt +++ b/data/src/main/java/com/terning/data/service/MyPageService.kt @@ -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 } \ No newline at end of file diff --git a/domain/src/main/java/com/terning/domain/repository/MyPageRepository.kt b/domain/src/main/java/com/terning/domain/repository/MyPageRepository.kt index 3e2ac65c7..2419f1b63 100644 --- a/domain/src/main/java/com/terning/domain/repository/MyPageRepository.kt +++ b/domain/src/main/java/com/terning/domain/repository/MyPageRepository.kt @@ -2,4 +2,6 @@ package com.terning.domain.repository interface MyPageRepository { suspend fun postLogout() : Result + + suspend fun deleteQuit() : Result } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/mypage/MyPageRoute.kt b/feature/src/main/java/com/terning/feature/mypage/MyPageRoute.kt index 41173af9a..31ac78a82 100644 --- a/feature/src/main/java/com/terning/feature/mypage/MyPageRoute.kt +++ b/feature/src/main/java/com/terning/feature/mypage/MyPageRoute.kt @@ -59,7 +59,7 @@ fun MyPageRoute( MyPageQuitBottomSheet( onDismiss = { showQuitBottomSheet = false }, onQuitClick = { - viewModel.patchQuit() + viewModel.quitKakao() } ) } diff --git a/feature/src/main/java/com/terning/feature/mypage/MyPageViewModel.kt b/feature/src/main/java/com/terning/feature/mypage/MyPageViewModel.kt index fdcbf8c50..b1eff6c6b 100644 --- a/feature/src/main/java/com/terning/feature/mypage/MyPageViewModel.kt +++ b/feature/src/main/java/com/terning/feature/mypage/MyPageViewModel.kt @@ -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())) + } + } } } \ No newline at end of file