This repository has been archived by the owner on Jul 30, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
395 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.user-header-wrapper { | ||
background: $color-gray-lightest; | ||
border-bottom: 1px solid $color-gray-light; | ||
} | ||
|
||
.user-subnav { | ||
clear: both; | ||
display: block; | ||
|
||
.active { | ||
background: $color-white; | ||
border: 1px solid $color-gray-light; | ||
border-bottom: none; | ||
text-decoration: none; | ||
} | ||
|
||
a { | ||
margin-top: 1rem; | ||
margin-bottom: -1px; | ||
border-bottom: 1px solid $color-gray-light; | ||
padding: 1rem; | ||
background: $color-gray-lightest; | ||
display: inline-block; | ||
line-height: $base-line-height; | ||
vertical-align: middle; | ||
} | ||
|
||
a:focus { | ||
box-shadow: none; | ||
} | ||
} | ||
|
||
.user-body-wrapper { | ||
margin-top: 1em; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class AccountBidsPlacedViewModel | ||
attr_reader :current_user | ||
|
||
def initialize(current_user:) | ||
@current_user = current_user | ||
end | ||
|
||
def bids_table_partial | ||
if auctions.empty? | ||
'bids/bids_table_none' | ||
else | ||
'bids/bids_table' | ||
end | ||
end | ||
|
||
def auctions | ||
@_auctions ||= AuctionQuery.new.with_bid_from_user(current_user.id).map do |auction| | ||
UserAuctionViewModel.new(auction, current_user) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
class UserAuctionViewModel | ||
attr_reader :auction, :user | ||
|
||
DATE_FORMAT = '%m/%d/%Y'.freeze | ||
NA_RESPONSE_STRING = '-'.freeze | ||
|
||
def initialize(auction, user) | ||
@auction = auction | ||
@user = user | ||
end | ||
|
||
def title | ||
auction.title | ||
end | ||
|
||
def id | ||
auction.id | ||
end | ||
|
||
def bidding_status | ||
BiddingStatusPresenterFactory.new(auction).create.label | ||
end | ||
|
||
def user_bid_count | ||
user_bids.count | ||
end | ||
|
||
def user_won_label | ||
if user_won? | ||
'Yes' | ||
elsif auction_over? | ||
'No' | ||
else | ||
NA_RESPONSE_STRING | ||
end | ||
end | ||
|
||
def user_lowest_bid | ||
Currency.new(user_bids.first.amount) | ||
end | ||
|
||
private | ||
|
||
def user_won? | ||
auction_over? && WinningBid.new(auction).find.bidder == user | ||
end | ||
|
||
def auction_over? | ||
BiddingStatus.new(auction).over? | ||
end | ||
|
||
def auction_rules | ||
RulesFactory.new(auction).create | ||
end | ||
|
||
def user_bids | ||
auction.bids.where(bidder: user).sort_by(&:amount) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<table class="striped-table"> | ||
<thead> | ||
<tr> | ||
<th scope="col"><%= t 'labels.vendor.account.bids_placed.columns.auction' %></th> | ||
<th scope="col"><%= t 'labels.vendor.account.bids_placed.columns.status' %></th> | ||
<th scope="col"><%= t 'labels.vendor.account.bids_placed.columns.number_bids' %></th> | ||
<th scope="col"><%= t 'labels.vendor.account.bids_placed.columns.lowest_bid' %></th> | ||
<th scope="col"><%= t 'labels.vendor.account.bids_placed.columns.won' %></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% view_model.auctions.each do |auction| %> | ||
<tr> | ||
<td><%= link_to(auction.title, auction_path(auction.id)) %></td> | ||
<td><%= auction.bidding_status %></td> | ||
<td><%= auction.user_bid_count %></td> | ||
<td><%= auction.user_lowest_bid %></td> | ||
<td><%= auction.user_won_label %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<%= t('labels.vendor.account.bids_placed.no_bids_html', | ||
index_url: Url.new(link_text: 'current and upcoming auctions', path_name: 'root')) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,15 @@ | ||
<div class="usa-grid"> | ||
<div> | ||
<%= link_to( | ||
"<icon class='fa fa-angle-double-left'></icon> Back to all auctions".html_safe, | ||
root_path, | ||
class: 'breadcrumb-link') %> | ||
<div class="user-profile"> | ||
<div class="user-header-wrapper"> | ||
<div class="usa-grid"> | ||
<div class="user-header-title"> | ||
<h1><%= t 'labels.vendor.account.title' %></h1> | ||
</div> | ||
<%= render partial: 'users/subnav', locals: {active: :bids_placed} %> | ||
</div> | ||
</div> | ||
<div class="user-body-wrapper"> | ||
<div class="usa-grid"> | ||
<%= render partial: @view_model.bids_table_partial, locals: {view_model: @view_model} %> | ||
</div> | ||
</div> | ||
|
||
<h1>My Bids</h1> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th scope="col">Auction</th> | ||
<th scope="col">Auction type</th> | ||
<th scope="col">Auction running?</th> | ||
<th scope="col">Amount</th> | ||
<th scope="col">Winning bid?</th> | ||
<th scope="col">Auction start time</th> | ||
<th scope="col">Auction end time</th> | ||
<th scope="col">Auction delivery deadline</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @bids.each do |bid| %> | ||
<tr> | ||
<td><%= link_to(bid.auction_title, auction_path(bid.auction)) %></td> | ||
<td><%= bid.formatted_type %></td> | ||
<td><%= bid.availability %></td> | ||
<td><%= bid.amount %></td> | ||
<td><%= bid.winning_status %></td> | ||
<td><%= bid.started_at %></td> | ||
<td><%= bid.ended_at %></td> | ||
<td><%= bid.delivery_due_at %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<table class="striped-table"> | ||
<thead> | ||
<tr> | ||
<th scope="col"><%= t 'labels.vendor.account.bids_placed.columns.auction' %></th> | ||
<th scope="col"><%= t 'labels.vendor.account.bids_placed.columns.status' %></th> | ||
<th scope="col"><%= t 'labels.vendor.account.bids_placed.columns.number_bids' %></th> | ||
<th scope="col"><%= t 'labels.vendor.account.bids_placed.columns.lowest_bid' %></th> | ||
<th scope="col"><%= t 'labels.vendor.account.bids_placed.columns.won' %></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% view_model.auctions.each do |auction| %> | ||
<tr> | ||
<td><%= link_to(auction.title, auction_path(auction.id)) %></td> | ||
<td><%= auction.bidding_status %></td> | ||
<td><%= auction.user_bid_count %></td> | ||
<td><%= auction.user_lowest_bid %></td> | ||
<td><%= auction.user_won_label %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<%= t('labels.vendor.account.bids_placed.no_bids_html', | ||
index_url: Url.new(link_text: 'current and upcoming auctions', path_name: 'root')) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="user-subnav"> | ||
<%= link_to I18n.t('labels.vendor.account.tabs.profile'), | ||
profile_path, | ||
class: "nav-auction #{ 'active' if active == :profile }" %> | ||
<%= link_to I18n.t('labels.vendor.account.tabs.bids_placed'), | ||
bids_placed_path, | ||
class: "nav-auction #{ 'active' if active == :bids_placed }" %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<div class="user-profile"> | ||
<div class="user-header-wrapper"> | ||
<div class="usa-grid"> | ||
<div class="user-header-title"> | ||
<h1><%= t 'labels.vendor.account.title' %></h1> | ||
</div> | ||
<%= render partial: 'users/subnav', locals: {active: :bids_placed} %> | ||
</div> | ||
</div> | ||
<div class="user-body-wrapper"> | ||
<div class="usa-grid"> | ||
<%= render partial: @view_model.bids_table_partial, locals: {view_model: @view_model} %> | ||
</div> | ||
</div> | ||
</div> |
Oops, something went wrong.