<% content_for :title, 'Imports' %>

<div class="w-full">
  <div class="flex justify-between items-center">
    <h1 class="font-bold text-4xl">Imports</h1>
    <%= link_to "New import", new_import_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %>
  </div>

  <div id="imports" class="min-w-full">
    <% if @imports.empty? %>
      <div class="hero min-h-80 bg-base-200">
        <div class="hero-content text-center">
          <div class="max-w-md">
            <h1 class="text-5xl font-bold">Hello there!</h1>
            <p class="py-6">
              Here you'll find your imports, But now there are none. Let's <%= link_to 'create one', new_import_path, class: 'link' %>!
            </p>
          </div>
        </div>
      </div>
    <% else %>
      <div class="overflow-x-auto">
        <table class="table">
          <!-- head -->
          <thead>
            <tr>
              <th>Name</th>
              <th>Processed</th>
              <th>Doubles</th>
              <th>Created at</th>
            </tr>
          </thead>
          <tbody>
            <% @imports.each do |import| %>
              <tr>
                <td>
                  <%= link_to import.name, import, class: 'underline hover:no-underline' %> (<%= import.source %>)
                </td>
                <td>
                  <%= "✅" if import.processed == import.raw_points %>
                  <%= "#{import.processed}/#{import.raw_points}" %>
                </td>
                <td><%= import.doubles %></td>
                <td><%= import.created_at.strftime("%d.%m.%Y, %H:%M") %></td>
              </tr>
            <% end %>
          </tbody>
        </table>
      </div>
    <% end %>
  </div>
</div>
