|
1 | 1 | <div class="d-flex justify-content-end">
|
2 | 2 | <% if current_user.id == @listing.user_id %>
|
| 3 | +<% # Check current user owns the listing then show Edit/Remove functions %> |
3 | 4 | <div>
|
4 | 5 | <%= link_to "Edit", edit_listing_path(@listing), class: "btn btn-primary mr-2" %>
|
5 | 6 | <%= link_to "Remove", listing_path(@listing.id), data: { toggle: "modal", target: "#RemoveListingModal" }, class: "btn btn-danger" %>
|
|
29 | 30 | </div>
|
30 | 31 | </div>
|
31 | 32 | <% else %>
|
32 |
| - <% # Check to see if the user has already favourited the listing %> |
33 |
| - <% if current_user.favourites.exists?(@listing.id) %> |
34 |
| - <%= link_to image_tag("favourited.svg"), favourite_listing_path(@listing, type: "unfavourite", id: @listing.id), data: { toggle: "tooltip", placement: "bottom", title: "Favourited" }, method: :put %> |
35 |
| - <% else %> |
36 |
| - <%= link_to image_tag("favourite.svg"), favourite_listing_path(@listing, type: "favourite", id: @listing.id), data: { toggle: "tooltip", placement: "bottom", title: "Add to Favourites" }, method: :put %> |
37 |
| - <% end %> |
| 33 | + <% # Check if the user has already favourited the listing %> |
| 34 | + <% if current_user.favourites.exists?(@listing.id) %> |
| 35 | + <%= link_to image_tag("favourited.svg"), favourite_listing_path(@listing, type: "unfavourite", id: @listing.id), data: { toggle: "tooltip", placement: "bottom", title: "Favourited" }, method: :put %> |
| 36 | + <% else %> |
| 37 | + <%= link_to image_tag("favourite.svg"), favourite_listing_path(@listing, type: "favourite", id: @listing.id), data: { toggle: "tooltip", placement: "bottom", title: "Add to Favourites" }, method: :put %> |
| 38 | + <% end %> |
38 | 39 | <% end %>
|
39 | 40 | </div>
|
40 | 41 |
|
|
64 | 65 | <h5>Description:</h5>
|
65 | 66 | <%= @listing.description %>
|
66 | 67 | </div>
|
67 |
| - <% if current_user.id != @listing.user_id %> |
| 68 | + <% if current_user.id != @listing.user_id && @listing.purchase == nil %> |
68 | 69 | <div class="mb-2">
|
69 | 70 | <button data-stripe="payment" class="btn btn-primary">Purchase</button>
|
70 | 71 | </div>
|
71 | 72 | <% end %>
|
| 73 | + <% if @listing.purchase != nil %> |
| 74 | + <div class="mb-2"> |
| 75 | + <button class="btn btn-danger disabled">SOLD</button><br> |
| 76 | + <small class="text-muted"><%= @listing.purchase.created_at.strftime("%Y/%m/%d %H:%M") %></small> |
| 77 | + </div> |
| 78 | + <% end %> |
72 | 79 | </div>
|
73 | 80 | </div>
|
74 | 81 |
|
|
0 commit comments