<fieldset data-hook="admin_customer_detail_form_fields" class="no-border-top">

  <fieldset class="index no-border-bottom" data-hook="customer_guest">
    <legend align="center"><%= t('spree.account') %></legend>

    <div data-hook="customer_fields" class="row">
      <div class="col-9">
        <div class="field">
          <%= f.label :email %>
          <%= f.email_field :email, required: true, class: 'fullwidth' %>
        </div>
      </div>
      <div class="col-3">
        <div class="field">
          <%= label_tag nil, t('spree.guest_checkout') %>
          <ul>
            <% if @order.completed? %>
              <li>
                <%= @order.user.nil? ? t('spree.say_yes') : t('spree.say_no') %>
              </li>
            <% else %>
              <% guest = @order.user.nil? %>
              <li>
                <label>
                  <%= radio_button_tag :guest_checkout, true, guest %>
                  <%= t('spree.say_yes') %>
                </label>
              </li>
              <li>
                <label>
                  <%= radio_button_tag :guest_checkout, false, !guest, disabled: @order.cart? %>
                  <%= t('spree.say_no') %>
                </label>
              </li>
              <%= hidden_field_tag :user_id, @order.user_id %>
            <% end %>
          </ul>
        </div>
      </div>
    </div>
  </fieldset>

  <div class="row">
    <% if Spree::Config[:order_bill_address_used] %>
      <div class="col-6" data-hook="bill_address_wrapper">
        <fieldset class="no-border-bottom">
          <legend align="center"><%= t('spree.billing_address') %></legend>
          <div class="js-billing-address">
            <%= f.fields_for :bill_address do |ba_form| %>
              <%= render partial: 'spree/admin/shared/address_form', locals: { f: ba_form, type: "billing" } %>
            <% end %>
          </div>
        </fieldset>
      </div>
    <% end %>

    <div class="col-6" data-hook="ship_address_wrapper">
      <fieldset class="no-border-bottom">
        <legend align="center"><%= t('spree.shipping_address') %></legend>
        <% if Spree::Config[:order_bill_address_used] %>
          <div class="field">
            <span data-hook="use_billing">
              <label>
                <%= check_box_tag 'order[use_billing]', '1', (@order.ship_address.new_record? && @order.bill_address == @order.ship_address) %>
                <%= t('spree.use_billing_address') %>
              </label>
            </span>
          </div>
        <% end %>

        <div class="js-shipping-address">
          <%= f.fields_for :ship_address do |ba_form| %>
            <%= render partial: 'spree/admin/shared/address_form', locals: { f: ba_form, type: "shipping" } %>
          <% end %>
        </div>
      </fieldset>
    </div>
  </div>

  <div class="clear"></div>

  <div class="form-buttons filter-actions actions" data-hook="buttons">
    <%= button_tag t('spree.actions.update'), class: 'btn btn-primary' %>
  </div>
</fieldset>
