|
|
@@ -14,7 +14,8 @@ defmodule VaccinsWeb.LocationComponent do
|
|
|
last_refresh_date: nil,
|
|
|
last_early_slot_seen: nil,
|
|
|
render_as: :description_list,
|
|
|
- is_local?: false
|
|
|
+ is_local?: false,
|
|
|
+ error_on_last_query?: false
|
|
|
)}
|
|
|
|
|
|
@impl true
|
|
|
@@ -91,6 +92,7 @@ defmodule VaccinsWeb.LocationComponent do
|
|
|
do: ~L"""
|
|
|
<%= cond do %>
|
|
|
<%= @loading -> %>...
|
|
|
+ <% @error_on_last_query? -> %>>__<
|
|
|
<% 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_slots?(assigns) -> %>Des dispos dans plus de 24h
|
|
|
@@ -115,9 +117,10 @@ defmodule VaccinsWeb.LocationComponent do
|
|
|
</ul>
|
|
|
"""
|
|
|
|
|
|
- defp integrate_availabilities(assigns = %{availabilities: {:error, _reason}}),
|
|
|
+ defp integrate_availabilities(assigns = %{availabilities: {:error, reason}}),
|
|
|
do:
|
|
|
assigns
|
|
|
+ |> Map.put(:error_on_last_query?, reason != :no_availability)
|
|
|
|> Map.put(:slots_after, [])
|
|
|
|> Map.put(:slots_before, [])
|
|
|
|
|
|
@@ -125,6 +128,7 @@ defmodule VaccinsWeb.LocationComponent do
|
|
|
when is_list(after_slots),
|
|
|
do:
|
|
|
assigns
|
|
|
+ |> Map.put(:error_on_last_query?, false)
|
|
|
|> Map.put(:slots_after, after_slots |> Enum.take(2))
|
|
|
|> Map.put(:slots_before, [])
|
|
|
|
|
|
@@ -132,6 +136,7 @@ defmodule VaccinsWeb.LocationComponent do
|
|
|
when is_list(before_slots),
|
|
|
do:
|
|
|
assigns
|
|
|
+ |> Map.put(:error_on_last_query?, false)
|
|
|
|> Map.put(:slots_after, after_slots |> Enum.take(2))
|
|
|
|> Map.put(:slots_before, before_slots |> Enum.take(2))
|
|
|
|> Map.put(:last_early_slot_seen, DateTime.utc_now())
|