% layout 'admin';
% title 'Transactions';
% content_for javascript => begin
% end
% if ( my $error = flash 'error' ) {
  <div class="alert alert-danger" role="alert">
    <strong>Error!</strong> <%= $error %>
  </div>
% } elsif ( my $success = flash 'success' ) {
  <div class="alert alert-success" role="alert">
    <strong>Success!</strong> <%= $success %>
  </div>
% }
<div class="row mb-3">
  <div class="col">
    <div class="card">
      <h3 class="card-header">
        Transactions
      </h3>
      <div class="list-group list-group-flush">
      % for my $transaction ( $transactions->all ) {
          <a href="<%= url_for . '/' . $transaction->id %>" class="list-group-item list-group-item-action" target="_blank">
            <div class="row">
              <div class="col-md-4 row">
                <div class="col my-auto">
                  <div class="row">
                    <div class="col">From: <%= $transaction->buyer->name %></div>
                  </div>
                  <div class="row">
                    <div class="col">To: <%= $transaction->seller->name %></div>
                  </div>
                </div>
              </div>
              <div class="col-md-4 text-center my-auto"><h3><%= sprintf('£%.2f', $transaction->value / 100000) %></h3></div>
              <div class="col-md-4 text-right my-auto"><%= format_human_datetime $transaction->purchase_time %></div>
            </div>
          </a>
      % }
      </div>
    </div>
  </div>
</div>
<div class="row">
  <div class="col">
      %= bootstrap_pagination( $c->param('page') || 1, $transactions->pager->last_page, { class => 'justify-content-center' } );
  </div>
</div>
