<commit_before><div class="container account">
  <h1 class="page-title">Account Details</h1>

  <h2 class="order-search">Search Orders</h2>
    <%= form_tag(account_orders_path(@user_account), method: "get", id: "search-form") do %>
      <%= text_field_tag :search, nil, placeholder: "Enter order number" %>
      <%= submit_tag "Find Order#", :name => nil %>
    <% end %>

  <div class="js-searchResults"></div>

  <h2>Profile</h2>
  <ul>
    <li><b>Account Type:</b> <%= @user_account.account_type %></li>
    <li><b>First Name:</b> <%= @user_account.first_name %></li>
    <li><b>Last Name:</b> <%= @user_account.last_name %></li>
    <li><b>Company:</b> <%= @user_account.company %></li>
  </ul>

  <h2>Address</h2>
  <% if @user_account.addresses.present? %>
    <ul>
      <% @user_account.addresses.each do |address| %>
        <li><b>Type of Address:</b> <%= address.address_type %></li>
        <li><b>Street:</b> <%= address.street_address %></li>
        <li><b>Apt/Unit/Floor:</b> <%= address.secondary_address %></li>
        <li><b>City:</b> <%= address.city %></li>
        <li><b>State:</b> <%= address.state %></li>
        <li><b>Zip:</b> <%= address.zip %></li>
        <li><b>Country:</b> <%= address.country %></li>
      <% end %>
    </ul>
  <% else %>
    <p>Your account doesn't have an address at this time.</p>
  <% end %>

  <h2>Phone Number</h2>
  <% if @user_account.phones.present? %>
    <ul>
      <% @user_account.phones.each do |phone| %>
      <li><b>Phone Type:</b> <%= phone.phone_type %></li>
      <li><b>Phone Number:</b> <%= phone.phone_number %></li>
      <li><b>Ext:</b> <%= phone.ext %></li>
      <% end %>
    </ul>
  <% else %>
    <p>Your account doesn't have phone number at this time.</p>
  <% end %>

  <%= link_to "Edit Account", edit_account_path(@user_account), class: "btn btn-primary"%>

  <h2>Log in</h2>
  <ul>
    <li><b>Email:</b> <%= @user_account.user.email %></li>
    <li><b>Password:</b> *********</li>
  </ul>

  <%= link_to "Edit Log in", edit_user_registration_path, class: "btn btn-primary" %>

</div><!-- /.container -->

<script type="text/javascript">
  $( document ).on('turbolinks:load', function() {

    $("#search-form").submit(function(event){

      let searchInput = $('#search').val();
      let orderHistoryPath = "<%= account_orders_path(@user_account) %>";
      let output = ['<div class="panel panel-default">'];
      event.preventDefault();

      $.ajax({
        url: this.action,
        data: $(this).serialize(),
        dataType: "json",
        type: this.method,

        success: function(response){
          let urlPath = `/account/${response.account.slug}/orders/${response.id}`;

          output.push(
                      `<h1>Order #${response.id}</h1>`,
                      '<ul>',
                      `<li>Number of items: ${response.number_of_items}</li>`,
                      `<li>Shipping Reference: ${response.shipping_reference || ''}</li>`,
                      `<li>Pickup Date: ${response.pickup_date}</li>`,
                      `<li>Shipper's Name: ${response.shipper.first_name || ''} ${response.shipper.last_name}</li>`,
                      `<li>Recipient's Name: ${response.shipper.first_name} ${response.shipper.last_name}</li>`,
                      `<a href="${urlPath}">More info</a>`,
                      '</ul>'
                    );
        },//end success:
        error: function(error){
          if (error.statusText === "Not Found"){
            output.push(
                        `<h3>Order #${searchInput} could not be found</h3>`,
                        '<p>Please check your ',
                        `<a href="${orderHistoryPath}">order history</a> `,
                        'and try again.</p>'
                       );
          } else {
            // TODO: generic message to return
          }
        },//end error:
        complete: function(){
          $('#search').val('');
          $('input[type="submit"]').prop('disabled', false);
          output.push('</div>');
          $('.js-searchResults').html(output.join(''));
        }//end complete:

      });//end ajax()
    });//end submit()
  });//end function() - document ready
</script>
<commit_msg>Add a bootstrap alert box display search orders<commit_after><div class="container account">
  <h1 class="page-title">Account Details</h1>

  <h2 class="order-search">Search Orders</h2>
    <%= form_tag(account_orders_path(@user_account), method: "get", id: "search-form") do %>
      <%= text_field_tag :search, nil, placeholder: "Enter order number" %>
      <%= submit_tag "Find Order#", :name => nil %>
    <% end %>

  <div class="js-searchResults"></div>

  <h2>Profile</h2>
  <ul>
    <li><b>Account Type:</b> <%= @user_account.account_type %></li>
    <li><b>First Name:</b> <%= @user_account.first_name %></li>
    <li><b>Last Name:</b> <%= @user_account.last_name %></li>
    <li><b>Company:</b> <%= @user_account.company %></li>
  </ul>

  <h2>Address</h2>
  <% if @user_account.addresses.present? %>
    <ul>
      <% @user_account.addresses.each do |address| %>
        <li><b>Type of Address:</b> <%= address.address_type %></li>
        <li><b>Street:</b> <%= address.street_address %></li>
        <li><b>Apt/Unit/Floor:</b> <%= address.secondary_address %></li>
        <li><b>City:</b> <%= address.city %></li>
        <li><b>State:</b> <%= address.state %></li>
        <li><b>Zip:</b> <%= address.zip %></li>
        <li><b>Country:</b> <%= address.country %></li>
      <% end %>
    </ul>
  <% else %>
    <p>Your account doesn't have an address at this time.</p>
  <% end %>

  <h2>Phone Number</h2>
  <% if @user_account.phones.present? %>
    <ul>
      <% @user_account.phones.each do |phone| %>
      <li><b>Phone Type:</b> <%= phone.phone_type %></li>
      <li><b>Phone Number:</b> <%= phone.phone_number %></li>
      <li><b>Ext:</b> <%= phone.ext %></li>
      <% end %>
    </ul>
  <% else %>
    <p>Your account doesn't have phone number at this time.</p>
  <% end %>

  <%= link_to "Edit Account", edit_account_path(@user_account), class: "btn btn-primary"%>

  <h2>Log in</h2>
  <ul>
    <li><b>Email:</b> <%= @user_account.user.email %></li>
    <li><b>Password:</b> *********</li>
  </ul>

  <%= link_to "Edit Log in", edit_user_registration_path, class: "btn btn-primary" %>

</div><!-- /.container -->

<script type="text/javascript">
  $( document ).on('turbolinks:load', function() {

    $("#search-form").submit(function(event){

      let searchInput = $('#search').val();
      let orderHistoryPath = "<%= account_orders_path(@user_account) %>";
      let output = [
            '<div class="alert panel panel-default alert-dismissible">',
            '<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>'
        ];
      event.preventDefault();

      $.ajax({
        url: this.action,
        data: $(this).serialize(),
        dataType: "json",
        type: this.method,

        success: function(response){
          let urlPath = `/account/${response.account.slug}/orders/${response.id}`;

          output.push(
                      `<h1>Order #${response.id}</h1>`,
                      '<ul>',
                      `<li>Number of items: ${response.number_of_items}</li>`,
                      `<li>Shipping Reference: ${response.shipping_reference || ''}</li>`,
                      `<li>Pickup Date: ${response.pickup_date}</li>`,
                      `<li>Shipper's Name: ${response.shipper.first_name || ''} ${response.shipper.last_name}</li>`,
                      `<li>Recipient's Name: ${response.shipper.first_name} ${response.shipper.last_name}</li>`,
                      `<a href="${urlPath}">More info</a>`,
                      '</ul>'
                    );
        },//end success:
        error: function(error){
          if (error.statusText === "Not Found"){
            output.push(
                        `<h3>Order #${searchInput} could not be found</h3>`,
                        '<p>Please check your ',
                        `<a href="${orderHistoryPath}">order history</a> `,
                        'and try again.</p>'
                       );
          } else {
            // TODO: generic message to return
          }
        },//end error:
        complete: function(){
          $('#search').val('');
          $('input[type="submit"]').prop('disabled', false);
          output.push('</div>');
          $('.js-searchResults').html(output.join(''));
        }//end complete:

      });//end ajax()
    });//end submit()
  });//end function() - document ready
</script>

{'fraction_non_alphanumeric': 0.21495652173913044, 'fraction_numerical': 0.0037101449275362317, 'mean_word_length': 2.298661567877629, 'pattern_counts': {'":': 0, '<': 307, '<?xml version=': 0, '>': 309, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3691021', 'n_tokens_mistral': 2926, 'n_tokens_neox': 2740, 'n_words': 530}