diff --git a/lib/companies/helper.ex b/lib/companies/helper.ex index b7bbbaf4..1e53d235 100644 --- a/lib/companies/helper.ex +++ b/lib/companies/helper.ex @@ -5,8 +5,17 @@ defmodule Companies.Helpers do @default_page_size "16" - def searched_list(list, _params) do - list + def searched_list(list, params) do + search_param = params["search"]["text"] + + if search_param do + Enum.filter(list, fn %{name: name, industry: industry} -> + String.contains?(String.downcase(name), String.downcase(search_param)) or + String.contains?(String.downcase(industry), String.downcase(search_param)) + end) + else + list + end end def sorted_list(list, params) do