% content_for :title, "Resolve squawk" %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= form_with url: resolve_aircraft_squawk_path(@aircraft, @squawk), method: :patch, class: "card card-body max-w-3xl space-y-4" do %>
Resolve squawk
<%= @squawk.issue_reported %><%= " · #{@squawk.component}" if @squawk.component %>
<% if @entry.errors.any? %>
<% @entry.errors.full_messages.each do |m| %><%= m %> <% end %>
<% end %>
<% choice = params[:logbook].presence || "new" %>
Logbook
<%= radio_button_tag :logbook, "new", choice == "new" %> Record the fix as a new logbook entry
<%= radio_button_tag :logbook, "existing", choice == "existing" %> Link an existing entry:
<%= select_tag :logbook_entry_id, options_for_select(logbook_options(@aircraft).reject { _2.nil? }, params[:logbook_entry_id]), class: "input w-auto" %>
<%= radio_button_tag :logbook, "none", choice == "none" %> No logbook entry (e.g. it wasn't a defect)
For a new entry. 14 CFR 43.9: what was done, the date, and the name, certificate number and kind of certificate of whoever approved the return to service.
<%= render "shared/sign_as" %>
<%= fields_for :logbook_entry, @entry do |f| %>
<%= f.field :date, as: :date %>
<%= f.field :log_type, as: :select, label: "Logbook", collection: LogbookEntry::LOG_TYPES.invert,
data: { component_times_target: "logType", action: "component-times#logTypeChanged" } %>
<%= f.field :aircraft_hours_at_entry, as: :number, step: 0.1, label: "Airframe total time" %>
<%= render "logbook_entries/component_fields", f: f, aircraft: @aircraft %>
<%= f.field :text, as: :textarea, label: "Work performed", rows: 3 %>
<%= f.field :signoff_person, label: "Signed off by", data: { signer_target: "name" } %>
<%= f.field :signoff_certificate_type, as: :select, label: "Kind of certificate", include_blank: "—", collection: LogbookEntry::CERTIFICATE_TYPES.invert,
data: { signer_target: "kind" } %>
<%= f.field :signoff_certificate_number, label: "Certificate number", data: { signer_target: "number" } %>
<% end %>
<%= label_tag :resolution_notes, "Resolution notes (optional)", class: "label" %>
<%= text_area_tag :resolution_notes, params[:resolution_notes], rows: 2, class: "input" %>
<%= submit_tag "Resolve", class: "btn-primary" %><%= link_to "Cancel", aircraft_squawks_path(@aircraft), class: "btn-secondary" %>
<% end %>