99 */
1010package com.mifos.feature.search
1111
12+ import androidclient.feature.search.generated.resources.Res
13+ import androidclient.feature.search.generated.resources.feature_search_filter_options_clients_label
14+ import androidclient.feature.search.generated.resources.feature_search_filter_options_clients_value
15+ import androidclient.feature.search.generated.resources.feature_search_filter_options_groups_label
16+ import androidclient.feature.search.generated.resources.feature_search_filter_options_groups_value
17+ import androidclient.feature.search.generated.resources.feature_search_filter_options_loans_label
18+ import androidclient.feature.search.generated.resources.feature_search_filter_options_loans_value
19+ import androidclient.feature.search.generated.resources.feature_search_filter_options_savings_label
20+ import androidclient.feature.search.generated.resources.feature_search_filter_options_savings_value
1221import androidx.compose.runtime.mutableStateOf
1322import androidx.lifecycle.ViewModel
1423import androidx.lifecycle.viewModelScope
@@ -24,6 +33,8 @@ import kotlinx.coroutines.flow.onEach
2433import kotlinx.coroutines.flow.onStart
2534import kotlinx.coroutines.flow.update
2635import kotlinx.coroutines.launch
36+ import org.jetbrains.compose.resources.StringResource
37+ import org.jetbrains.compose.resources.getString
2738
2839class SearchViewModel (
2940 private val searchRepository : SearchRepository ,
@@ -96,7 +107,7 @@ class SearchViewModel(
96107 state.value = state.value.copy(showEmptyError = false )
97108 searchJob = searchRepository.searchResources(
98109 query = state.value.searchText,
99- resources = state.value.selectedFilter?.value ,
110+ resources = state.value.selectedFilter?.let { getString(it.valueRes) } ,
100111 exactMatch = state.value.exactMatch,
101112 ).onStart {
102113 searchResultState.update { SearchResultState .Loading }
@@ -157,16 +168,27 @@ sealed interface SearchScreenEvent {
157168 data object PerformSearch : SearchScreenEvent
158169}
159170
160- sealed class FilterOption (val label : String , val value : String ) {
171+ sealed class FilterOption (val labelRes : StringResource , val valueRes : StringResource ) {
161172
162- data object Clients : FilterOption (label = " Clients" , value = " clients" )
173+ data object Clients : FilterOption (
174+ labelRes = Res .string.feature_search_filter_options_clients_label,
175+ valueRes = Res .string.feature_search_filter_options_clients_value,
176+ )
163177
164- data object Groups : FilterOption (label = " Groups" , value = " groups" )
178+ data object Groups : FilterOption (
179+ labelRes = Res .string.feature_search_filter_options_groups_label,
180+ valueRes = Res .string.feature_search_filter_options_groups_value,
181+ )
165182
166- data object LoanAccounts : FilterOption (label = " Loan Accounts" , value = " loans" )
183+ data object LoanAccounts : FilterOption (
184+ labelRes = Res .string.feature_search_filter_options_loans_label,
185+ valueRes = Res .string.feature_search_filter_options_loans_value,
186+ )
167187
168- data object SavingsAccounts :
169- FilterOption (label = " Savings Accounts" , value = " savingsaccounts" )
188+ data object SavingsAccounts : FilterOption (
189+ labelRes = Res .string.feature_search_filter_options_savings_label,
190+ valueRes = Res .string.feature_search_filter_options_savings_value,
191+ )
170192
171193 companion object {
172194 val values = listOf (Clients , Groups , LoanAccounts , SavingsAccounts )
0 commit comments