Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Bug #2855 - Added edit category functionality to Edit Planned payment…
Browse files Browse the repository at this point in the history
… screen (#2856)
  • Loading branch information
Subikesh authored Jan 2, 2024
1 parent 9e83d30 commit 427cb17
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,9 @@ private fun BoxWithConstraintsScope.UI(
CategoryModal(
modal = state.categoryModalData,
onCreateCategory = { onEvent(EditPlannedScreenEvent.OnCreateCategory(it)) },
onEditCategory = { },
onEditCategory = {
onEvent(EditPlannedScreenEvent.OnEditCategory(it))
},
dismiss = {
onEvent(EditPlannedScreenEvent.OnCategoryModalDataChanged(null))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ sealed interface EditPlannedScreenEvent {

data class OnSave(val closeScreen: Boolean = true) : EditPlannedScreenEvent
data object OnDelete : EditPlannedScreenEvent
data class OnEditCategory(val updatedCategory: Category) : EditPlannedScreenEvent
data class OnCreateCategory(val data: CreateCategoryData) : EditPlannedScreenEvent
data class OnCreateAccount(val data: CreateAccountData) : EditPlannedScreenEvent
data class OnCategoryModalVisible(val visible: Boolean) : EditPlannedScreenEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ class EditPlannedViewModel @Inject constructor(
is EditPlannedScreenEvent.OnRuleChanged ->
updateRule(event.startDate, event.oneTime, event.intervalN, event.intervalType)
is EditPlannedScreenEvent.OnCategoryChanged -> updateCategory(event.newCategory)
is EditPlannedScreenEvent.OnEditCategory -> editCategory(event.updatedCategory)
is EditPlannedScreenEvent.OnCategoryModalVisible ->
categoryModalVisible.value = event.visible
is EditPlannedScreenEvent.OnCategoryModalDataChanged ->
Expand Down Expand Up @@ -476,6 +477,14 @@ class EditPlannedViewModel @Inject constructor(
}
}

private fun editCategory(updatedCategory: Category) {
viewModelScope.launch {
categoryCreator.editCategory(updatedCategory) {
categories.value = categoriesAct(Unit)
}
}
}

private fun createAccount(data: CreateAccountData) {
viewModelScope.launch {
accountCreator.createAccount(data) {
Expand Down

0 comments on commit 427cb17

Please sign in to comment.