<% page_title "User Upgrade Status" %>
<%= render "users/secondary_links" %>

<div id="c-user-upgrades">
  <div id="a-show">
    <h1>User Upgrade</h1>

    <p>
      <ul>
        <li>
          <strong>Purchased</strong>
          by <%= link_to_user @user_upgrade.purchaser %>
          <% if @user_upgrade.is_gift? %>
            for <%= link_to_user @user_upgrade.recipient %>
          <% end %>
        </li>
        <li>
          <strong>Updated</strong>
          <%= time_ago_in_words_tagged @user_upgrade.updated_at %>
        </li>
        <li>
          <strong>Upgrade Type</strong>
          <%= @user_upgrade.upgrade_type.humanize %>
        </li>
        <li>
          <strong>Status</strong>
          <%= @user_upgrade.status.humanize %>
        </li>
      </ul>
    </p>

    <% if @user_upgrade.complete? %>
      <% if @user_upgrade.is_gift? && CurrentUser.user == @user_upgrade.recipient %>
        <p><%= link_to_user @user_upgrade.purchaser %> has upgraded your account to <%= @user_upgrade.level_string %>. Enjoy your new account!</p>
      <% elsif @user_upgrade.is_gift? && CurrentUser.user == @user_upgrade.purchaser %>
        <p><%= link_to_user @user_upgrade.recipient %> is now a <%= @user_upgrade.level_string %> user. Thanks for supporting the site! A receipt has been sent to your email.</p>
      <% else %>
        <p>You are now a <%= @user_upgrade.level_string %> user. Thanks for supporting the site! A receipt has been sent to your email.</p>
      <% end %>

      <%= render "stripe_links", user_upgrade: @user_upgrade %>
    <% elsif @user_upgrade.refunded? %>
      <p>This purchase has been refunded. A receipt has been sent to your email. It can take up to
      5-10 days for the refund to appear on your credit card or bank statement. If it takes longer,
      please contact your bank for assistance.</p>

      <%= render "stripe_links", user_upgrade: @user_upgrade %>
    <% else %>
      <%= content_for :html_header do %>
        <meta http-equiv="refresh" content="5">
      <% end %>

      <p>This order is still being processed. You will be notified as soon as the order is complete.</p>
    <% end %>
  </div>
</div>
