Skip to content

Commit

Permalink
fix: 약관 동의 응답 형식 정정
Browse files Browse the repository at this point in the history
  • Loading branch information
yangsooplus committed Jul 8, 2024
1 parent a02402f commit e286f6c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ data class TermResponse(
val id: Int,
val title: String,
val isEssential: Boolean,
val isIncludeDetail: Boolean = true,
)

@Serializable
Expand All @@ -23,6 +24,7 @@ fun TermResponse.toModel(): Term = Term(
id = id,
title = title,
isEssential = isEssential,
canRead = isIncludeDetail
)

fun TermDetailResponse.toModel(): TermDetail = TermDetail(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import com.susu.core.ui.Gender
import com.susu.core.ui.base.SideEffect
import com.susu.core.ui.base.UiState
import com.susu.feature.loginsignup.R
import kotlinx.collections.immutable.PersistentSet
import kotlinx.collections.immutable.persistentSetOf

sealed interface SignUpEffect : SideEffect {
data object NavigateToLogin : SignUpEffect
Expand All @@ -16,7 +18,7 @@ sealed interface SignUpEffect : SideEffect {
data class SignUpState(
val isLoading: Boolean = false,
val currentStep: SignUpStep = SignUpStep.TERMS,
val agreedTerms: List<Int> = emptyList(),
val agreedTerms: PersistentSet<Int> = persistentSetOf(),
val name: String = "",
val isNameValid: Boolean = true,
val gender: Gender = Gender.NONE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.RectangleShape
Expand All @@ -39,15 +38,14 @@ import com.susu.core.designsystem.component.button.MediumButtonStyle
import com.susu.core.designsystem.component.button.SusuFilledButton
import com.susu.core.designsystem.component.screen.LoadingScreen
import com.susu.core.designsystem.theme.SusuTheme
import com.susu.core.model.Term
import com.susu.core.ui.SnackbarToken
import com.susu.core.ui.USER_BIRTH_RANGE
import com.susu.core.ui.extension.collectWithLifecycle
import com.susu.feature.loginsignup.R
import com.susu.feature.loginsignup.signup.content.AdditionalContent
import com.susu.feature.loginsignup.signup.content.NameContent
import com.susu.feature.loginsignup.signup.content.TermsContent
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toPersistentList

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand Down Expand Up @@ -131,7 +129,7 @@ fun SignUpRoute(
modifier = Modifier.fillMaxSize(),
descriptionText = targetState.description?.let { stringResource(id = it) } ?: "",
terms = termState.terms,
agreedTerms = uiState.agreedTerms,
agreedTerms = uiState.agreedTerms.toPersistentList(),
onDetailClick = {
termViewModel.updateCurrentTerm(it)
viewModel.goTermDetail()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import com.susu.core.ui.base.BaseViewModel
import com.susu.domain.usecase.loginsignup.SignUpUseCase
import com.susu.feature.loginsignup.social.KakaoLoginHelper
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.collections.immutable.persistentSetOf
import kotlinx.collections.immutable.toPersistentSet
import kotlinx.coroutines.launch
import javax.inject.Inject

Expand Down Expand Up @@ -43,19 +45,19 @@ class SignUpViewModel @Inject constructor(
}

fun agreeTerm(termId: Int) {
intent { copy(agreedTerms = agreedTerms + termId) }
intent { copy(agreedTerms = agreedTerms.add(termId)) }
}

fun disagreeTerm(termId: Int) {
intent { copy(agreedTerms = agreedTerms - termId) }
intent { copy(agreedTerms = agreedTerms.remove(termId)) }
}

fun agreeAllTerms(entireTermIds: List<Int>) {
intent { copy(agreedTerms = entireTermIds) }
intent { copy(agreedTerms = entireTermIds.toPersistentSet()) }
}

fun disagreeAllTerms() {
intent { copy(agreedTerms = emptyList()) }
intent { copy(agreedTerms = persistentSetOf()) }
}

fun goNextStep() {
Expand Down Expand Up @@ -96,7 +98,7 @@ class SignUpViewModel @Inject constructor(
} else {
null
},
termAgreement = uiState.value.agreedTerms,
termAgreement = uiState.value.agreedTerms.toList(),
),
).onSuccess {
postSideEffect(SignUpEffect.NavigateToReceived)
Expand Down

0 comments on commit e286f6c

Please sign in to comment.