<% content_for :title, 'components' %>

<div class="flex justify-end mb-6">
  <%= link_to new_admin_component_path, class: 'btn-primary' do %>
    <svg class="w-4 h-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
      <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
    </svg>
    新增
  <% end %>
</div>

<!-- This example requires Tailwind CSS v2.0+ -->
<div class="flex flex-col">
  <div class="-my-2 overflow-x-auto sm:-mx-6 lg:-mx-8">
    <div class="py-2 align-middle inline-block min-w-full sm:px-6 lg:px-8">
      <div class="shadow overflow-hidden border-b border-gray-200 sm:rounded-lg">
        <table class="min-w-full divide-y divide-gray-200">
          <thead class="bg-gray-50">
            <tr>
              <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                Name
              </th>
              <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                Articles
              </th>
              <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                Sort Num
              </th>
              <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                Creator
              </th>
              <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                Deleted At
              </th>
              <th scope="col" class="relative px-6 py-3">
                <span class="sr-only">Edit</span>
              </th>
            </tr>
          </thead>
          <tbody class="bg-white divide-y divide-gray-200">
            <% @components.each do |component| %>
            <tr>
              <td class="px-6 py-4 whitespace-nowrap">
                
                <div class="text-sm text-gray-500">
                  <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800"><%= component.name %>
                  </span>
                </div>

              </td>
              <td class="px-6 py-4 whitespace-nowrap">
                <div class="text-sm text-gray-900"><%= component.articles.count %></div>
               
              </td>
              <td class="px-6 py-4 whitespace-nowrap">
                <div class="text-sm text-gray-900"><%= component.ord %></div>
               
              </td>
              <td class="px-6 py-4 whitespace-nowrap">
                
                  <%= component.user&.username || "system" %>
                
              </td>
              <td class="px-6 py-4 whitespace-nowrap">
                <div class="text-sm text-gray-900"><%= component.deleted_at %></div>
               
              </td>

              <td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
                <%= link_to "编辑", edit_admin_component_path(component), class: "btn-green" %>
                <% if component.deleted_at %>
                  <%= link_to "恢复", restore_admin_component_path(component), method: :put, class: "btn-primary" %>
                <% else %>
                  <%= link_to "软删", admin_component_path(component), method: :delete, class: "btn-cancel" %>
                <% end %>
              </td>
            </tr>
            <% end %>

            <!-- More people... -->
          </tbody>
        </table>
        
        
      </div>
    </div>
    <div class="py-2 px-8">
       <%== pagy_nav(@pagy) %>
    </div>
  </div>
</div>