@@ -104,89 +104,94 @@ private fun ClientLoanAccountsScreen(
104104 ) {
105105 MifosBreadcrumbNavBar (navController)
106106
107- Column (
108- modifier = Modifier .fillMaxSize()
109- .padding(horizontal = DesignToken .padding.large),
110- ) {
111- ClientsAccountHeader (
112- totalItem = state.loanAccounts.size.toString(),
113- onAction = onAction,
114- )
107+ when (state.isLoading) {
108+ true -> MifosProgressIndicator ()
109+ false -> {
110+ Column (
111+ modifier = Modifier .fillMaxSize()
112+ .padding(horizontal = DesignToken .padding.large),
113+ ) {
114+ ClientsAccountHeader (
115+ totalItem = state.loanAccounts.size.toString(),
116+ onAction = onAction,
117+ )
115118
116- if (state.isSearchBarActive) {
117- MifosSearchBar (
118- query = state.searchText,
119- onQueryChange = {
120- onAction.invoke(
121- ClientLoanAccountsAction .UpdateSearchValue (
122- it,
123- ),
119+ if (state.isSearchBarActive) {
120+ MifosSearchBar (
121+ query = state.searchText,
122+ onQueryChange = {
123+ onAction.invoke(
124+ ClientLoanAccountsAction .UpdateSearchValue (
125+ it,
126+ ),
127+ )
128+ },
129+ onSearchClick = { onAction.invoke(ClientLoanAccountsAction .OnSearchClick ) },
130+ onBackClick = { onAction.invoke(ClientLoanAccountsAction .ToggleSearch ) },
124131 )
125- },
126- onSearchClick = { onAction.invoke(ClientLoanAccountsAction .OnSearchClick ) },
127- onBackClick = { onAction.invoke(ClientLoanAccountsAction .ToggleSearch ) },
128- )
129- }
132+ }
130133
131- Spacer (modifier = Modifier .height(DesignToken .padding.large))
134+ Spacer (modifier = Modifier .height(DesignToken .padding.large))
132135
133- if (state.loanAccounts.isEmpty()) {
134- MifosEmptyCard ()
135- } else {
136- LazyColumn {
137- items(state.loanAccounts) { loan ->
138- val symbol = loan.currency?.displaySymbol ? : " "
139- MifosActionsLoanListingComponent (
140- accountNo = (loan.accountNo ? : " Not Available" ),
141- loanProduct = loan.productName ? : " Not Available" ,
142- originalLoan = symbol + (
143- (loan.originalLoan ? : " Not Available" ).toString()
144- ),
145- amountPaid = symbol + (
146- (
147- loan.amountPaid
148- ? : " Not Available"
149- ).toString()
150- ),
151- loanBalance = symbol + (
152- (loan.amountPaid ? : " Not Available" ).toString()
153- ),
154- type = loan.loanType?.value ? : " Not Available" ,
155- // TODO check if we need to add other options as well, such as disburse and all
156- // currently didn't add it cuz its not in the UI design
157- menuList = when {
158- loan.status?.active == true -> {
159- listOf (
160- Actions .ViewAccount (
161- vectorResource(Res .drawable.wallet),
136+ if (state.loanAccounts.isEmpty()) {
137+ MifosEmptyCard ()
138+ } else {
139+ LazyColumn {
140+ items(state.loanAccounts) { loan ->
141+ val symbol = loan.currency?.displaySymbol ? : " "
142+ MifosActionsLoanListingComponent (
143+ accountNo = (loan.accountNo ? : " Not Available" ),
144+ loanProduct = loan.productName ? : " Not Available" ,
145+ originalLoan = symbol + (
146+ (loan.originalLoan ? : " Not Available" ).toString()
162147 ),
163- Actions .MakeRepayment (
164- vectorResource(Res .drawable.cash_bundel),
148+ amountPaid = symbol + (
149+ (
150+ loan.amountPaid
151+ ? : " Not Available"
152+ ).toString()
165153 ),
166- )
167- }
168-
169- else -> {
170- listOf (
171- Actions .ViewAccount (
172- vectorResource(Res .drawable.wallet),
154+ loanBalance = symbol + (
155+ (loan.amountPaid ? : " Not Available" ).toString()
173156 ),
174- )
175- }
176- },
177- onActionClicked = { actions ->
178- when (actions) {
179- is Actions .ViewAccount -> onAction(ClientLoanAccountsAction .ViewAccount )
180- is Actions .MakeRepayment -> onAction(
181- ClientLoanAccountsAction .MakeRepayment ,
182- )
157+ type = loan.loanType?.value ? : " Not Available" ,
158+ // TODO check if we need to add other options as well, such as disburse and all
159+ // currently didn't add it cuz its not in the UI design
160+ menuList = when {
161+ loan.status?.active == true -> {
162+ listOf (
163+ Actions .ViewAccount (
164+ vectorResource(Res .drawable.wallet),
165+ ),
166+ Actions .MakeRepayment (
167+ vectorResource(Res .drawable.cash_bundel),
168+ ),
169+ )
170+ }
183171
184- else -> null
185- }
186- },
187- )
172+ else -> {
173+ listOf (
174+ Actions .ViewAccount (
175+ vectorResource(Res .drawable.wallet),
176+ ),
177+ )
178+ }
179+ },
180+ onActionClicked = { actions ->
181+ when (actions) {
182+ is Actions .ViewAccount -> onAction(ClientLoanAccountsAction .ViewAccount )
183+ is Actions .MakeRepayment -> onAction(
184+ ClientLoanAccountsAction .MakeRepayment ,
185+ )
188186
189- Spacer (modifier = Modifier .height(8 .dp))
187+ else -> null
188+ }
189+ },
190+ )
191+
192+ Spacer (modifier = Modifier .height(8 .dp))
193+ }
194+ }
190195 }
191196 }
192197 }
@@ -260,8 +265,6 @@ private fun ClientLoanAccountsDialog(
260265 )
261266 }
262267
263- ClientLoanAccountsState .DialogState .Loading -> MifosProgressIndicator ()
264-
265268 else -> null
266269 }
267270}
0 commit comments