<%= render HeaderComponent.new(title: "Lightning Network") %>

<%= render MainSimpleComponent.new do %>
  <section>
    <%= render QuickstatsContainerComponent.new do %>
      <%= render QuickstatsItemComponent.new(
          type: :number,
          title: 'Current user balance',
          value: @ln[:current_balance],
          unit: 'sats'
      ) %>
      <%= render QuickstatsItemComponent.new(
          type: :number,
          title: 'Users with sats',
          value: @ln[:users_with_sats],
          meta: "/ #{User.count}"
      ) %>
    <% end %>
  </section>

  <section>
    <h3>Accounts</h3>
    <table class="divided">
      <thead>
        <tr>
          <th>LN Account</th>
          <th>User</th>
          <th>Balance</th>
        </tr>
      </thead>
      <tbody>
        <% @accounts.each do |account| %>
          <tr>
            <td class="font-mono">
              <%= account.login %>
            </td>
            <td>
              <% if user = @users.find{ |u| u[2] == account.login } %>
                <%= link_to "#{user[0]}@#{user[1]}", admin_user_path("#{user[0]}@#{user[1]}"), class: "ks-text-link" %>
              <% end %>
            </td>
            <td><%= number_with_delimiter account.balance.to_i.to_s %></td>
          </tr>
        <% end %>
      </tbody>
    </table>
  </section>
<% end %>
