<%# The most recent day's flying (Overview). %>

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

<%= link_to t(".flights"), aircraft_flight_logs_path(aircraft), class: "link text-sm" %>
<% if last_day %> <% route = last_day.flat_map { [ _1.departure_location, _1.destination_location ] }.compact_blank.chunk_while { _1 == _2 }.map(&:first) %> <% last_leg = last_day.last %> <% fuel_after = last_day.reverse.find(&:fuel_level_after)&.fuel_level_after %> <% oil_after = last_day.reverse.find(&:oil_level_after)&.oil_level_after %>
<%= t(".date") %>
<%= fmt_date(last_leg.date) %><%= " · #{t("counts.leg", count: last_day.size)}" if last_day.size > 1 %>
<% if route.any? %>
<%= t(".route") %>
<%= route.join(" → ") %>
<% end %>
<%= t(".flown") %>
<%= t(".hrs_tach_html", hours: (hours(last_day.sum { _1.tach_time.to_d }))) %>
<% if last_leg.tach_in %>
<%= t(".ended_at") %>
<%= t(".tach_html", tach_in: (hours(last_leg.tach_in)), hobbs_in: (t(".hobbs", hobbs_in: (hours(last_leg.hobbs_in))) if last_leg.hobbs_in)) %>
<% end %> <% if fuel_after %>
<%= t(".fuel_after") %>
<%= t(".gal_html", fuel: (number_with_precision(fuel_after, precision: 1, strip_insignificant_zeros: true))) %>
<% end %> <% if oil_after %>
<%= t(".oil_after") %>
<%= t(".qt_html", oil: (number_with_precision(oil_after, precision: 1, strip_insignificant_zeros: true))) %>
<% end %> <% if (notes = last_day.filter_map { _1.notes.presence }).any? %>
<%= t(".notes") %>
<%= notes.join("\n") %>
<% end %>
<% else %> <%= empty_state t(".no_flights_logged_yet") %> <% end %>