summaryrefslogtreecommitdiff
path: root/app/views/characters/hearth/hearth_plantings/index.html.erb
blob: 3f6964f5dee4b16a654e26f33cc8d27fe93510b1 (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
<h1 class="text-3xl mb-2">Loamspire</h1>

<p>You have <span class="font-bold"><%= @hearth.available_planting_spots %></span> available planting spots.</p>

<div class="my-4">
  <div data-controller="activity-select">
    <%= form_with url: start_activity_path, method: :post do |f| %>
      <%= f.select :id, @planting_activities.sort_by { |a| a.name }.map { |a| [a.name, a.id] },
                   {}, { data: { activity_select_target: "select", action: "activity-select#load" } } %>
      <%= f.number_field :actions, value: 1, size: 5, min: 1, max: 2_000_000_000 %>
      <%= f.submit "Plant" %>
    <% end %>
    <div data-activity-select-target="output" class="my-1"></div>
  </div>
</div>

<div class="grid grid-cols-1 lg:grid-cols-2 gap-4">
  <% @hearth_plantings.sort_by(&:ripens_at).each do |hp| %>
    <div class="flex justify-between items-center border-2 border-yellow-900 rounded p-2">
      <h2 class="font-bold"><%= hp.item.name %></h2>
      <% if hp.ripens_at > Time.now %>
        <p class="text-sm">Ripens in <%= distance_of_time_in_words_to_now(hp.ripens_at) %></p>
      <% else %>
        <% harvest_activity = Activity.find_by_gid(hp.item.whatnot[:harvest_activity]) %>
        <%= form_with url: start_activity_path(harvest_activity) do |f| %>
          <%= f.hidden_field :id, value: harvest_activity.id %>
          <%= f.hidden_field :actions, value: current_char.hearth.ripe_hearth_plantings_of(hp.item).count %>
          <%= f.submit "Harvest" %>
        <% end %>
      <% end %>
    </div>
  <% end %>
</div>