diff options
Diffstat (limited to 'app/views/bazaar')
-rw-r--r-- | app/views/bazaar/index.html.erb | 128 |
1 files changed, 128 insertions, 0 deletions
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> |