diff --git a/lib/algground_web/live/components/search_bar.ex b/lib/algground_web/live/components/search_bar.ex
new file mode 100644
index 0000000..30dc39e
--- /dev/null
+++ b/lib/algground_web/live/components/search_bar.ex
@@ -0,0 +1,46 @@
+defmodule AlggroundWeb.SearchBar do
+ use AlggroundWeb, :live_component
+
+ def update(%{regions: regions}, socket) do
+ {:ok,
+ socket
+ |> assign(:regions, regions)
+ |> assign(:found_regions, [])}
+ end
+
+ def handle_event("search_region", %{"region" => region}, socket) do
+ regions =
+ case Enum.filter(
+ socket.assigns.regions,
+ fn stored_region ->
+ String.contains?(stored_region.region, region)
+ end
+ ) do
+ [] -> socket.assigns.regions
+ filtered -> filtered
+ end
+
+ {:noreply,
+ socket
+ |> assign(:regions, regions)}
+ end
+
+ def render(assigns) do
+ ~H"""
+
+
+ <.simple_form for={%{}} phx-target={@myself} phx-change="search_region">
+ <.input type="text" name="region" value="" class="" placeholder="where are you going ?" />
+
+
+ <%= for region <- @regions do %>
+ <.live_component
+ module={AlggroundWeb.Components.Region}
+ region={region}
+ id={region.region <> "#{System.unique_integer()}"}
+ />
+ <% end %>
+
+ """
+ end
+end
diff --git a/lib/algground_web/live/pages/live_home_page.ex b/lib/algground_web/live/pages/live_home_page.ex
index ef999a9..3b69421 100644
--- a/lib/algground_web/live/pages/live_home_page.ex
+++ b/lib/algground_web/live/pages/live_home_page.ex
@@ -74,7 +74,7 @@ defmodule AlggroundWeb.LiveHomePage do
<%= Datex.Date.format_date(@date, "DD/MM/YYYY") %>
- Albufeira
+ <%= Enum.random(@regions).region %>
<%= display_groundwater(assigns) %>
@@ -84,7 +84,6 @@ defmodule AlggroundWeb.LiveHomePage do
-
@@ -109,6 +108,7 @@ defmodule AlggroundWeb.LiveHomePage do
+