<% content_for :title, t(".inspections", tail_number: @aircraft.tail_number) %> <%= render "shared/aircraft_header", aircraft: @aircraft %>

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

<% if can?(:manage_inspections) %>
<%= more_menu do %><%= link_to t(".add_standard_inspections"), new_aircraft_standard_inspections_path(@aircraft), class: "menu-item" %><% end %><%= link_to t(".inspection_type"), new_aircraft_inspection_type_path(@aircraft), class: "btn-primary" %>
<% end %>
<% if @rows.any? %>
<% @rows.each do |row| %> <% end %>
<%= t(".inspection") %><%= t(".interval") %><%= t(".last_done") %><%= t(".next_due") %><%= t(".status") %>
<%= row.type.name %><%= tag.span(" #{row.type.advisory? ? 'advisory' : row.type.limitation.to_s.downcase + ' if overdue'}", class: "text-xs text-slate-500") if row.type.advisory? || row.type.limitation %> <% if row.type.satisfies %>
<%= t(".also_counts_as_html", satisfies: row.type.satisfies.name) %>
<% end %>
<%= row.type.interval_description %> <%= row.latest ? "#{fmt_date(row.latest.date)} @ #{hours(row.latest.hours_at_inspection)} h" : "—" %> <%= [row.next_due_date&.to_s, row.next_due_hours && "#{hours(row.next_due_hours)} h"].compact.join(" / ").presence || "—" %> <%= compliance_badge(row.status) %> <% if can?(:manage_inspections) %> <%= link_to t(".record"), new_aircraft_inspection_record_path(@aircraft, inspection_type_id: row.type.id), class: "btn-secondary btn-sm" %> <%= link_to t(".edit"), edit_aircraft_inspection_type_path(@aircraft, row.type), class: "btn-secondary btn-sm" %> <% end %>
<% else %> <%= empty_state t(".no_inspections_tracked_add_annual") %> <% end %>

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

<% if @history.any? %> <% @history.each do |r| %> <% end %>
<%= t(".date") %><%= t(".inspection") %><%= t(".hours") %><%= t(".notes") %>
<%= fmt_date(r.date) %> <%= r.inspection_type.name %><%= " (#{r.component})" if r.component %> <%= hours(r.hours_at_inspection) %> <%= r.notes %><% if r.logbook_entry %> <%= link_to "logbook", aircraft_logbook_entry_path(@aircraft, r.logbook_entry), class: "link" %><% end %> <% if can?(:manage_inspections) %><%= link_to t(".edit"), edit_aircraft_inspection_record_path(@aircraft, r), class: "btn-secondary btn-sm" %><% end %>
<% else %> <%= empty_state t(".no_inspections_recorded") %> <% end %>