<div class="row m-3">
  <div class="col justify-content-end">
    <%= form_tag(internal_organizations_path, method: "get") do %>
      <div class="form-row justify-content-end">
        <div class="form-group">
          <%= text_field_tag(:search, params[:search]) %>
          <%= submit_tag("Search") %>
        </div>
      </div>
    <% end %>
  </div>
</div>

<%= paginate @organizations %>

<table class="table">
  <thead>
    <tr>
      <th scope="col">Name</th>
      <th scope="col">ID</th>
      <th scope="col">Twitter</th>
      <th scope="col">GitHub</th>
      <th scope="col">URL</th>
    </tr>
  </thead>
  <tbody>
    <% @organizations.each do |organization| %>
      <tr>
        <td><%= link_to "@#{organization.name}", internal_organization_path(organization.id) %></td>
        <td><%= organization.id %></td>
        <% if organization.twitter_username %>
          <td><%= link_to organization.twitter_username, "https://twitter.com/#{organization.twitter_username}" %></td>
        <% else %>
          <td>N/A</td>
        <% end %>
        <% if organization.github_username %>
          <td><%= link_to organization.github_username, "https://github.com/#{organization.github_username}" %></td>
        <% else %>
          <td>N/A</td>
        <% end %>
        <% if organization.url %>
          <td><%= link_to organization.url, organization.url %></td>
        <% else %>
          <td>N/A</td>
        <% end %>
      </tr>
    <% end %>
  </tbody>
</table>

<%= paginate @organizations %>
