From 84c9a73c042ed8336db733bd4d467d7a8d964d1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=95=88=EB=B3=91=ED=97=8C?= <64366488+Heonbyeong@users.noreply.github.com> Date: Tue, 1 Oct 2024 16:54:02 +0900 Subject: [PATCH] =?UTF-8?q?Feature/moneymong=20509=20=EC=9E=A5=EB=B6=80=20?= =?UTF-8?q?=EB=82=B4=EC=97=AD=20=EA=B8=B0=EA=B0=84=EB=B3=84=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=9D=B4=EC=8A=88=20=EC=88=98=EC=A0=95=20(#34)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 장부 조회 종료 연도가 시작 연도보다 작아도 동작하는 이슈 수정 * fix: 소속 변경 시 조회 기간 초기화 --- .../datepicker/MDSBottomSheetDatePicker.kt | 7 +---- .../moneymong/ledger/LedgerViewModel.kt | 27 ++++++++++--------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/core/design-system/src/main/java/com/moneymong/moneymong/design_system/component/datepicker/MDSBottomSheetDatePicker.kt b/core/design-system/src/main/java/com/moneymong/moneymong/design_system/component/datepicker/MDSBottomSheetDatePicker.kt index 499fe81b..80dbcf93 100644 --- a/core/design-system/src/main/java/com/moneymong/moneymong/design_system/component/datepicker/MDSBottomSheetDatePicker.kt +++ b/core/design-system/src/main/java/com/moneymong/moneymong/design_system/component/datepicker/MDSBottomSheetDatePicker.kt @@ -135,12 +135,7 @@ fun MDSWheelDatePicker( snappedEndYear, snappedEndMonth ) { - isValidValue = if (snappedStartYear < snappedEndYear) { - true - } else { - snappedStartMonth <= snappedEndMonth - } - + isValidValue = snappedStartYear <= snappedEndYear && snappedStartMonth <= snappedEndMonth confirmValidValue(isValidValue) } diff --git a/feature/ledger/src/main/java/com/moneymong/moneymong/ledger/LedgerViewModel.kt b/feature/ledger/src/main/java/com/moneymong/moneymong/ledger/LedgerViewModel.kt index 5c0ec38a..1da493e5 100644 --- a/feature/ledger/src/main/java/com/moneymong/moneymong/ledger/LedgerViewModel.kt +++ b/feature/ledger/src/main/java/com/moneymong/moneymong/ledger/LedgerViewModel.kt @@ -74,7 +74,7 @@ class LedgerViewModel @Inject constructor( reduce { state.copy(isAgencyExistLoading = true) } fetchAgencyExistLedgerUseCase(state.agencyId) .onSuccess { - Log.d("fetchAgencyExistLedger${state.agencyId}",it.toString() ) + Log.d("fetchAgencyExistLedger${state.agencyId}", it.toString()) reduce { state.copy( isExistLedger = it, @@ -96,7 +96,7 @@ class LedgerViewModel @Inject constructor( page = 0, limit = 100 ).onSuccess { - Log.d("fetchLedgerTransactionList${state.existAgency}",it.toString() ) + Log.d("fetchLedgerTransactionList${state.existAgency}", it.toString()) reduce { state.copy( @@ -127,7 +127,7 @@ class LedgerViewModel @Inject constructor( reduce { state.copy(isMyAgencyLoading = true) } fetchMyAgencyListUseCase() .onSuccess { - Log.d("fetchMyAgencyList${state.existAgency}",it.toString() ) + Log.d("fetchMyAgencyList${state.existAgency}", it.toString()) reduce { state.copy( @@ -188,6 +188,7 @@ class LedgerViewModel @Inject constructor( fun reFetchLedgerData(agencyId: Int) { saveAgencyId(agencyId) + updateSelectedDate(startDate = LocalDate.now().minusMonths(6), endDate = LocalDate.now()) fetchAgencyExistLedger() fetchAgencyMemberList() fetchLedgerTransactionList() @@ -227,15 +228,8 @@ class LedgerViewModel @Inject constructor( } fun onClickDateChange(startDate: LocalDate, endDate: LocalDate) { - intent { - reduce { - state.copy( - startDate = startDate, - endDate = endDate - ) - } - postSideEffect(LedgerSideEffect.LedgerCloseSheet) - } + updateSelectedDate(startDate = startDate, endDate = endDate) + eventEmit(LedgerSideEffect.LedgerCloseSheet) fetchLedgerTransactionList() } @@ -262,4 +256,13 @@ class LedgerViewModel @Inject constructor( ) } } + + fun updateSelectedDate(startDate: LocalDate, endDate: LocalDate) = intent { + reduce { + state.copy( + startDate = startDate, + endDate = endDate + ) + } + } }