Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

장부, 봉투 생성 시 상세 화면 이동 / 받은 장부 목록 쿼리 수정 #168

Merged
merged 4 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ class LedgerRepositoryImpl @Inject constructor(
title: String?,
categoryIdList: List<Int>?,
fromStartAt: LocalDateTime,
toEndAt: LocalDateTime,
toStartAt: LocalDateTime,
page: Int?,
sort: String?,
): List<Ledger> = ledgerService.getLedgerList(
title = title,
categoryIdList = categoryIdList,
fromStartAt = fromStartAt.toKotlinLocalDateTime(),
toEndAt = toEndAt.toKotlinLocalDateTime(),
toStartAt = toStartAt.toKotlinLocalDateTime(),
page = page,
sort = sort,
).getOrThrow().toModel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface LedgerService {
@Query("title") title: String?,
@Query("categoryIds") categoryIdList: List<Int>?,
@Query("fromStartAt") fromStartAt: LocalDateTime,
@Query("toEndAt") toEndAt: LocalDateTime,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

스웨거 보니까 toEndAt도 남아있던데, toStartAt이 toEndAt를 완전히 대체하는 것인가요? 아님 toStartAt이랑 toEndAt이랑 다른 쿼리인가요?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

완전히 바뀔 예정인걸로 알아요!

자세한 히스토리는 ... https://www.notion.so/489e952079c9405f9322a18eabe01084?pvs=4

요거 참고 부탁드림다

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아아 이거 관련이엇군요 친절한 링크제공 감사합니다

@Query("toStartAt") toStartAt: LocalDateTime,
@Query("page") page: Int?,
@Query("sort") sort: String?,
): ApiResult<LedgerListResponse>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface LedgerRepository {
title: String?,
categoryIdList: List<Int>?,
fromStartAt: LocalDateTime,
toEndAt: LocalDateTime,
toStartAt: LocalDateTime,
page: Int?,
sort: String?,
): List<Ledger>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class GetLedgerListUseCase @Inject constructor(
title = title,
categoryIdList = categoryIdList,
fromStartAt = fromStartAt ?: LocalDateTime.now().minusYears(100),
toEndAt = toEndAt ?: LocalDateTime.now().plusYears(100),
toStartAt = toStartAt ?: LocalDateTime.now().plusYears(100),
page = page,
sort = sort,
)
Expand All @@ -25,7 +25,7 @@ class GetLedgerListUseCase @Inject constructor(
val title: String? = null,
val categoryIdList: List<Int>? = null,
val fromStartAt: LocalDateTime? = null,
val toEndAt: LocalDateTime? = null,
val toStartAt: LocalDateTime? = null,
val page: Int? = null,
val sort: String? = null,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.susu.feature.received.envelopeadd

import androidx.annotation.StringRes
import com.susu.core.model.Envelope
import com.susu.core.model.Ledger
import com.susu.core.ui.base.SideEffect
import com.susu.core.ui.base.UiState
import com.susu.feature.received.R
Expand Down Expand Up @@ -37,7 +39,7 @@ enum class EnvelopeAddStep(
sealed interface ReceivedEnvelopeAddSideEffect : SideEffect {
data class ShowSnackbar(val message: String) : ReceivedEnvelopeAddSideEffect
data object PopBackStack : ReceivedEnvelopeAddSideEffect
data class PopBackStackWithEnvelope(val envelope: String) : ReceivedEnvelopeAddSideEffect
data class NavigateEnvelopeDetail(val envelope: Envelope, val ledger: Ledger) : ReceivedEnvelopeAddSideEffect
data class HandleException(val throwable: Throwable, val retry: () -> Unit) : ReceivedEnvelopeAddSideEffect
data class LogClickNextButton(val step: EnvelopeAddStep) : ReceivedEnvelopeAddSideEffect
data class LogClickBackButton(val step: EnvelopeAddStep) : ReceivedEnvelopeAddSideEffect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ 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.Envelope
import com.susu.core.model.Ledger
import com.susu.core.model.Relationship
import com.susu.core.ui.SnackbarToken
import com.susu.core.ui.extension.collectWithLifecycle
Expand All @@ -50,7 +52,7 @@ import java.time.LocalDateTime
fun ReceivedEnvelopeAddRoute(
viewModel: ReceivedEnvelopeAddViewModel = hiltViewModel(),
popBackStack: () -> Unit,
popBackStackWithEnvelope: (String) -> Unit,
navigateEnvelopeDetail: (Envelope, Ledger) -> Unit,
onShowSnackbar: (SnackbarToken) -> Unit,
handleException: (Throwable, () -> Unit) -> Unit,
) {
Expand All @@ -64,7 +66,7 @@ fun ReceivedEnvelopeAddRoute(
is ReceivedEnvelopeAddSideEffect.HandleException -> handleException(sideEffect.throwable, sideEffect.retry)
ReceivedEnvelopeAddSideEffect.PopBackStack -> popBackStack()
is ReceivedEnvelopeAddSideEffect.ShowSnackbar -> onShowSnackbar(SnackbarToken(message = sideEffect.message))
is ReceivedEnvelopeAddSideEffect.PopBackStackWithEnvelope -> popBackStackWithEnvelope(sideEffect.envelope)
is ReceivedEnvelopeAddSideEffect.NavigateEnvelopeDetail -> navigateEnvelopeDetail(sideEffect.envelope, sideEffect.ledger)
is ReceivedEnvelopeAddSideEffect.LogClickBackButton -> scope.launch {
FirebaseAnalytics.getInstance(context).logEvent(
FirebaseAnalytics.Event.SELECT_CONTENT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.susu.core.model.Relationship
import com.susu.core.model.exception.AlreadyRegisteredFriendPhoneNumberException
import com.susu.core.ui.base.BaseViewModel
import com.susu.core.ui.extension.decodeFromUri
import com.susu.core.ui.extension.encodeToUri
import com.susu.domain.usecase.envelope.CreateReceivedEnvelopeUseCase
import com.susu.feature.received.navigation.ReceivedRoute
import dagger.hilt.android.lifecycle.HiltViewModel
Expand Down Expand Up @@ -66,8 +65,8 @@ class ReceivedEnvelopeAddViewModel @Inject constructor(
handedOverAt = date!!.toKotlinLocalDateTime(),
hasVisited = hasVisited,
),
).onSuccess {
postSideEffect(ReceivedEnvelopeAddSideEffect.PopBackStackWithEnvelope(Json.encodeToUri(it)))
).onSuccess { envelope ->
postSideEffect(ReceivedEnvelopeAddSideEffect.NavigateEnvelopeDetail(envelope, ledger))
}.onFailure { throwable ->
when (throwable) {
is AlreadyRegisteredFriendPhoneNumberException -> postSideEffect(ReceivedEnvelopeAddSideEffect.ShowSnackbar(throwable.message))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.susu.feature.received.ledgeradd

import com.susu.core.model.Ledger
import com.susu.core.ui.base.SideEffect
import com.susu.core.ui.base.UiState

Expand All @@ -18,6 +19,6 @@ enum class LedgerAddStep {
sealed interface LedgerAddSideEffect : SideEffect {
data object HideKeyboard : LedgerAddSideEffect
data object PopBackStack : LedgerAddSideEffect
data class PopBackStackWithLedger(val ledger: String) : LedgerAddSideEffect
data class NavigateLedgerDetail(val ledger: Ledger) : LedgerAddSideEffect
data class HandleException(val throwable: Throwable, val retry: () -> Unit) : LedgerAddSideEffect
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ 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.Category
import com.susu.core.model.Ledger
import com.susu.core.ui.R
import com.susu.core.ui.SnackbarToken
import com.susu.core.ui.extension.collectWithLifecycle
Expand All @@ -40,7 +41,7 @@ import java.time.LocalDateTime
fun LedgerAddRoute(
viewModel: LedgerAddViewModel = hiltViewModel(),
popBackStack: () -> Unit,
popBackStackWithLedger: (String) -> Unit,
navigateLedgerDetail: (Ledger) -> Unit,
onShowSnackbar: (SnackbarToken) -> Unit,
handleException: (Throwable, () -> Unit) -> Unit,
) {
Expand All @@ -50,7 +51,7 @@ fun LedgerAddRoute(
when (sideEffect) {
LedgerAddSideEffect.PopBackStack -> popBackStack()
is LedgerAddSideEffect.HandleException -> handleException(sideEffect.throwable, sideEffect.retry)
is LedgerAddSideEffect.PopBackStackWithLedger -> popBackStackWithLedger(sideEffect.ledger)
is LedgerAddSideEffect.NavigateLedgerDetail -> navigateLedgerDetail(sideEffect.ledger)
LedgerAddSideEffect.HideKeyboard -> keyboardController?.hide()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ import androidx.lifecycle.viewModelScope
import com.susu.core.model.Category
import com.susu.core.model.Ledger
import com.susu.core.ui.base.BaseViewModel
import com.susu.core.ui.extension.encodeToUri
import com.susu.domain.usecase.ledger.CreateLedgerUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.datetime.toKotlinLocalDateTime
import kotlinx.serialization.json.Json
import java.time.LocalDateTime
import javax.inject.Inject

Expand Down Expand Up @@ -80,7 +78,7 @@ class LedgerAddViewModel @Inject constructor(
category = selectedCategory!!,
),
).onSuccess { ledger ->
postSideEffect(LedgerAddSideEffect.PopBackStackWithLedger(Json.encodeToUri(ledger)))
postSideEffect(LedgerAddSideEffect.NavigateLedgerDetail(ledger))
}.onFailure {
postSideEffect(LedgerAddSideEffect.HandleException(it, ::createLedger))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ fun NavGraphBuilder.receivedNavGraph(
) {
LedgerAddRoute(
popBackStack = popBackStack,
popBackStackWithLedger = popBackStackWithLedger,
navigateLedgerDetail = { ledger ->
popBackStackWithLedger(Json.encodeToUri(ledger))
navigateLedgerDetail(ledger)
},
handleException = handleException,
onShowSnackbar = onShowSnackbar,
)
Expand All @@ -172,7 +175,10 @@ fun NavGraphBuilder.receivedNavGraph(
ReceivedEnvelopeAddRoute(
popBackStack = popBackStack,
onShowSnackbar = onShowSnackbar,
popBackStackWithEnvelope = popBackStackWithEnvelope,
navigateEnvelopeDetail = { envelope, ledger ->
popBackStackWithEnvelope(Json.encodeToUri(envelope))
navigateEnvelopeDetail(envelope, ledger)
},
handleException = handleException,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class ReceivedViewModel @Inject constructor(
page = page,
categoryIdList = filter.selectedCategoryList.map { it.id },
fromStartAt = currentState.startAt,
toEndAt = currentState.endAt,
toStartAt = currentState.endAt,
sort = LedgerAlign.entries[currentState.selectedAlignPosition].query,
),
).onSuccess { ledgerList ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.susu.core.ui.base.UiState

sealed interface EnvelopeAddEffect : SideEffect {
data object PopBackStack : EnvelopeAddEffect
data object PopBackStackWithRefresh : EnvelopeAddEffect
data class NavigateSentEnvelopeDetail(val id: Long) : EnvelopeAddEffect
data class HandleException(val throwable: Throwable, val retry: () -> Unit) : EnvelopeAddEffect
data class LogClickNextButton(val step: EnvelopeAddStep) : EnvelopeAddEffect
data class LogClickBackButton(val step: EnvelopeAddStep) : EnvelopeAddEffect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class EnvelopeAddViewModel @Inject constructor(
category = category!!,
),
).onSuccess {
postSideEffect(EnvelopeAddEffect.PopBackStackWithRefresh)
postSideEffect(EnvelopeAddEffect.NavigateSentEnvelopeDetail(it.id))
}.onFailure {
postSideEffect(EnvelopeAddEffect.HandleException(it, ::createEnvelope))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import java.time.LocalDateTime
fun SentEnvelopeAddRoute(
viewModel: EnvelopeAddViewModel = hiltViewModel(),
popBackStack: () -> Unit,
popBackStackWithRefresh: () -> Unit,
navigateSentEnvelopeDetail: (Long) -> Unit,
onShowSnackbar: (SnackbarToken) -> Unit,
handleException: (Throwable, () -> Unit) -> Unit,
) {
Expand All @@ -64,7 +64,7 @@ fun SentEnvelopeAddRoute(
when (sideEffect) {
is EnvelopeAddEffect.HandleException -> handleException(sideEffect.throwable, sideEffect.retry)
EnvelopeAddEffect.PopBackStack -> popBackStack()
EnvelopeAddEffect.PopBackStackWithRefresh -> popBackStackWithRefresh()
is EnvelopeAddEffect.NavigateSentEnvelopeDetail -> navigateSentEnvelopeDetail(sideEffect.id)
is EnvelopeAddEffect.LogClickBackButton -> scope.launch {
FirebaseAnalytics.getInstance(context).logEvent(
FirebaseAnalytics.Event.SELECT_CONTENT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ fun NavGraphBuilder.sentNavGraph(
composable(route = SentRoute.sentEnvelopeAddRoute("{${SentRoute.FRIEND_ARGUMENT_NAME}}")) {
SentEnvelopeAddRoute(
popBackStack = popBackStack,
popBackStackWithRefresh = popBackStackWithRefresh,
navigateSentEnvelopeDetail = {
popBackStackWithRefresh()
navigateSentEnvelopeDetail(it)
},
handleException = handleException,
onShowSnackbar = onShowSnackbar,
)
Expand Down
Loading