diff --git a/feature/gifticon/src/main/java/com/yapp/buddycon/gifticon/register/GifticonRegisterScreen.kt b/feature/gifticon/src/main/java/com/yapp/buddycon/gifticon/register/GifticonRegisterScreen.kt index 2e178ee1..a197299f 100644 --- a/feature/gifticon/src/main/java/com/yapp/buddycon/gifticon/register/GifticonRegisterScreen.kt +++ b/feature/gifticon/src/main/java/com/yapp/buddycon/gifticon/register/GifticonRegisterScreen.kt @@ -62,6 +62,7 @@ import com.yapp.buddycon.designsystem.theme.BuddyConTheme import com.yapp.buddycon.designsystem.theme.Grey30 import com.yapp.buddycon.designsystem.theme.Grey70 import com.yapp.buddycon.designsystem.theme.Paddings +import com.yapp.buddycon.domain.model.type.GifticonCategory import com.yapp.buddycon.gifticon.GifticonViewModel import timber.log.Timber import java.io.IOException @@ -207,7 +208,7 @@ fun GifticonRegisterScreen( ) { showErrorPopup = true } else { - if (uiState.name.isNotEmpty() && uiState.expireDate != 0L && uiState.store.isNotEmpty()) { + if (uiState.category != GifticonCategory.ETC) { gifticonRegisterViewModel.registerNewGifticon( imagePath = imageUri?.toString() ?: "" ) @@ -252,7 +253,7 @@ private fun GifticonRegisterContent( if (isShowCategoryModal) { CategoryModalSheet( - onSelectCategory = { gifticonRegisterViewModel.setUsage(it.value) }, + onSelectCategory = { gifticonRegisterViewModel.setCategory(it) }, onDismiss = { isShowCategoryModal = false } ) } @@ -318,7 +319,7 @@ private fun GifticonRegisterContent( modifier = Modifier.fillMaxWidth(), title = stringResource(R.string.gifticon_usage), placeholder = stringResource(R.string.gifticon_usage_placeholder), - value = uiState.store, + value = if (uiState.category == GifticonCategory.ETC) "" else uiState.category.value, action = { isShowCategoryModal = true } ) NoEssentialInputText( diff --git a/feature/gifticon/src/main/java/com/yapp/buddycon/gifticon/register/GifticonRegisterUiState.kt b/feature/gifticon/src/main/java/com/yapp/buddycon/gifticon/register/GifticonRegisterUiState.kt index 0e5cc0ea..748ac68e 100644 --- a/feature/gifticon/src/main/java/com/yapp/buddycon/gifticon/register/GifticonRegisterUiState.kt +++ b/feature/gifticon/src/main/java/com/yapp/buddycon/gifticon/register/GifticonRegisterUiState.kt @@ -1,8 +1,10 @@ package com.yapp.buddycon.gifticon.register +import com.yapp.buddycon.domain.model.type.GifticonCategory + data class GifticonRegisterUiState( val name: String = "", val expireDate: Long = 0L, - val store: String = "", + val category: GifticonCategory = GifticonCategory.ETC, val memo: String = "" ) diff --git a/feature/gifticon/src/main/java/com/yapp/buddycon/gifticon/register/GifticonRegisterViewModel.kt b/feature/gifticon/src/main/java/com/yapp/buddycon/gifticon/register/GifticonRegisterViewModel.kt index 7148f0fb..92ace2b1 100644 --- a/feature/gifticon/src/main/java/com/yapp/buddycon/gifticon/register/GifticonRegisterViewModel.kt +++ b/feature/gifticon/src/main/java/com/yapp/buddycon/gifticon/register/GifticonRegisterViewModel.kt @@ -2,6 +2,7 @@ package com.yapp.buddycon.gifticon.register import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.yapp.buddycon.domain.model.type.GifticonCategory import com.yapp.buddycon.domain.repository.GifticonRepository import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableSharedFlow @@ -11,6 +12,7 @@ import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import java.text.SimpleDateFormat +import java.util.Date import java.util.Locale import javax.inject.Inject @@ -33,8 +35,8 @@ class GifticonRegisterViewModel @Inject constructor( _uiState.value = _uiState.value.copy(expireDate = expireDate) } - fun setUsage(store: String) { - _uiState.value = _uiState.value.copy(store = store) + fun setCategory(category: GifticonCategory) { + _uiState.value = _uiState.value.copy(category = category) } fun setMemo(memo: String) { @@ -45,8 +47,8 @@ class GifticonRegisterViewModel @Inject constructor( gifticonRepository.createGifticon( imagePath = imagePath, name = uiState.value.name, - expireDate = SimpleDateFormat("yyyy-MM-dd", Locale.KOREA).format(uiState.value.expireDate), - store = uiState.value.store, + expireDate = SimpleDateFormat("yyyy-MM-dd", Locale.KOREA).format(Date(uiState.value.expireDate)), + store = uiState.value.category.name, memo = uiState.value.memo ).onEach { _isCompleted.emit(it)