|
|
@@ -54,34 +54,17 @@ defmodule VaccinsWeb.LocationComponent do
|
|
|
<dt>location</dt>
|
|
|
<dd><%= @location.location %></dd>
|
|
|
<dt>Status (<%= if @last_refresh_date, do: @last_refresh_date |> Time.to_string() %>) </dt>
|
|
|
- <dd>
|
|
|
- <%= cond do %>
|
|
|
- <%= @loading -> %>...
|
|
|
- <%= 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 !
|
|
|
- <% end %>
|
|
|
- </dd>
|
|
|
+ <dd><%= render_status(assigns) %></dd>
|
|
|
<dt>booking page</dt>
|
|
|
<dd><%= link @location.booking_page, to: @location.booking_page %></dd>
|
|
|
<%= if has_slots?(assigns) do %>
|
|
|
<dt>Avant 24h</dt>
|
|
|
- <dd>
|
|
|
- <ul class="slots-list"><%= for d <- @slots_before do %><li><%= d |> Calendar.strftime("%d/%m/%Y %H:%M:%S") %></li><% end %></ul>
|
|
|
- </dd>
|
|
|
+ <dd><%= render_slots_before(assigns) %></dd>
|
|
|
<dt>Après 24h</dt>
|
|
|
- <dd>
|
|
|
- <ul class="slots-list"><%= for d <- @slots_after do %><li><%= d |> Calendar.strftime("%d/%m/%Y %H:%M:%S") %></li><% end %></ul>
|
|
|
- </dd>
|
|
|
+ <dd><%= render_slots_after(assigns) %></dd>
|
|
|
<% end %>
|
|
|
<dt>actions</dt>
|
|
|
- <dd>
|
|
|
- <ul class="actions-list">
|
|
|
- <li><button phx-click="trigger_query" phx-target="<%= @myself %>">Trigger</button></li>
|
|
|
- <li><a href="<%= @location |> to_json_query %>"><button>Debug</button></a></li>
|
|
|
- <li><button class="alert-danger" phx-click="delete" phx-target="<%= @myself %>" data-confirm="Etes-vous sur?">Delete</button></li>
|
|
|
- </ul>
|
|
|
- </dd>
|
|
|
+ <dd><%= render_action_list(assigns) %></dd>
|
|
|
</dl>
|
|
|
"""
|
|
|
end
|
|
|
@@ -92,24 +75,11 @@ defmodule VaccinsWeb.LocationComponent do
|
|
|
<td><%= @location.name %></td>
|
|
|
<td><%= @location.location %></td>
|
|
|
<td><%= if @last_refresh_date, do: @last_refresh_date |> Time.to_string() %></td>
|
|
|
- <td><%= cond do %>
|
|
|
- <%= @loading -> %>...
|
|
|
- <%= 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 !
|
|
|
- <% end %></td>
|
|
|
+ <td><%= render_status(assigns) %></td>
|
|
|
<td><%= link "Résa.", to: @location.booking_page %></td>
|
|
|
- <td>
|
|
|
- <ul class="slots-list"><%= for d <- @slots_before do %><li><%= d |> Calendar.strftime("%d/%m/%Y %H:%M") %></li><% end %></ul>
|
|
|
- </td>
|
|
|
- <td>
|
|
|
- <ul class="slots-list"><%= for d <- @slots_after do %><li><%= d |> Calendar.strftime("%d/%m/%Y %H:%M") %></li><% end %></ul>
|
|
|
- </td>
|
|
|
- <td><ul class="actions-list">
|
|
|
- <li><button phx-click="trigger_query" phx-target="<%= @myself %>">Trigger</button></li>
|
|
|
- <li><a href="<%= @location |> to_json_query %>"><button>Debug</button></a></li>
|
|
|
- <li><button class="alert-danger" phx-click="delete" phx-target="<%= @myself %>" data-confirm="Etes-vous sur?">Delete</button></li>
|
|
|
- </ul></td>
|
|
|
+ <td><%= render_slots_before(assigns) %></td>
|
|
|
+ <td><%= render_slots_after(assigns) %></td>
|
|
|
+ <td><%= render_action_list(assigns) %></td>
|
|
|
"""
|
|
|
end
|
|
|
|
|
|
@@ -125,6 +95,35 @@ defmodule VaccinsWeb.LocationComponent do
|
|
|
<th>Actions</th>
|
|
|
"""
|
|
|
|
|
|
+ defp render_status(assigns),
|
|
|
+ do: ~L"""
|
|
|
+ <%= cond do %>
|
|
|
+ <%= @loading -> %>...
|
|
|
+ <%= 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 !
|
|
|
+ <% end %>
|
|
|
+ """
|
|
|
+
|
|
|
+ defp render_slots_before(assigns),
|
|
|
+ do: ~L"""
|
|
|
+ <ul class="slots-list"><%= for d <- @slots_before do %><li><%= d |> Calendar.strftime("%d/%m/%Y %H:%M") %></li><% end %></ul>
|
|
|
+ """
|
|
|
+
|
|
|
+ defp render_slots_after(assigns),
|
|
|
+ do: ~L"""
|
|
|
+ <ul class="slots-list"><%= for d <- @slots_after do %><li><%= d |> Calendar.strftime("%d/%m/%Y %H:%M") %></li><% end %></ul>
|
|
|
+ """
|
|
|
+
|
|
|
+ defp render_action_list(assigns),
|
|
|
+ do: ~L"""
|
|
|
+ <ul class="actions-list">
|
|
|
+ <li><button phx-click="trigger_query" phx-target="<%= @myself %>">Trigger</button></li>
|
|
|
+ <li><a href="<%= @location |> to_json_query %>"><button>Debug</button></a></li>
|
|
|
+ <li><button class="alert-danger" phx-click="delete" phx-target="<%= @myself %>" data-confirm="Etes-vous sur?">Delete</button></li>
|
|
|
+ </ul>
|
|
|
+ """
|
|
|
+
|
|
|
defp integrate_availabilities(assigns = %{availabilities: {:error, reason}}),
|
|
|
do:
|
|
|
assigns
|