Files
nairobi/app/components/shared/search_results_summary_component.rb
Javi Martín 5c0aa42351 Remove duplication in search results summary
We were using very similar code for proposals, debates and investments,
so we might as well share the code between them.

Note we're using the `proposals.index.search_results` key even for
debates and investments. This will still work because the translations
shared the same text, but IMHO we should rename the key to something
like `shared.search_results_summary`. We aren't doing so because we'd
lose all the existing translations.
2022-04-12 14:23:14 +02:00

16 lines
449 B
Ruby

class Shared::SearchResultsSummaryComponent < ApplicationComponent
attr_reader :results, :search_terms, :advanced_search_terms
def initialize(results:, search_terms:, advanced_search_terms:)
@results = results
@search_terms = search_terms
@advanced_search_terms = advanced_search_terms
end
private
def summary
sanitize(t("proposals.index.search_results", count: results.size, search_term: search_terms))
end
end