summaryrefslogtreecommitdiff
path: root/app/views
diff options
context:
space:
mode:
authorDavid Gay <david@davidgay.org>2021-05-23 17:06:34 -0400
committerDavid Gay <david@davidgay.org>2021-05-23 17:06:34 -0400
commitaba212e13062c43a1192ef885b05145ac1cc9fe7 (patch)
tree61e3850ec0c86913a7e2d42076bcd73aa59f480a /app/views
parent44facc2e567eb3c045ce082428f42276e45b0202 (diff)
Bazaar with buy orders, sell orders, and order cancellation
Diffstat (limited to 'app/views')
-rw-r--r--app/views/application/_navbar.html.erb3
-rw-r--r--app/views/bazaar/index.html.erb128
2 files changed, 131 insertions, 0 deletions
diff --git a/app/views/application/_navbar.html.erb b/app/views/application/_navbar.html.erb
index ef81d6c..c0e2761 100644
--- a/app/views/application/_navbar.html.erb
+++ b/app/views/application/_navbar.html.erb
@@ -12,5 +12,8 @@
<li class="mr-6 inline">
<%= link_to "Hearth", character_hearth_path(current_char) %>
</li>
+ <li class="mr-6 inline">
+ <%= link_to "Bazaar", bazaar_path %>
+ </li>
<% end %>
</ul>
diff --git a/app/views/bazaar/index.html.erb b/app/views/bazaar/index.html.erb
new file mode 100644
index 0000000..63d708f
--- /dev/null
+++ b/app/views/bazaar/index.html.erb
@@ -0,0 +1,128 @@
+<h1 class="text-3xl mb-4">Numedite Bazaar</h1>
+
+<p class="mb-2">The small, cloaked people known as the Numedites travel this way and that across the planes.
+ Because their ways are spiritual in nature, they use their innate magic to facilitate
+ distant trade at no cost to their clientele.</p>
+
+<p class="mb-2">You have <span class="font-bold"><%= current_char.vestige %></span> vestige.</p>
+
+<div class="my-8">
+ <h2 class="text-xl mb-4">Post Order</h2>
+
+ <p class="mb-4">Sell orders can be posted with a caravan of numedites, offering items for vestige.
+ Buy orders can also be posted, offering vestige for items.</p>
+
+ <%= form_with url: bazaar_order_path, class: "my-4" do |f| %>
+ <div>
+ <%= f.label :item_id, "Item" %>
+ <%= f.select :item_id, @items.map { |i| [i.name, i.id] } %>
+ </div>
+ <div>
+ <%= f.label :quantity, "Quantity" %>
+ <%= f.number_field :quantity, required: true, min: 1, max: 2_000_000_000 %>
+ </div>
+ <div>
+ <%= f.label :price_each, "Price Each" %>
+ <%= f.number_field :price_each, required: true, min: 1, max: 2_000_000_000 %>
+ </div>
+ <div>
+ <%= f.label :buy_order, "Post as buy order" %>
+ <%= f.check_box :buy_order %>
+ </div>
+ <div>
+ <%= f.submit "Post Order" %>
+ </div>
+ <% end %>
+</div>
+
+<div class="my-8">
+ <h2 class="text-xl mb-4">Your Orders</h2>
+ <table class="table-auto mb-8">
+ <thead>
+ <tr>
+ <th class="table-header-padded">Item</th>
+ <th class="table-header-padded">Quantity</th>
+ <th class="table-header-padded">Type</th>
+ <th class="table-header-padded">Price Each</th>
+ <th class="table-header-padded">Cancel</th>
+ </tr>
+ </thead>
+ <tbody>
+ <% @bazaar_orders.where(character: current_char).each do |bo| %>
+ <tr>
+ <td class="table-cell-padded"><%= bo.item.name %></td>
+ <td class="table-cell-padded"><%= bo.quantity %></td>
+ <td class="table-cell-padded"><%= bo.buy_order? ? "Buy" : "Sell" %></td>
+ <td class="table-cell-padded"><%= bo.price_each %></td>
+ <td class="table-cell-padded">
+ <%= button_to "Cancel", bazzar_cancel_offer_path(id: bo.id), method: :delete %>
+ </td>
+ </tr>
+ <% end %>
+ </tbody>
+ </table>
+</div>
+
+<div class="my-8">
+ <h2 class="text-xl mb-4">Sell Orders</h2>
+
+ <table class="table-auto mb-8">
+ <thead>
+ <tr>
+ <th class="table-header-padded">Item</th>
+ <th class="table-header-padded">Quantity</th>
+ <th class="table-header-padded">From</th>
+ <th class="table-header-padded">Price Each</th>
+ <th class="table-header-padded">Buy</th>
+ </tr>
+ </thead>
+ <tbody>
+ <% @bazaar_orders.where(buy_order: false).each do |bo| %>
+ <tr>
+ <td class="table-cell-padded"><%= bo.item.name %></td>
+ <td class="table-cell-padded"><%= bo.quantity %></td>
+ <td class="table-cell-padded"><%= bo.character.name %></td>
+ <td class="table-cell-padded"><%= bo.price_each %></td>
+ <td class="table-cell-padded">
+ <%= form_with url: bazzar_accept_offer_path(id: bo.id) do |f| %>
+ <%= f.number_field :quantity, value: 1, min: 1, max: 2_000_000_000, required: true %>
+ <%= f.submit "Buy" %>
+ <% end %>
+ </td>
+ </tr>
+ <% end %>
+ </tbody>
+ </table>
+</div>
+
+<div class="my-8">
+ <h2 class="text-xl mb-4">Buy Orders</h2>
+
+ <table class="table-auto mb-8">
+ <thead>
+ <tr>
+ <th class="table-header-padded">Item</th>
+ <th class="table-header-padded">Quantity</th>
+ <th class="table-header-padded">From</th>
+ <th class="table-header-padded">Price Each</th>
+ <th class="table-header-padded">Sell</th>
+ </tr>
+ </thead>
+ <tbody>
+ <% @bazaar_orders.where(buy_order: true).each do |bo| %>
+ <tr>
+ <td class="table-cell-padded"><%= bo.item.name %></td>
+ <td class="table-cell-padded"><%= bo.quantity %></td>
+ <td class="table-cell-padded"><%= bo.character.name %></td>
+ <td class="table-cell-padded"><%= bo.price_each %></td>
+ <td class="table-cell-padded">
+ <%= form_with url: bazzar_accept_offer_path(id: bo.id) do |f| %>
+ <%= f.number_field :quantity, value: 1, min: 1, max: 2_000_000_000, required: true %>
+ <%= f.submit "Sell" %>
+ <% end %>
+ </td>
+ </tr>
+ <% end %>
+ </tbody>
+ </table>
+</div>