<div class="card shadow-sm">
  <div class="card-body">
    <%= errors_summary_for @medical_release %>
    <%= bootstrap_form_with model: [@account, @project, @contract_template, @medical_release], local: true, validation_context: :native do |form| %>
      <div class="alert alert-warning font-weight-bold"><%= t ".instructions_html", name: @project.name %></div>
      <%= card_field_set_tag t(".legal.heading") do %>
        <p><%= @contract_template.body %></p>
        <% if @contract_template.fee? %>
          <p>
            Fee <span class="font-weight-bold text-success"><%= number_to_currency @contract_template.fee %></span>
          </p>
        <% end %>
      <% end %>

      <hr>
      
      <% if (1..10).map {|n| @contract_template.public_send("question_#{n}_text").presence }.compact.any? %>
        <%= card_field_set_tag t(".questionnaire.heading") do %>
          <% (1..10).each do |n| %>
            <% if @contract_template.public_send("question_#{n}_text").present? %>
              <div class="form-row">
                <%= form.text_area "question_#{n}_answer", wrapper_class: "col-sm-12", label: @contract_template.public_send("question_#{n}_text") %>
              </div>
            <% end %>
          <% end %>
        <% end %>
        <hr>
      <% end %>

      <%= card_field_set_tag t(".personal_info.heading") do %>
        <div class="alert alert-warning font-weight-bold"><%= t ".personal_info.instructions" %></div>
        <div class="form-row">
          <%= form.text_field :person_first_name, required: true, wrapper_class: "col-sm-6" %>
          <%= form.text_field :person_last_name, required: true, wrapper_class: "col-sm-6" %>
          <%= form.phone_field :person_phone, wrapper_class: "col-sm-6" %>
          <%= form.email_field :person_email, wrapper_class: "col-sm-6" %>
        </div>
        <%= render "shared/address_fields", form: form, subject: "person" %>
      <% end %>

      <hr>

      <%= card_field_set_tag t(".photo.heading") do %>
        <%= render "shared/photos_dropzone_fields", form: form, release: @medical_release %>
      <% end %>

      <%= card_field_set_tag t(".signature.heading") do %>
        <%= render "shared/signature_fields", form: form %>
      <% end %>

      <div class="mt-5">
        <%= form.button t("shared.submit_release_short"), class: "btn btn-block btn-lg btn-success", data: { disable_with: t("shared.disable_with") } %>
      </div>
    <% end %>
  </div>
</div>