Просмотр исходного кода

Highlight locations with early slots

theenglishway (time) 4 лет назад
Родитель
Сommit
6f2ddaa69b
1 измененных файлов с 5 добавлено и 1 удалено
  1. 5 1
      lib/vaccins_web/live/location_component.ex

+ 5 - 1
lib/vaccins_web/live/location_component.ex

@@ -54,6 +54,7 @@ defmodule VaccinsWeb.LocationComponent do
           <%= cond do %>
             <%= @loading -> %>...
             <%= not has_slots?(assigns) -> %>Pas de créneau
+            <%= has_early_slots?(assigns) -> %><span class="alert-danger">Des dispos sous 24h !</span>
             <%= has_slots?(assigns) -> %>Des dispos !
           <% end %>
         </dd>
@@ -101,6 +102,9 @@ defmodule VaccinsWeb.LocationComponent do
   defp has_slots?(assigns = %{slots_before: before, slots_after: after_}),
     do: not (before |> Enum.empty?() and after_ |> Enum.empty?())
 
+  defp has_early_slots?(assigns = %{slots_before: before}),
+    do: not (before |> Enum.empty?())
+
   defp trigger_and_signal_query(location, id) do
     ref = Search.async_trigger_query(location)
     send(self(), {:query_sent, id, ref})
@@ -115,7 +119,7 @@ defmodule VaccinsWeb.LocationComponent do
   defp signal_availabilities(socket = %{assigns: %{loading: false, slots_after: slots_after}}) do
     cond do
       socket.assigns |> has_slots? ->
-        send(self(), {:location_has_slots, socket.assigns.id, not (slots_after |> Enum.empty?())})
+        send(self(), {:location_has_slots, socket.assigns.id, socket.assigns |> has_early_slots?})
 
       true ->
         send(self(), {:location_no_more_slots, socket.assigns.id})