Skip to content

Commit aba93d2

Browse files
committed
updates
1 parent 44e8699 commit aba93d2

File tree

5 files changed

+64
-26
lines changed

5 files changed

+64
-26
lines changed

feature/beneficiary/src/commonMain/kotlin/org/mifos/mobile/feature/beneficiary/beneficiaryApplication/BeneficiaryApplicationViewModel.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,6 @@ data class BeneficiaryApplicationState(
439439
beneficiaryName.isNotEmpty()
440440
}
441441

442-
443442
/**
444443
* Data class to represent the events of the beneficiary application screen.
445444
*
@@ -452,6 +451,7 @@ sealed interface BeneficiaryApplicationEvent {
452451
* Navigate to the next screen.
453452
*/
454453
data object Navigate : BeneficiaryApplicationEvent
454+
455455
/***
456456
* Submit the beneficiary application.
457457
*
@@ -472,6 +472,7 @@ sealed interface BeneficiaryApplicationEvent {
472472
val accountNumber: String,
473473
val transferLimit: Int,
474474
) : BeneficiaryApplicationEvent
475+
475476
/***
476477
* Navigate to the QR screen.
477478
*/
@@ -493,46 +494,57 @@ sealed interface BeneficiaryApplicationAction {
493494
* Load the beneficiary template.
494495
*/
495496
data object LoadBeneficiaryTemplate : BeneficiaryApplicationAction
497+
496498
/***
497499
* Submit the beneficiary application.
498500
*/
499501
data object SubmitBeneficiary : BeneficiaryApplicationAction
502+
500503
/***
501504
* Navigate to the next screen.
502505
*/
503506
data object OnNavigate : BeneficiaryApplicationAction
507+
504508
/***
505509
* Retry the operation.
506510
*/
507511
data object OnRetry : BeneficiaryApplicationAction
512+
508513
/***
509514
* Navigate to the QR screen.
510515
*/
511516
data object NavigateToQR : BeneficiaryApplicationAction
517+
512518
/***
513519
* Account type changed.
514520
*/
515521
data class OnAccountTypeChanged(val accountType: Int) : BeneficiaryApplicationAction
522+
516523
/***
517524
* Account number changed.
518525
*/
519526
data class OnAccountNumberChanged(val accountNumber: String) : BeneficiaryApplicationAction
527+
520528
/***
521529
* Office name changed.
522530
*/
523531
data class OnOfficeNameChanged(val officeName: String) : BeneficiaryApplicationAction
532+
524533
/***
525534
* Transfer limit changed.
526535
*/
527536
data class OnTransferLimitChanged(val transferLimit: String) : BeneficiaryApplicationAction
537+
528538
/***
529539
* Beneficiary name changed.
530540
*/
531541
data class OnBeneficiaryNameChanged(val beneficiaryName: String) : BeneficiaryApplicationAction
542+
532543
/***
533544
* Receive network status.
534545
*/
535546
data class ReceiveNetworkStatus(val isOnline: Boolean) : BeneficiaryApplicationAction
547+
536548
/***
537549
* Internal action.
538550
*/

feature/beneficiary/src/commonMain/kotlin/org/mifos/mobile/feature/beneficiary/beneficiaryApplicationConfirmation/BeneficiaryApplicationConfirmationNavigation.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import androidx.navigation.NavOptions
1717
import kotlinx.serialization.Serializable
1818
import org.mifos.mobile.core.ui.composableWithSlideTransitions
1919

20-
2120
/**
2221
* Data class representing the navigation route for the beneficiary application confirmation screen.
2322
*

feature/beneficiary/src/commonMain/kotlin/org/mifos/mobile/feature/beneficiary/beneficiaryApplicationConfirmation/BeneficiaryApplicationConfirmationViewModel.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@ internal class BeneficiaryApplicationConfirmationViewModel(
165165
}
166166

167167
/**
168-
* Handles the result of the beneficiary creation API call.
169-
* If the API call is successful, navigates the user to the beneficiary status screen.
170-
* If the API call fails, navigates the user to the previous screen with an error message.
171-
*/
168+
* Handles the result of the beneficiary creation API call.
169+
* If the API call is successful, navigates the user to the beneficiary status screen.
170+
* If the API call fails, navigates the user to the previous screen with an error message.
171+
*/
172172
private fun processSubmitBeneficiaryResult(response: DataState<String>) {
173173
viewModelScope.launch {
174174
when (response) {
@@ -398,7 +398,6 @@ internal class BeneficiaryApplicationConfirmationViewModel(
398398
* @param networkStatus indicates whether the network is available.
399399
*/
400400

401-
402401
data class BeneficiaryApplicationConfirmationState(
403402
val details: Map<StringResource, String> = emptyMap(),
404403
val topBarTitle: StringResource = Res.string.add_beneficiary,
@@ -431,6 +430,7 @@ sealed interface BeneficiaryApplicationConfirmationEvent {
431430
* Represents the event of navigating back to the previous screen.
432431
*/
433432
data object Navigate : BeneficiaryApplicationConfirmationEvent
433+
434434
/**
435435
* Represents the event of navigating to the Beneficiary Status screen.
436436
*
@@ -448,6 +448,7 @@ sealed interface BeneficiaryApplicationConfirmationEvent {
448448

449449
val buttonText: String,
450450
) : BeneficiaryApplicationConfirmationEvent
451+
451452
/**
452453
* Represents the event of navigating to the Beneficiary Authentication screen.
453454
*
@@ -466,13 +467,13 @@ sealed interface BeneficiaryApplicationConfirmationEvent {
466467
* @param OnNavigate the action of navigating back to the previous screen.
467468
*/
468469

469-
470470
sealed interface BeneficiaryApplicationConfirmationAction {
471471

472472
/**
473473
* Represents the action of submitting the beneficiary application.
474474
*/
475475
data object SubmitBeneficiary : BeneficiaryApplicationConfirmationAction
476+
476477
/**
477478
* Represents the action of receiving the network status.
478479
*
@@ -484,6 +485,7 @@ sealed interface BeneficiaryApplicationConfirmationAction {
484485
* Represents the action of navigating back to the previous screen.
485486
*/
486487
data object OnNavigate : BeneficiaryApplicationConfirmationAction
488+
487489
/**
488490
* Represents the internal actions that can be performed on the Beneficiary Application Confirmation screen.
489491
*
@@ -498,12 +500,14 @@ sealed interface BeneficiaryApplicationConfirmationAction {
498500
* @param result indicates whether the authentication was successful.
499501
*/
500502
data class ReceiveAuthenticationResult(val result: Boolean) : Internal
503+
501504
/**
502505
* Represents the action of receiving the result of submitting the beneficiary application.
503506
*
504507
* @param result the data state of the submission result.
505508
*/
506509
data class ReceiveSubmitBeneficiary(val result: DataState<String>) : Internal
510+
507511
/**
508512
* Represents the action of receiving the result of updating the beneficiary application.
509513
*

feature/beneficiary/src/commonMain/kotlin/org/mifos/mobile/feature/beneficiary/beneficiaryDetail/BeneficiaryDetailViewModel.kt

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ internal class BeneficiaryDetailViewModel(
112112
}
113113

114114
/*
115-
* Update the view model state to show a loading state and then
116-
* an internal action to handle the list is sent.
117-
* */
115+
* Update the view model state to show a loading state and then
116+
* an internal action to handle the list is sent.
117+
* */
118118
private fun loadBeneficiary() {
119119
updateState {
120120
it.copy(
@@ -232,11 +232,11 @@ internal class BeneficiaryDetailViewModel(
232232
}
233233
}
234234

235-
/**
236-
* Handles actions from the UI.
237-
*
238-
* @param action The action to handle.
239-
*/
235+
/**
236+
* Handles actions from the UI.
237+
*
238+
* @param action The action to handle.
239+
*/
240240
override fun handleAction(action: BeneficiaryDetailAction) {
241241
when (action) {
242242
is BeneficiaryDetailAction.ReceiveNetworkStatus -> handleNetworkStatus(action.isOnline)
@@ -313,12 +313,12 @@ data class BeneficiaryDetailState(
313313
* @property UpdateBeneficiary Updates the beneficiary with the given ID.
314314
* */
315315

316-
317316
sealed interface BeneficiaryDetailEvent {
318317
/**
319318
* Navigates back to the previous screen.
320319
*/
321320
data object NavigateBack : BeneficiaryDetailEvent
321+
322322
/**
323323
* Updates the beneficiary with the given ID.
324324
*
@@ -344,32 +344,39 @@ sealed interface BeneficiaryDetailAction {
344344
* Refreshes the beneficiary list.
345345
*/
346346
data object OnRefresh : BeneficiaryDetailAction
347+
347348
/**
348349
* Updates the beneficiary with the given ID.
349350
*/
350351
data object OnUpdateBeneficiary : BeneficiaryDetailAction
352+
351353
/**
352354
* Deletes the beneficiary with the given ID.
353355
*/
354356
data object DeleteBeneficiary : BeneficiaryDetailAction
357+
355358
/**
356359
* Navigates to the beneficiary list screen.
357360
*/
358361
data object OnNavigate : BeneficiaryDetailAction
362+
359363
/**
360364
* Dismisses the error dialog.
361365
*/
362366
data object ErrorDialogDismiss : BeneficiaryDetailAction
367+
363368
/**
364369
* Shows the delete confirmation dialog.
365370
*/
366371
data object ShowDeleteConfirmation : BeneficiaryDetailAction
372+
367373
/**
368374
* Receives the network status.
369375
*
370376
* @property isOnline Whether the device is online or not.
371377
*/
372378
data class ReceiveNetworkStatus(val isOnline: Boolean) : BeneficiaryDetailAction
379+
373380
/**
374381
* Internal actions.
375382
*/
@@ -380,6 +387,7 @@ sealed interface BeneficiaryDetailAction {
380387
* @property result The result of loading a beneficiary.
381388
*/
382389
data class ReceiveBeneficiaryResult(val result: DataState<List<Beneficiary>>) : Internal
390+
383391
/**
384392
* Receives the result of deleting a beneficiary.
385393
*

feature/beneficiary/src/commonMain/kotlin/org/mifos/mobile/feature/beneficiary/beneficiaryList/BeneficiaryListViewModel.kt

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ internal class BeneficiaryListViewModel(
4545
init {
4646
observeNetwork()
4747
}
48+
4849
/**
4950
* Initialize the view model.
5051
*/
@@ -92,7 +93,6 @@ internal class BeneficiaryListViewModel(
9293
}
9394
}
9495

95-
9696
override fun handleAction(action: BeneficiaryListAction) {
9797
when (action) {
9898
is BeneficiaryListAction.ReceiveNetworkStatus -> handleNetworkStatus(action.isOnline)
@@ -199,6 +199,7 @@ internal class BeneficiaryListViewModel(
199199
}
200200
}
201201
}
202+
202203
/**
203204
* Handle the click on the add beneficiary button.
204205
*/
@@ -215,9 +216,9 @@ internal class BeneficiaryListViewModel(
215216
sendEvent(BeneficiaryListEvent.BeneficiaryItemClick(action.position))
216217
}
217218

218-
/**
219-
* Handle the click on the navigate button.
220-
*/
219+
/**
220+
* Handle the click on the navigate button.
221+
*/
221222
private fun handleNavigate() {
222223
sendEvent(BeneficiaryListEvent.Navigate)
223224
}
@@ -250,11 +251,12 @@ internal class BeneficiaryListViewModel(
250251
)
251252
}
252253
}
253-
/**
254-
* Handle the change of the selected accounts.
255-
*
256-
* @param action The action to handle.
257-
*/
254+
255+
/**
256+
* Handle the change of the selected accounts.
257+
*
258+
* @param action The action to handle.
259+
*/
258260
private fun handleAccountChange(action: BeneficiaryListAction.OnAccountChange) {
259261
val currentAccounts = state.selectedAccounts
260262
val updatedAccounts = if (currentAccounts.contains(action.account)) {
@@ -408,46 +410,57 @@ sealed interface BeneficiaryListAction {
408410
* Refresh the list of beneficiaries.
409411
*/
410412
data object RefreshBeneficiaries : BeneficiaryListAction
413+
411414
/**
412415
* Add a new beneficiary.
413416
*/
414417
data object OnAddBeneficiaryClicked : BeneficiaryListAction
418+
415419
/**
416420
* Click on a beneficiary item.
417421
*/
418422
data class OnBeneficiaryItemClick(val position: Long) : BeneficiaryListAction
423+
419424
/**
420425
* Navigate to another screen.
421426
*/
422427
data object OnNavigate : BeneficiaryListAction
428+
423429
/**
424430
* Toggle the filter dialog.
425431
*/
426432
data object ToggleFilter : BeneficiaryListAction
433+
427434
/**
428435
* Reset the filters.
429436
*/
430437
data object ResetFilters : BeneficiaryListAction
438+
431439
/**
432440
* Get the filter results.
433441
*/
434442
data object GetFilterResults : BeneficiaryListAction
443+
435444
/**
436445
* Dismiss the dialog.
437446
*/
438447
data object DismissDialog : BeneficiaryListAction
448+
439449
/**
440450
* Change the selected account.
441451
*/
442452
data class OnAccountChange(val account: String) : BeneficiaryListAction
453+
443454
/**
444455
* Change the selected office.
445456
*/
446457
data class OnOfficeChange(val office: String) : BeneficiaryListAction
458+
447459
/**
448460
* Load the beneficiaries.
449461
*/
450462
data object LoadBeneficiaries : BeneficiaryListAction
463+
451464
/**
452465
* Receive the network status.
453466
*/
@@ -477,10 +490,12 @@ sealed interface BeneficiaryListEvent {
477490
* Add a new beneficiary.
478491
*/
479492
data object AddBeneficiaryClicked : BeneficiaryListEvent
493+
480494
/**
481495
* Click on a beneficiary item.
482496
*/
483497
data class BeneficiaryItemClick(val position: Long) : BeneficiaryListEvent
498+
484499
/**
485500
* Navigate to another screen.
486501
*/

0 commit comments

Comments
 (0)