summaryrefslogtreecommitdiff
path: root/app/views/bazaar/index.html.erb
blob: 63d708f3de1b4d58489842349ffa5674fd39cdc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
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>