@@ -52,7 +52,7 @@ import org.mifos.mobile.core.designsystem.theme.AppColors
5252import org.mifos.mobile.core.designsystem.theme.DesignToken
5353import org.mifos.mobile.core.designsystem.theme.MifosMobileTheme
5454import org.mifos.mobile.core.designsystem.theme.MifosTypography
55- import org.mifos.mobile.core.model.LoanStatus
55+ import org.mifos.mobile.core.model.SavingStatus
5656import org.mifos.mobile.core.ui.component.EmptyDataView
5757import org.mifos.mobile.core.ui.component.MifosAccountCard
5858import org.mifos.mobile.core.ui.component.MifosDashboardCard
@@ -254,6 +254,19 @@ internal fun SavingsAccountContent(
254254 )
255255 }
256256 } else {
257+ val statusOrder = remember {
258+ listOf (
259+ SavingStatus .ACTIVE .status,
260+ SavingStatus .SUBMIT_AND_PENDING_APPROVAL .status,
261+ SavingStatus .CLOSED .status,
262+ SavingStatus .INACTIVE .status,
263+ )
264+ }
265+ val sortedAccounts = remember(state.savingsAccount) {
266+ state.savingsAccount.orEmpty().sortedWith(
267+ compareBy { statusOrder.indexOf(it.status?.value) },
268+ )
269+ }
257270 LazyColumn (
258271 modifier = Modifier
259272 .fillMaxSize()
@@ -262,30 +275,34 @@ internal fun SavingsAccountContent(
262275 item {
263276 Spacer (modifier = Modifier .height(DesignToken .spacing.small))
264277 }
265- items(state.savingsAccount.orEmpty() ) { account ->
278+ items(sortedAccounts ) { account ->
266279 val color = when (account.status?.value) {
267- LoanStatus .ACTIVE .status -> AppColors .customEnable
268- LoanStatus .SUBMIT_AND_PENDING_APPROVAL .status -> AppColors .customYellow
269- LoanStatus .WITHDRAWN .status, LoanStatus .MATURED .status ->
270- MaterialTheme .colorScheme.error
280+ SavingStatus .ACTIVE .status -> AppColors .customEnable
281+ SavingStatus .SUBMIT_AND_PENDING_APPROVAL .status -> AppColors .customYellow
282+
283+ SavingStatus .INACTIVE .status -> MaterialTheme .colorScheme.error
284+
271285 else -> MaterialTheme .colorScheme.onSurface
272286 }
287+ val accountStatus = if (account.status?.active == true ) {
288+ CurrencyFormatter .format(
289+ account.accountBalance,
290+ account.currency?.code,
291+ account.currency?.decimalPlaces,
292+ )
293+ } else {
294+ if (account.status?.value == SavingStatus .SUBMIT_AND_PENDING_APPROVAL .status) {
295+ " PENDING APPROVAL"
296+ } else {
297+ account.status?.value ? : " "
298+ }
299+ }
273300
274301 MifosAccountCard (
275302 accountId = account.id,
276303 accountNumber = account.accountNo,
277304 accountType = account.productName,
278- accountStatus = (
279- if (account.status?.active == true ) {
280- CurrencyFormatter .format(
281- account.accountBalance,
282- account.currency?.code,
283- account.currency?.decimalPlaces,
284- )
285- } else {
286- account.status?.value ? : " "
287- }
288- ),
305+ accountStatus = accountStatus,
289306 accountStatusColor = color,
290307 onAccountClick = {
291308 onAction(
0 commit comments