diff --git a/feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountScreen.kt b/feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountScreen.kt index 65a81db239..fc76634e5f 100644 --- a/feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountScreen.kt +++ b/feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountScreen.kt @@ -40,6 +40,7 @@ import mifos_mobile.feature.savings_account.generated.resources.feature_account_ import mifos_mobile.feature.savings_account.generated.resources.feature_savings_account import mifos_mobile.feature.savings_account.generated.resources.feature_savings_account_dashboard import mifos_mobile.feature.savings_account.generated.resources.feature_savings_account_items +import mifos_mobile.feature.savings_account.generated.resources.feature_savings_filter_pending_account import mifos_mobile.feature.savings_account.generated.resources.feature_savings_no_accounts_found import org.jetbrains.compose.resources.StringResource import org.jetbrains.compose.resources.stringResource @@ -52,7 +53,7 @@ import org.mifos.mobile.core.designsystem.theme.AppColors import org.mifos.mobile.core.designsystem.theme.DesignToken import org.mifos.mobile.core.designsystem.theme.MifosMobileTheme import org.mifos.mobile.core.designsystem.theme.MifosTypography -import org.mifos.mobile.core.model.LoanStatus +import org.mifos.mobile.core.model.SavingStatus import org.mifos.mobile.core.ui.component.EmptyDataView import org.mifos.mobile.core.ui.component.MifosAccountCard import org.mifos.mobile.core.ui.component.MifosDashboardCard @@ -254,6 +255,19 @@ internal fun SavingsAccountContent( ) } } else { + val statusOrder = remember { + listOf( + SavingStatus.ACTIVE.status, + SavingStatus.SUBMIT_AND_PENDING_APPROVAL.status, + SavingStatus.CLOSED.status, + SavingStatus.INACTIVE.status, + ) + } + val sortedAccounts = remember(state.savingsAccount) { + state.savingsAccount.orEmpty().sortedWith( + compareBy { statusOrder.indexOf(it.status?.value) }, + ) + } LazyColumn( modifier = Modifier .fillMaxSize() @@ -262,30 +276,34 @@ internal fun SavingsAccountContent( item { Spacer(modifier = Modifier.height(DesignToken.spacing.small)) } - items(state.savingsAccount.orEmpty()) { account -> + items(sortedAccounts) { account -> val color = when (account.status?.value) { - LoanStatus.ACTIVE.status -> AppColors.customEnable - LoanStatus.SUBMIT_AND_PENDING_APPROVAL.status -> AppColors.customYellow - LoanStatus.WITHDRAWN.status, LoanStatus.MATURED.status -> - MaterialTheme.colorScheme.error + SavingStatus.ACTIVE.status -> AppColors.customEnable + SavingStatus.SUBMIT_AND_PENDING_APPROVAL.status -> AppColors.customYellow + + SavingStatus.INACTIVE.status -> MaterialTheme.colorScheme.error + else -> MaterialTheme.colorScheme.onSurface } + val accountStatus = if (account.status?.active == true) { + CurrencyFormatter.format( + account.accountBalance, + account.currency?.code, + account.currency?.decimalPlaces, + ) + } else { + if (account.status?.value == SavingStatus.SUBMIT_AND_PENDING_APPROVAL.status) { + stringResource(Res.string.feature_savings_filter_pending_account) + } else { + account.status?.value ?: "" + } + } MifosAccountCard( accountId = account.id, accountNumber = account.accountNo, accountType = account.productName, - accountStatus = ( - if (account.status?.active == true) { - CurrencyFormatter.format( - account.accountBalance, - account.currency?.code, - account.currency?.decimalPlaces, - ) - } else { - account.status?.value ?: "" - } - ), + accountStatus = accountStatus, accountStatusColor = color, onAccountClick = { onAction( diff --git a/feature/third-party-transfer/src/commonMain/kotlin/org/mifos/mobile/feature/third/party/transfer/di/ThirdPartyTransferModule.kt b/feature/third-party-transfer/src/commonMain/kotlin/org/mifos/mobile/feature/third/party/transfer/di/ThirdPartyTransferModule.kt index e613131d2e..f22501bd60 100644 --- a/feature/third-party-transfer/src/commonMain/kotlin/org/mifos/mobile/feature/third/party/transfer/di/ThirdPartyTransferModule.kt +++ b/feature/third-party-transfer/src/commonMain/kotlin/org/mifos/mobile/feature/third/party/transfer/di/ThirdPartyTransferModule.kt @@ -13,6 +13,11 @@ import org.koin.core.module.dsl.viewModelOf import org.koin.dsl.module import org.mifos.mobile.feature.third.party.transfer.thirdPartyTransfer.TptViewModel +/** + * Koin module for the Third Party Transfer feature. + * + * This module provides the ViewModel for the TPT screen. + */ val ThirdPartyTransferModule = module { viewModelOf(::TptViewModel) } diff --git a/feature/third-party-transfer/src/commonMain/kotlin/org/mifos/mobile/feature/third/party/transfer/navigation/ThirdPartyTransferRoute.kt b/feature/third-party-transfer/src/commonMain/kotlin/org/mifos/mobile/feature/third/party/transfer/navigation/ThirdPartyTransferRoute.kt index 2895e26af8..521d088372 100644 --- a/feature/third-party-transfer/src/commonMain/kotlin/org/mifos/mobile/feature/third/party/transfer/navigation/ThirdPartyTransferRoute.kt +++ b/feature/third-party-transfer/src/commonMain/kotlin/org/mifos/mobile/feature/third/party/transfer/navigation/ThirdPartyTransferRoute.kt @@ -18,18 +18,44 @@ import org.mifos.mobile.core.model.entity.payload.ReviewTransferPayload import org.mifos.mobile.feature.third.party.transfer.thirdPartyTransfer.TptScreenRoute import org.mifos.mobile.feature.third.party.transfer.thirdPartyTransfer.tptScreenDestination +/** + * Sealed class representing the possible navigation destinations from the TPT screen. + */ sealed class TptNavigationDestination { - // Add more as needed - object Notification : TptNavigationDestination() + /** + * Navigation destination for the Notification screen. + */ + data object Notification : TptNavigationDestination() + + /** + * Navigation destination for the Transfer Process screen. + * + * @param payload The payload containing the details of the transfer to be reviewed. + */ class TransferProcess(val payload: ReviewTransferPayload) : TptNavigationDestination() - object AddBeneficiaryScreen : TptNavigationDestination() + + /** + * Navigation destination for the Add Beneficiary screen. + */ + data object AddBeneficiaryScreen : TptNavigationDestination() } +/** + * A type alias for the navigator function that handles navigation to a [TptNavigationDestination]. + */ typealias TptNavigator = (TptNavigationDestination) -> Unit +/** + * The route for the Third Party Transfer navigation graph. + */ @Serializable data object ThirdPartyTransferNavGraphRoute +/** + * Navigates to the TPT navigation graph. + * + * @param navOptions The navigation options to apply to this navigation. + */ fun NavController.navigateToTptGraph(navOptions: NavOptions? = null) { this.navigate( ThirdPartyTransferNavGraphRoute, @@ -37,6 +63,11 @@ fun NavController.navigateToTptGraph(navOptions: NavOptions? = null) { ) } +/** + * Defines the TPT navigation graph. + * + * @param onNavigate The navigator function to handle navigation to other screens. + */ fun NavGraphBuilder.tptGraphDestination( onNavigate: TptNavigator, ) { diff --git a/feature/third-party-transfer/src/commonMain/kotlin/org/mifos/mobile/feature/third/party/transfer/thirdPartyTransfer/TptScreen.kt b/feature/third-party-transfer/src/commonMain/kotlin/org/mifos/mobile/feature/third/party/transfer/thirdPartyTransfer/TptScreen.kt index cca9f77a08..1f40644be7 100644 --- a/feature/third-party-transfer/src/commonMain/kotlin/org/mifos/mobile/feature/third/party/transfer/thirdPartyTransfer/TptScreen.kt +++ b/feature/third-party-transfer/src/commonMain/kotlin/org/mifos/mobile/feature/third/party/transfer/thirdPartyTransfer/TptScreen.kt @@ -61,6 +61,12 @@ import org.mifos.mobile.core.ui.utils.ScreenUiState import org.mifos.mobile.feature.third.party.transfer.navigation.TptNavigationDestination import org.mifos.mobile.feature.third.party.transfer.navigation.TptNavigator +/** + * Composable function for the Third Party Transfer screen. + * + * @param onNavigate The navigator function to handle navigation to other screens. + * @param viewModel The ViewModel for the TPT screen. + */ @Composable internal fun TptScreen( onNavigate: TptNavigator, @@ -99,6 +105,12 @@ internal fun TptScreen( ) } +/** + * Composable function for displaying dialogs on the TPT screen. + * + * @param dialogState The current state of the dialog. + * @param onAction The action to be performed when the dialog is dismissed. + */ @Composable internal fun TptDialog( dialogState: TptState.DialogState?, @@ -118,6 +130,13 @@ internal fun TptDialog( } } +/** + * Composable function for the content of the TPT screen. + * + * @param state The current state of the TPT screen. + * @param onAction The action to be performed when a user interacts with the screen. + * @param modifier The modifier to be applied to the layout. + */ @Composable internal fun TprContent( state: TptState, @@ -177,6 +196,13 @@ internal fun TprContent( } } +/** + * Composable function for the TPT form. + * + * @param state The current state of the TPT screen. + * @param onAction The action to be performed when a user interacts with the form. + * @param modifier The modifier to be applied to the layout. + */ @Composable internal fun TptForm( state: TptState, diff --git a/feature/third-party-transfer/src/commonMain/kotlin/org/mifos/mobile/feature/third/party/transfer/thirdPartyTransfer/TptScreenRoute.kt b/feature/third-party-transfer/src/commonMain/kotlin/org/mifos/mobile/feature/third/party/transfer/thirdPartyTransfer/TptScreenRoute.kt index d4a27b5ed2..d3e33610e2 100644 --- a/feature/third-party-transfer/src/commonMain/kotlin/org/mifos/mobile/feature/third/party/transfer/thirdPartyTransfer/TptScreenRoute.kt +++ b/feature/third-party-transfer/src/commonMain/kotlin/org/mifos/mobile/feature/third/party/transfer/thirdPartyTransfer/TptScreenRoute.kt @@ -16,13 +16,26 @@ import kotlinx.serialization.Serializable import org.mifos.mobile.core.ui.composableWithSlideTransitions import org.mifos.mobile.feature.third.party.transfer.navigation.TptNavigator +/** + * The route for the TPT screen. + */ @Serializable data object TptScreenRoute +/** + * Navigates to the TPT screen. + * + * @param navOptions The navigation options to apply to this navigation. + */ fun NavController.navigateToTptScreen(navOptions: NavOptions? = null) { this.navigate(TptScreenRoute, navOptions) } +/** + * Defines the TPT screen destination. + * + * @param onNavigate The navigator function to handle navigation to other screens. + */ fun NavGraphBuilder.tptScreenDestination( onNavigate: TptNavigator, ) { diff --git a/feature/third-party-transfer/src/commonMain/kotlin/org/mifos/mobile/feature/third/party/transfer/thirdPartyTransfer/TptViewModel.kt b/feature/third-party-transfer/src/commonMain/kotlin/org/mifos/mobile/feature/third/party/transfer/thirdPartyTransfer/TptViewModel.kt index 310c4bf75d..c562f1c6ab 100644 --- a/feature/third-party-transfer/src/commonMain/kotlin/org/mifos/mobile/feature/third/party/transfer/thirdPartyTransfer/TptViewModel.kt +++ b/feature/third-party-transfer/src/commonMain/kotlin/org/mifos/mobile/feature/third/party/transfer/thirdPartyTransfer/TptViewModel.kt @@ -450,6 +450,7 @@ internal class TptViewModel( /** * Represents the state of the Make Transfer screen. * + * @property accountId The ID of the account. * @property clientId The ID of the current user. * @property outstandingBalance The outstanding balance of the primary account, if applicable. * @property amount The amount entered by the user for the transfer.