diff --git a/core/src/main/java/com/terning/core/type/ProfileImage.kt b/core/src/main/java/com/terning/core/type/ProfileImage.kt index f4836df27..8ccc58040 100644 --- a/core/src/main/java/com/terning/core/type/ProfileImage.kt +++ b/core/src/main/java/com/terning/core/type/ProfileImage.kt @@ -24,7 +24,7 @@ enum class ProfileImage( "glass" -> GLASS "calendar" -> CALENDAR "passion" -> PASSION - else -> BASIC + else -> DEFAULT } fun toIndex(profileImage: ProfileImage): Int = 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 bc96ce7b0..a1560963c 100644 --- a/data/src/main/java/com/terning/data/datasourceimpl/MyPageDataSourceImpl.kt +++ b/data/src/main/java/com/terning/data/datasourceimpl/MyPageDataSourceImpl.kt @@ -19,5 +19,5 @@ class MyPageDataSourceImpl @Inject constructor( override suspend fun editProfile( request: MyPageProfileEditRequestDto - ): NonDataBaseResponse = myPageService.editProfile() + ): NonDataBaseResponse = myPageService.editProfile(request) } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/datasourceimpl/TokenReissueDataSourceImpl.kt b/data/src/main/java/com/terning/data/datasourceimpl/TokenReissueDataSourceImpl.kt index d4bae4bf0..3c7bebdfd 100644 --- a/data/src/main/java/com/terning/data/datasourceimpl/TokenReissueDataSourceImpl.kt +++ b/data/src/main/java/com/terning/data/datasourceimpl/TokenReissueDataSourceImpl.kt @@ -12,5 +12,5 @@ class TokenReissueDataSourceImpl @Inject constructor( override suspend fun postReissueToken( authorization: String ): BaseResponse = - tokenReissueService.postReissueToken(authorization) + tokenReissueService.postReissueToken("Bearer $authorization") } \ 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 6ce2d16ae..9b7a62b61 100644 --- a/data/src/main/java/com/terning/data/service/MyPageService.kt +++ b/data/src/main/java/com/terning/data/service/MyPageService.kt @@ -2,7 +2,9 @@ package com.terning.data.service import com.terning.data.dto.BaseResponse import com.terning.data.dto.NonDataBaseResponse +import com.terning.data.dto.request.MyPageProfileEditRequestDto import com.terning.data.dto.response.MyPageResponseDto +import retrofit2.http.Body import retrofit2.http.DELETE import retrofit2.http.GET import retrofit2.http.PATCH @@ -19,5 +21,7 @@ interface MyPageService { suspend fun getProfile(): BaseResponse @PATCH("api/v1/mypage/profile") - suspend fun editProfile(): NonDataBaseResponse + suspend fun editProfile( + @Body body: MyPageProfileEditRequestDto + ): NonDataBaseResponse } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/mypage/mypage/MyPageRoute.kt b/feature/src/main/java/com/terning/feature/mypage/mypage/MyPageRoute.kt index 4ec22dbcc..10f4479af 100644 --- a/feature/src/main/java/com/terning/feature/mypage/mypage/MyPageRoute.kt +++ b/feature/src/main/java/com/terning/feature/mypage/mypage/MyPageRoute.kt @@ -73,6 +73,10 @@ fun MyPageRoute( } } + LaunchedEffect(true) { + viewModel.getProfile() + } + LaunchedEffect(viewModel.sideEffects, lifecycleOwner) { viewModel.sideEffects.flowWithLifecycle(lifecycle = lifecycleOwner.lifecycle) .collect { sideEffect -> diff --git a/feature/src/main/java/com/terning/feature/mypage/mypage/MyPageViewModel.kt b/feature/src/main/java/com/terning/feature/mypage/mypage/MyPageViewModel.kt index 535cf4b6d..485419852 100644 --- a/feature/src/main/java/com/terning/feature/mypage/mypage/MyPageViewModel.kt +++ b/feature/src/main/java/com/terning/feature/mypage/mypage/MyPageViewModel.kt @@ -31,10 +31,6 @@ class MyPageViewModel @Inject constructor( private val tokenRepository: TokenRepository ) : ViewModel() { - init { - getProfile() - } - private val _state: MutableStateFlow = MutableStateFlow(MyPageState()) val state: StateFlow get() = _state.asStateFlow() @@ -98,7 +94,7 @@ class MyPageViewModel @Inject constructor( } } - private fun getProfile() { + fun getProfile() { viewModelScope.launch { myPageRepository.getProfile() .onSuccess { response -> diff --git a/feature/src/main/java/com/terning/feature/mypage/profileedit/ProfileEditState.kt b/feature/src/main/java/com/terning/feature/mypage/profileedit/ProfileEditState.kt index a8f1d2b96..41d811f37 100644 --- a/feature/src/main/java/com/terning/feature/mypage/profileedit/ProfileEditState.kt +++ b/feature/src/main/java/com/terning/feature/mypage/profileedit/ProfileEditState.kt @@ -4,7 +4,9 @@ data class ProfileEditState( val name: String = "", val initialName: String = "", val profile: String = "", + val initialProfile: String = "", val initialView: Boolean = true, + val isModified: Boolean = false, val isButtonValid: Boolean = false, val authType: String = "", val showBottomSheet: Boolean = false diff --git a/feature/src/main/java/com/terning/feature/mypage/profileedit/ProfileEditViewModel.kt b/feature/src/main/java/com/terning/feature/mypage/profileedit/ProfileEditViewModel.kt index 5516b79c2..a12f19733 100644 --- a/feature/src/main/java/com/terning/feature/mypage/profileedit/ProfileEditViewModel.kt +++ b/feature/src/main/java/com/terning/feature/mypage/profileedit/ProfileEditViewModel.kt @@ -37,20 +37,26 @@ class ProfileEditViewModel @Inject constructor( name = initialName, initialName = initialName, profile = initialProfile, + initialProfile = initialProfile ) } fun updateName(name: String) { _state.value = _state.value.copy( name = name, - initialView = false + initialView = false, + isModified = true ) } fun updateProfile(profile: String) { + val isSameAsInitial = profile == _state.value.initialProfile + val isSameAsPrevious = profile == _state.value.profile + _state.value = _state.value.copy( profile = profile, - initialView = false + initialView = !_state.value.isModified && isSameAsInitial, + isModified = if (isSameAsPrevious) _state.value.isModified else !isSameAsInitial ) }