Skip to content

Commit c6a11ea

Browse files
fix : changed apis to self (#2891)
1 parent c975afb commit c6a11ea

File tree

6 files changed

+64
-47
lines changed
  • core
    • model/src/commonMain/kotlin/org/mifos/mobile/core/model/entity
    • network/src/commonMain/kotlin/org/mifos/mobile/core/network/utils
  • feature

6 files changed

+64
-47
lines changed

core/model/src/commonMain/kotlin/org/mifos/mobile/core/model/entity/User.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ data class User(
2828
val permissions: ArrayList<String> = arrayListOf(),
2929
val shouldRenewPassword: Boolean = false,
3030
val isTwoFactorAuthenticationRequired: Boolean = false,
31+
val clients: ArrayList<Long> = arrayListOf(),
3132
) : Parcelable
3233

3334
@Serializable

core/network/src/commonMain/kotlin/org/mifos/mobile/core/network/utils/BaseURL.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class BaseURL {
2222

2323
companion object {
2424
const val API_ENDPOINT = "tt.mifos.community"
25-
const val API_PATH = "/fineract-provider/api/v1/"
25+
const val API_PATH = "/fineract-provider/api/v1/self/"
2626
const val PROTOCOL_HTTPS = "https://"
2727
}
2828
}

feature/auth/src/commonMain/kotlin/org/mifos/mobile/feature/auth/login/LoginViewModel.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,11 @@ class LoginViewModel(
114114
val userData = UserData(
115115
userId = user.userId,
116116
userName = user.username.orEmpty(),
117-
clientId = user.userId,
117+
clientId = if (user.clients.isNotEmpty()) {
118+
user.clients[0]
119+
} else {
120+
user.userId
121+
},
118122
isAuthenticated = user.isAuthenticated,
119123
base64EncodedAuthenticationKey = user.base64EncodedAuthenticationKey.orEmpty(),
120124
officeName = user.officeName.orEmpty(),

feature/home/src/commonMain/kotlin/org/mifos/mobile/feature/home/HomeScreen.kt

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -89,23 +89,22 @@ internal fun HomeScreen(
8989
event.route == Constants.TRANSACTIONS -> navigateToTransactionScreen.invoke()
9090
event.route == Constants.HELP -> navigateToFaqScreen.invoke()
9191
}
92-
// navigateToDestinationScreen(event.route)
9392
}
9493

9594
is HomeEvent.NavigateToNotification -> navigateToNotificationScreen.invoke()
9695
}
9796
}
9897

99-
HomeScreenDialog(
100-
dialogState = state.dialogState,
98+
HomeContent(
99+
state = state,
100+
modifier = modifier,
101101
onAction = remember(viewModel) {
102102
{ viewModel.trySendAction(it) }
103103
},
104104
)
105105

106-
HomeContent(
107-
state = state,
108-
modifier = modifier,
106+
HomeScreenDialog(
107+
dialogState = state.dialogState,
109108
onAction = remember(viewModel) {
110109
{ viewModel.trySendAction(it) }
111110
},
@@ -128,10 +127,11 @@ internal fun HomeContent(
128127
Row(
129128
horizontalArrangement = Arrangement.spacedBy(DesignToken.spacing.large),
130129
) {
131-
Image(
132-
imageVector = MifosIcons.SearchNew,
133-
contentDescription = null,
134-
)
130+
// TODO : once ui/ux team gives this flow uncomment and implement
131+
// Image(
132+
// imageVector = MifosIcons.SearchNew,
133+
// contentDescription = null,
134+
// )
135135
Image(
136136
imageVector = MifosIcons.Alert,
137137
contentDescription = null,
@@ -142,45 +142,47 @@ internal fun HomeContent(
142142
}
143143
},
144144
) {
145-
Column(
146-
modifier = Modifier
147-
.padding(DesignToken.padding.large),
148-
) {
149-
Spacer(modifier = Modifier.height(DesignToken.spacing.small))
145+
if (state.dialogState == null) {
146+
Column(
147+
modifier = Modifier
148+
.padding(DesignToken.padding.large),
149+
) {
150+
Spacer(modifier = Modifier.height(DesignToken.spacing.small))
150151

151-
Text(
152-
text = stringResource(Res.string.feature_home_greet, state.username),
153-
style = MifosTypography.titleLarge,
154-
color = AppColors.customBlack,
155-
)
152+
Text(
153+
text = stringResource(Res.string.feature_home_greet, state.username),
154+
style = MifosTypography.titleLarge,
155+
color = AppColors.customBlack,
156+
)
156157

157-
Spacer(modifier = Modifier.height(DesignToken.spacing.large))
158+
Spacer(modifier = Modifier.height(DesignToken.spacing.large))
158159

159-
MifosDashboardCard(
160-
isLoanApplied = state.isLoanApplied,
161-
savingsAccount = Res.string.feature_home_total_available_savings,
162-
loanAccount = Res.string.feature_home_total_available_loan,
163-
loanAmount = state.loanAmount,
164-
savingsAmount = state.savingsAmount,
165-
isVisible = state.isAmountVisible,
166-
onVisibilityToggle = { onAction(HomeAction.ToggleAmountVisible) },
167-
currency = state.currency,
168-
)
160+
MifosDashboardCard(
161+
isLoanApplied = state.isLoanApplied,
162+
savingsAccount = Res.string.feature_home_total_available_savings,
163+
loanAccount = Res.string.feature_home_total_available_loan,
164+
loanAmount = state.loanAmount,
165+
savingsAmount = state.savingsAmount,
166+
isVisible = state.isAmountVisible,
167+
onVisibilityToggle = { onAction(HomeAction.ToggleAmountVisible) },
168+
currency = state.currency,
169+
)
169170

170-
Spacer(modifier = Modifier.height(DesignToken.spacing.extraLarge))
171+
Spacer(modifier = Modifier.height(DesignToken.spacing.extraLarge))
171172

172-
Text(
173-
text = stringResource(Res.string.feature_home_services),
174-
style = MifosTypography.titleMediumEmphasized,
175-
color = AppColors.customBlack,
176-
)
173+
Text(
174+
text = stringResource(Res.string.feature_home_services),
175+
style = MifosTypography.titleMediumEmphasized,
176+
color = AppColors.customBlack,
177+
)
177178

178-
Spacer(modifier = Modifier.height(DesignToken.spacing.large))
179+
Spacer(modifier = Modifier.height(DesignToken.spacing.large))
179180

180-
ServiceBox(
181-
items = state.items,
182-
onAction = onAction,
183-
)
181+
ServiceBox(
182+
items = state.items,
183+
onAction = onAction,
184+
)
185+
}
184186
}
185187
}
186188
}

feature/home/src/commonMain/kotlin/org/mifos/mobile/feature/home/HomeViewModel.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,24 @@ internal class HomeViewModel(
9595
DataState.Loading -> updateState { it.copy(dialogState = HomeState.DialogState.Loading) }
9696

9797
is DataState.Success -> {
98-
if (dataState.data.loanAccounts.isNotEmpty()) {
98+
val hasLoans = dataState.data.loanAccounts.isNotEmpty()
99+
val hasSavings = dataState.data.savingsAccounts?.isNotEmpty() ?: false
100+
101+
if (hasLoans) {
99102
getLoanAccountDetails(dataState.data.loanAccounts)
103+
}
104+
105+
if (hasSavings) {
100106
getSavingAccountDetails(dataState.data.savingsAccounts)
107+
}
108+
109+
if (hasLoans || hasSavings) {
101110
updateState {
102111
it.copy(
103112
clientAccounts = dataState.data,
104113
dialogState = null,
105-
currency = dataState.data.loanAccounts.firstOrNull()?.currency?.displaySymbol,
114+
currency = dataState.data.loanAccounts.firstOrNull()?.currency?.displaySymbol
115+
?: dataState.data.savingsAccounts?.firstOrNull()?.currency?.displaySymbol,
106116
)
107117
}
108118
} else {

feature/loan-account/src/commonMain/kotlin/org/mifos/mobile/feature/loanaccount/loanAccount/LoanAccountScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ internal fun LoanAccountContent(
139139
.fillMaxSize()
140140
.padding(DesignToken.padding.large),
141141
) {
142-
if (state.dialogState == null) {
142+
if (!state.isEmpty && state.dialogState == null) {
143143
Spacer(modifier = Modifier.height(DesignToken.spacing.large))
144144

145145
MifosDashboardCard(

0 commit comments

Comments
 (0)