Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ interface ClientDetailsRepository {

suspend fun getClientCloseTemplate(): DataState<ClientCloseTemplateResponse>

suspend fun getCollateralItems(): DataState<List<CollateralItem>>
suspend fun getCollateralItems(clientId: Int): DataState<List<CollateralItem>>

suspend fun getClient(clientId: Int): ClientEntity

Expand Down Expand Up @@ -69,4 +69,6 @@ interface ClientDetailsRepository {
collateralId: Int,
quantity: String,
): DataState<Unit>


}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ClientDetailsRepositoryImp(
}
}

override suspend fun getCollateralItems(): DataState<List<CollateralItem>> {
override suspend fun getCollateralItems(clientId: Int): DataState<List<CollateralItem>> {
return try {
val res = dataManagerClient.getCollateralItems()
return DataState.Success(res)
Expand Down Expand Up @@ -201,4 +201,4 @@ class ClientDetailsRepositoryImp(
DataState.Error(e)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
* Copyright 2025 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/


/*
* Copyright 2025 Mifos Initiative
*
Expand All @@ -20,4 +31,4 @@ data class CollateralItem(
val currency: String,
val name: String,
val id: Int,
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
package com.mifos.core.ui.components


import androidclient.core.ui.generated.resources.Res
import androidclient.core.ui.generated.resources.client_share_accounts_approved_shares
import androidclient.core.ui.generated.resources.client_share_accounts_pending_for_approval_shares
Expand Down Expand Up @@ -500,6 +501,88 @@ fun MifosActionsShareListingComponent(
}
}
}
@Composable
fun MifosActionsCollateralDataComponent(
name: String,
quantity: String,
totalValue: String,
totalCollateralValue: String,
menuList: List<Actions>,
onActionClicked: (Actions) -> Unit,
) {
MifosActionsListingComponentOutline {
Column {
Column(
modifier = Modifier.padding(DesignToken.padding.large),
) {
MifosListingRowItem(
key = "Name",
value = name,
keyStyle = MifosTypography.titleSmallEmphasized,
valueStyle = MifosTypography.titleSmall,
)
Spacer(Modifier.height(DesignToken.padding.large))
Column(
verticalArrangement = Arrangement.spacedBy(DesignToken.padding.extraExtraSmall),
) {
MifosListingRowItem(
key = stringResource(Res.string.core_ui_quantity),
value = quantity,
)
MifosListingRowItem(
key = stringResource(Res.string.core_ui_total_value),
value = totalValue,
)
}
Spacer(Modifier.height(DesignToken.padding.medium))
MifosListingRowItem(
key = stringResource(Res.string.core_ui_total_collateral_value),
value = totalCollateralValue,
valueColor = MaterialTheme.colorScheme.primary,
)
}

Surface(
modifier = Modifier.fillMaxWidth(),
shape = RoundedCornerShape(
bottomStart = DesignToken.padding.medium,
bottomEnd = DesignToken.padding.medium,
),
) {
Column(
modifier = Modifier.padding(
vertical = DesignToken.padding.small,
),
) {
menuList.map { menuItem ->
Row(
modifier = Modifier.fillMaxWidth()
.height(DesignToken.sizes.avatarMedium)
.clickable {
onActionClicked(menuItem)
},
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Start,
) {
Icon(
modifier = Modifier.padding(horizontal = DesignToken.padding.large),
imageVector = menuItem.icon,
contentDescription = "",
)

Text(
modifier = Modifier.fillMaxWidth(),
text = menuItem::class.simpleName ?: "",
color = MaterialTheme.colorScheme.onSurface,
fontSize = MaterialTheme.typography.bodyLarge.fontSize,
)
}
}
}
}
}
}
}

@Composable
fun MifosActionsChargeListingComponent(
Expand Down Expand Up @@ -724,6 +807,7 @@ fun MifosActionsSavingsListingComponent(
}
}


@Composable
fun MifosActionsClientFeeListingComponent(
name: String,
Expand Down Expand Up @@ -1136,3 +1220,26 @@ private fun PreviewMifosActionsShareListingComponent() {
)
}
}
@Preview
@Composable
private fun PreviewMifosActionsCollateralDataComponent() {
MifosTheme {
MifosActionsCollateralDataComponent(
name = "Gold ",
quantity = "5",
totalValue = "$2500",
totalCollateralValue = "$2500",
menuList = listOf(
Actions.ViewAccount(),
Actions.ApproveAccount(),
),
onActionClicked = { action ->
when (action) {
is Actions.ViewAccount -> println(Actions.ViewDocument::class.simpleName)
is Actions.ApproveAccount -> println(Actions.ApproveAccount::class.simpleName)
else -> println("Action not Handled")
}
},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import com.mifos.core.data.repository.ClientDetailsRepository
import com.mifos.core.data.util.NetworkMonitor
import com.mifos.core.network.model.CollateralItem
import com.mifos.core.ui.components.ResultStatus

import com.mifos.core.ui.util.BaseViewModel

import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch

Expand All @@ -43,29 +45,28 @@ internal class ClientCollateralViewModel(
}

private suspend fun loadCollaterals() {
mutableStateFlow.update { it.copy(dialogState = ClientCollateralState.DialogState.Loading) }
val result = repo.getCollateralItems()
when (result) {
is DataState.Error -> {
mutableStateFlow.update {
it.copy(
dialogState = ClientCollateralState.DialogState.Error(
result.message,
),
)
}
}
is DataState.Success -> {
mutableStateFlow.update {
it.copy(
collaterals = result.data,
dialogState = null,
)
}
}
else -> Unit
when (result) {
is DataState.Error -> {
mutableStateFlow.update {
it.copy(
dialogState = ClientCollateralState.DialogState.Error(
result.message,
),
)
}
}
is DataState.Success -> {
mutableStateFlow.update {
it.copy(
collaterals = result.data,
dialogState = null,
)
}
}
else -> Unit
}
}

private suspend fun saveCollateral() {
mutableStateFlow.update { it.copy(dialogState = ClientCollateralState.DialogState.Loading) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ fun NavGraphBuilder.clientProfileGeneralDestination(
fixedDepositAccounts: (Int) -> Unit,
recurringDepositAccounts: (Int) -> Unit,
sharesAccounts: (Int) -> Unit,

collateralData: (Int) -> Unit,
) {
composable<ClientProfileGeneralRoute> {
Expand All @@ -42,6 +43,7 @@ fun NavGraphBuilder.clientProfileGeneralDestination(
sharesAccounts,
collateralData,


)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.mifos.feature.client.collateralData

import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable


import kotlinx.serialization.Serializable

@Serializable
data class ClientCollateralRoute(
val clientId : Int = -1,
)
fun NavGraphBuilder.clientCollateralDestination(
navController: NavController,
navigateToViewAccount: (Int) -> Unit,
) {
composable<ClientCollateralRoute> {
CollateralScreenRoute(
navController = navController,
viewAccount = navigateToViewAccount,
)
}

}
fun NavController.navigateCollateralScreen(
clientId : Int,
){
this.navigate(
ClientCollateralRoute(
clientId = clientId,
)


)
}
Loading