From 5a2ce6f6ff3710e922673220dd0acaa81e0ad5e8 Mon Sep 17 00:00:00 2001 From: 915dbfl Date: Thu, 23 Nov 2023 21:42:29 +0900 Subject: [PATCH 1/2] feat: add des for test business num 0000 #175 --- common-ui/src/main/res/values/strings.xml | 2 +- feature/login/src/main/res/layout/fragment_register_store.xml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/common-ui/src/main/res/values/strings.xml b/common-ui/src/main/res/values/strings.xml index 695d5707..17a0f435 100644 --- a/common-ui/src/main/res/values/strings.xml +++ b/common-ui/src/main/res/values/strings.xml @@ -218,7 +218,7 @@ ex) 0101234123 인증에 성공하셨습니다! 사업자 등록 번호 입력 - 가게 등록을 위해 사업자등록번호를 입력해주세요! + 가게 등록을 위해 사업자등록번호를 입력해주세요!\n사업자번호가 없으시다면 0000을 입력해 테스트해보실 수 있습니다! 가게 이름 입력 추가적인 가게 정보를 알려주세요! ← 전화번호를 재인증 하시겠습니까? diff --git a/feature/login/src/main/res/layout/fragment_register_store.xml b/feature/login/src/main/res/layout/fragment_register_store.xml index 4f3973e7..81aaa6d8 100644 --- a/feature/login/src/main/res/layout/fragment_register_store.xml +++ b/feature/login/src/main/res/layout/fragment_register_store.xml @@ -36,7 +36,6 @@ app:layout_constraintVertical_chainStyle="packed" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toTopOf="@id/cl_business_registration_num" - app:layout_constraintEnd_toEndOf="@id/cl_business_registration_num" app:layout_constraintStart_toStartOf="@id/cl_business_registration_num"> Date: Thu, 23 Nov 2023 21:44:55 +0900 Subject: [PATCH 2/2] feat: add logic for register test store #175 --- .../att/login/store/RegisterStoreViewModel.kt | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/feature/login/src/main/java/org/swm/att/login/store/RegisterStoreViewModel.kt b/feature/login/src/main/java/org/swm/att/login/store/RegisterStoreViewModel.kt index 35552946..5d0bc8fa 100644 --- a/feature/login/src/main/java/org/swm/att/login/store/RegisterStoreViewModel.kt +++ b/feature/login/src/main/java/org/swm/att/login/store/RegisterStoreViewModel.kt @@ -1,7 +1,5 @@ package org.swm.att.login.store -import androidx.lifecycle.LiveData -import androidx.lifecycle.MutableLiveData import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableStateFlow @@ -17,7 +15,6 @@ import org.swm.att.domain.entity.response.StoreIdVO import org.swm.att.domain.entity.response.StoreListVO import org.swm.att.domain.entity.response.TokenVO import org.swm.att.domain.repository.AttPosUserRepository -import java.lang.IllegalArgumentException import javax.inject.Inject @HiltViewModel @@ -31,6 +28,7 @@ class RegisterStoreViewModel @Inject constructor( val registerStoreState: StateFlow> = _registerStoreState private val _getStoreState = MutableStateFlow>(UiState.Loading) val getStoreState: StateFlow> = _getStoreState + private var businessNumber: String? = null //login fun login(businessRegistrationNumber: String, certificatedPhoneToken: String?) { @@ -40,6 +38,7 @@ class RegisterStoreViewModel @Inject constructor( attPosUserRepository.login(userInfo).collect { result -> result.onSuccess { _loginState.value = UiState.Success(it) + businessNumber = businessRegistrationNumber }.onFailure { val errorMsg = if (it is HttpResponseException) it.message else "사업자 등록 번호 제출에 실패했습니다." _loginState.value = UiState.Error(errorMsg) @@ -79,14 +78,25 @@ class RegisterStoreViewModel @Inject constructor( viewModelScope.launch(attExceptionHandler) { try { val storeInfo = checkCreateStoreInfo(storeName) - attPosUserRepository.registerStoreForTest(storeInfo).collect { result -> - //attPosUserRepository.registerStore(storeInfo).collect { result -> - result.onSuccess { - _registerStoreState.value = UiState.Success(it) - saveStoreId(it.storeId) - }.onFailure { - val errorMsg = if (it is HttpResponseException) it.message else "가게 등록에 실패했습니다." - _registerStoreState.value = UiState.Error(errorMsg) + if (businessNumber == "0000" && storeInfo.name == "소예다방") { // TODO: 테스트 계정 생성을 위한 코드, 추후 삭제 필요 + attPosUserRepository.registerStoreForTest(storeInfo).collect { result -> + result.onSuccess { + _registerStoreState.value = UiState.Success(it) + saveStoreId(it.storeId) + }.onFailure { + val errorMsg = if (it is HttpResponseException) it.message else "가게 등록에 실패했습니다." + _registerStoreState.value = UiState.Error(errorMsg) + } + } + } else { + attPosUserRepository.registerStore(storeInfo).collect { result -> + result.onSuccess { + _registerStoreState.value = UiState.Success(it) + saveStoreId(it.storeId) + }.onFailure { + val errorMsg = if (it is HttpResponseException) it.message else "가게 등록에 실패했습니다." + _registerStoreState.value = UiState.Error(errorMsg) + } } } } catch (e: Exception) {