|
@@ -11,7 +11,8 @@ defmodule VaccinsWeb.LocationComponent do
|
|
|
slots_after: [],
|
|
slots_after: [],
|
|
|
slots_before: [],
|
|
slots_before: [],
|
|
|
loading: false,
|
|
loading: false,
|
|
|
- last_refresh_date: nil
|
|
|
|
|
|
|
+ last_refresh_date: nil,
|
|
|
|
|
+ last_early_slot_seen: nil
|
|
|
)}
|
|
)}
|
|
|
|
|
|
|
|
@impl true
|
|
@impl true
|
|
@@ -53,7 +54,7 @@ defmodule VaccinsWeb.LocationComponent do
|
|
|
<dd>
|
|
<dd>
|
|
|
<%= cond do %>
|
|
<%= cond do %>
|
|
|
<%= @loading -> %>...
|
|
<%= @loading -> %>...
|
|
|
- <%= not has_slots?(assigns) -> %>Pas de créneau
|
|
|
|
|
|
|
+ <%= not has_slots?(assigns) -> %>Pas de créneau <%= if @last_early_slot_seen do %>(<%= @last_early_slot_seen |> DateTime.to_time() |> Time.truncate(:second) |> Time.to_string %>)<% end %>
|
|
|
<%= has_early_slots?(assigns) -> %><span class="alert-danger">Des dispos sous 24h !</span>
|
|
<%= has_early_slots?(assigns) -> %><span class="alert-danger">Des dispos sous 24h !</span>
|
|
|
<%= has_slots?(assigns) -> %>Des dispos !
|
|
<%= has_slots?(assigns) -> %>Des dispos !
|
|
|
<% end %>
|
|
<% end %>
|
|
@@ -101,6 +102,7 @@ defmodule VaccinsWeb.LocationComponent do
|
|
|
assigns
|
|
assigns
|
|
|
|> Map.put(:slots_after, after_slots |> Enum.take(5))
|
|
|> Map.put(:slots_after, after_slots |> Enum.take(5))
|
|
|
|> Map.put(:slots_before, before_slots)
|
|
|> Map.put(:slots_before, before_slots)
|
|
|
|
|
+ |> Map.put(:last_early_slot_seen, DateTime.utc_now)
|
|
|
|
|
|
|
|
defp integrate_availabilities(assigns), do: assigns
|
|
defp integrate_availabilities(assigns), do: assigns
|
|
|
|
|
|
|
@@ -121,7 +123,7 @@ defmodule VaccinsWeb.LocationComponent do
|
|
|
do: now |> DateTime.to_time() |> Time.truncate(:second)
|
|
do: now |> DateTime.to_time() |> Time.truncate(:second)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
- defp signal_availabilities(socket = %{assigns: %{loading: false, slots_after: slots_after}}) do
|
|
|
|
|
|
|
+ defp signal_availabilities(socket = %{assigns: %{loading: false}}) do
|
|
|
cond do
|
|
cond do
|
|
|
socket.assigns |> has_slots? ->
|
|
socket.assigns |> has_slots? ->
|
|
|
send(self(), {:location_has_slots, socket.assigns.id, socket.assigns |> has_early_slots?})
|
|
send(self(), {:location_has_slots, socket.assigns.id, socket.assigns |> has_early_slots?})
|