Skip to content

Commit

Permalink
[feat] #55 기프티콘 사용처 및 유효기간 파라미터 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
ows3090 committed Mar 3, 2024
1 parent 41af462 commit f540311
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() ?: ""
)
Expand Down Expand Up @@ -252,7 +253,7 @@ private fun GifticonRegisterContent(

if (isShowCategoryModal) {
CategoryModalSheet(
onSelectCategory = { gifticonRegisterViewModel.setUsage(it.value) },
onSelectCategory = { gifticonRegisterViewModel.setCategory(it) },
onDismiss = { isShowCategoryModal = false }
)
}
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = ""
)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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) {
Expand All @@ -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)
Expand Down

0 comments on commit f540311

Please sign in to comment.