diff --git a/feature/history/src/commonMain/composeResources/values/strings.xml b/feature/history/src/commonMain/composeResources/values/strings.xml index a14ed054..9af67f4a 100644 --- a/feature/history/src/commonMain/composeResources/values/strings.xml +++ b/feature/history/src/commonMain/composeResources/values/strings.xml @@ -23,5 +23,10 @@ Loading No transactions found Specific Transactions History + Transaction Details + Share + Paid To + Debited From + Error \ No newline at end of file diff --git a/feature/history/src/commonMain/kotlin/org/mifospay/feature/history/components/TransactionDetail.kt b/feature/history/src/commonMain/kotlin/org/mifospay/feature/history/components/TransactionDetail.kt index 4c3d5a05..d40a2134 100644 --- a/feature/history/src/commonMain/kotlin/org/mifospay/feature/history/components/TransactionDetail.kt +++ b/feature/history/src/commonMain/kotlin/org/mifospay/feature/history/components/TransactionDetail.kt @@ -29,6 +29,12 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp +import mobile_wallet.feature.history.generated.resources.Res +import mobile_wallet.feature.history.generated.resources.feature_history_debited_from +import mobile_wallet.feature.history.generated.resources.feature_history_paid_to +import mobile_wallet.feature.history.generated.resources.feature_history_transaction_date +import mobile_wallet.feature.history.generated.resources.feature_history_transaction_id +import org.jetbrains.compose.resources.stringResource import org.mifospay.core.common.CurrencyFormatter import org.mifospay.core.common.DateHelper import org.mifospay.core.model.savingsaccount.TransferDetail @@ -57,7 +63,10 @@ internal fun TransactionDetail( horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically, ) { - Text(text = "Transaction ID", style = MaterialTheme.typography.labelLarge) + Text( + text = stringResource(Res.string.feature_history_transaction_id), + style = MaterialTheme.typography.labelLarge, + ) Text(text = detail.id.toString()) } @@ -70,7 +79,10 @@ internal fun TransactionDetail( horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically, ) { - Text(text = "Transaction Date", style = MaterialTheme.typography.labelLarge) + Text( + text = stringResource(Res.string.feature_history_transaction_date), + style = MaterialTheme.typography.labelLarge, + ) val date = DateHelper.getDateAsString(detail.transferDate) Text(text = date) } @@ -80,7 +92,7 @@ internal fun TransactionDetail( ) Text( - text = "Paid To", + text = stringResource(Res.string.feature_history_paid_to), style = MaterialTheme.typography.labelLarge, ) @@ -148,7 +160,7 @@ internal fun TransactionDetail( ) Text( - text = "Debited From", + text = stringResource(Res.string.feature_history_debited_from), style = MaterialTheme.typography.labelLarge, ) diff --git a/feature/history/src/commonMain/kotlin/org/mifospay/feature/history/detail/TransactionDetailScreen.kt b/feature/history/src/commonMain/kotlin/org/mifospay/feature/history/detail/TransactionDetailScreen.kt index 0c3d7da6..065ac805 100644 --- a/feature/history/src/commonMain/kotlin/org/mifospay/feature/history/detail/TransactionDetailScreen.kt +++ b/feature/history/src/commonMain/kotlin/org/mifospay/feature/history/detail/TransactionDetailScreen.kt @@ -25,6 +25,8 @@ import mobile_wallet.feature.history.generated.resources.Res import mobile_wallet.feature.history.generated.resources.feature_history_error import mobile_wallet.feature.history.generated.resources.feature_history_error_oops import mobile_wallet.feature.history.generated.resources.feature_history_loading +import mobile_wallet.feature.history.generated.resources.feature_history_share +import mobile_wallet.feature.history.generated.resources.feature_history_transaction_details import org.jetbrains.compose.resources.stringResource import org.koin.compose.viewmodel.koinViewModel import org.mifospay.core.designsystem.component.MifosLoadingWheel @@ -68,7 +70,7 @@ internal fun TransactionDetailScreenContent( ) { MifosScaffold( backPress = { onAction(TransactionDetailAction.NavigateBack) }, - topBarTitle = "Transaction Details", + topBarTitle = stringResource(Res.string.feature_history_transaction_details), actions = { IconButton( onClick = { @@ -77,7 +79,7 @@ internal fun TransactionDetailScreenContent( ) { Icon( imageVector = MifosIcons.OutlinedShare, - contentDescription = "Share", + contentDescription = stringResource(Res.string.feature_history_share), ) } }, diff --git a/feature/history/src/commonMain/kotlin/org/mifospay/feature/history/detail/TransactionDetailViewModel.kt b/feature/history/src/commonMain/kotlin/org/mifospay/feature/history/detail/TransactionDetailViewModel.kt index e2ab9132..e81a27ab 100644 --- a/feature/history/src/commonMain/kotlin/org/mifospay/feature/history/detail/TransactionDetailViewModel.kt +++ b/feature/history/src/commonMain/kotlin/org/mifospay/feature/history/detail/TransactionDetailViewModel.kt @@ -14,6 +14,9 @@ import androidx.lifecycle.viewModelScope import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.update +import mobile_wallet.feature.history.generated.resources.Res +import mobile_wallet.feature.history.generated.resources.feature_history_error_fallback +import org.jetbrains.compose.resources.StringResource import org.mifospay.core.common.DataState import org.mifospay.core.data.repository.AccountRepository import org.mifospay.core.model.savingsaccount.TransferDetail @@ -58,8 +61,13 @@ internal class TransactionDetailViewModel( private fun handleTransferDetailReceive(action: TransferDetailReceive) { when (action.result) { is DataState.Error -> { + val message = action.result.exception.message mutableStateFlow.update { - it.copy(viewState = Error(action.result.exception.message ?: "Error")) + if (message.isNullOrEmpty()) { + it.copy(viewState = Error.ResourceMessage(Res.string.feature_history_error_fallback)) + } else { + it.copy(Error.StringMessage(message)) + } } } @@ -83,7 +91,11 @@ internal data class TransactionDetailState( ) { internal sealed interface ViewState { data object Loading : ViewState - data class Error(val message: String) : ViewState + + sealed interface Error : ViewState { + data class StringMessage(val message: String) : Error + data class ResourceMessage(val message: StringResource) : Error + } data class Content(val transaction: TransferDetail) : ViewState } }