<% content_for :title, t(".airports") %>

<%= t(".airports") %>

<%= link_to t(".custom_airport"), new_admin_airport_path, class: "btn-primary" %>

<%= t(".airport_database") %>

<% if @running %> <%= t(".updating") %> <% else %> <%= button_to t(".update_from_ourairports"), refresh_admin_airports_path, class: "btn-secondary", form: { data: { turbo_confirm: t(".download_the_latest_airport_data") } } %> <% end %>
<%= number_with_delimiter(@total) %>
<%= t(".airports_2") %>
<%= @custom.size %>
<%= t(".custom") %>
<%= @last_success ? "#{time_ago_in_words(@last_success.finished_at)} ago" : "never" %>
<%= t(".last_updated") %>
<% if @total.zero? %>

<%= t(".no_airport_data_yet_it") %>

<% end %>

<%= t(".airport_data_comes_from_ourairports_html") %>

<% if @updates.any? %> <% @updates.each do |u| %> <% end %>
<%= t(".started") %><%= t(".by") %><%= t(".status") %><%= t(".result") %>
<%= fmt_time(u.created_at) %> <%= u.requested_by&.display_name || t(".startup") %> <%= tag.span u.status.capitalize, class: { "done" => "badge-green", "failed" => "badge-red" }.fetch(u.status, "badge-blue") %> <%= u.done? ? u.summary : u.error %>
<% end %>

<%= t(".look_up") %>

<%= form_with url: admin_airports_path, method: :get, class: "flex gap-2" do |f| %> <%= f.search_field :q, value: @query, class: "input", placeholder: t(".code_or_name") %> <%= f.submit t(".search"), class: "btn-secondary" %> <% end %> <% if @query.present? %> <% if @results.any? %>
    <% @results.each do |a| %>
  • <%= a.code %> <%= a.name %>
    <%= [a.place, t(".airtrail", airtrail_code: a.airtrail_code), (a.custom? ? "custom" : nil), Airport::KIND_LABELS[a.kind]].compact_blank.join(" ยท ") %>
  • <% end %>
<% else %>

<%= t(".no_match_for_html", query: @query, link: (link_to t(".add_it_as_a_custom"), new_admin_airport_path(ident: @query.upcase), class: "link")) %>

<% end %> <% end %>

<%= t(".custom_airports") %>

<% if @custom.any? %> <% @custom.each do |a| %> <% end %>
<%= t(".code") %><%= t(".name") %><%= t(".location") %><%= t(".type") %>
<%= a.ident %><%= a.name %><%= a.place %> <%= a.kind.to_s.humanize %> <%= link_to t(".edit"), edit_admin_airport_path(a), class: "btn-secondary btn-sm" %>
<% else %> <%= empty_state t(".none_add_private_strips_or") %> <% end %>