Merge pull request #46 from Pear-Trading/finn/ViewUserTransactions

View Transactions from a User on their page
This commit is contained in:
Finn 2017-09-05 12:39:06 +01:00 committed by GitHub
commit e330812cf8
2 changed files with 36 additions and 1 deletions

View file

@ -33,7 +33,17 @@ sub read {
my $id = $c->param('id'); my $id = $c->param('id');
if ( my $user = $c->user_result_set->find($id) ) { if ( my $user = $c->user_result_set->find($id) ) {
$c->stash( user => $user ); my $transactions = $user->entity->purchases->search(
undef, {
page => $c->param('page') || 1,
rows => 10,
order_by => { -desc => 'submitted_at' },
},
);
$c->stash(
user => $user,
transactions => $transactions,
);
} else { } else {
$c->flash( error => 'No User found' ); $c->flash( error => 'No User found' );
$c->redirect_to( '/admin/users' ); $c->redirect_to( '/admin/users' );

View file

@ -86,3 +86,28 @@
<button class="btn btn-primary form-control" type="submit">Edit Account</button> <button class="btn btn-primary form-control" type="submit">Edit Account</button>
</div> </div>
</form> </form>
<div class="card mb-3">
<h3 class="card-header">
Transactions
</h3>
<ul class="list-group list-group-flush">
% for my $transaction ( $transactions->all ) {
<li class="list-group-item">
<div class="container">
<div class="row text-center">
<div class="col">From: <%= $transaction->buyer->name %></div>
<div class="col">To: <%= $transaction->seller->name %></div>
<div class="col">Value: <%= $transaction->value %></div>
<div class="col">Submitted At: <%= $transaction->submitted_at %></div>
<div class="col">Purchase Time: <%= $transaction->purchase_time %></div>
</div>
</div>
</li>
% }
<li class="list-group-item">
<div class="container">
%= bootstrap_pagination( $c->param('page') || 1, $transactions->pager->last_page, { class => 'justify-content-center' } );
</div>
</li>
</ul>
</div>