<%
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

      <table class="merge_results">
        <thead>
          <tr class="result">
            <th><%= t('user', 'User') %></th>
            <td><%= user.name %></td>
            <td><%= other_user.name %></td>
          </tr>
        </thead>
        <tbody>
          <tr class="result">
            <th><%= t('action', 'Action') %></th>
            <td><%= t('will_be_deleted', 'will be deleted') %></td>
            <td><%= t('will_be_kept', 'will be kept') %></td>
          </tr>
          <tr class="result">
            <th><%= t('emails', 'Emails') %></th>
            <td><%= t('no_emails', 'no emails') %></td>
            <td>
                <% emails = Canvas::ICU.collate((user.communication_channels.unretired.email + other_user.communication_channels.unretired.email).map(&:path).uniq) %>
                <% if emails.empty? %>
                <%= t('no_emails', 'no emails') %>
                <% else %>
                  <ul class="unstyled_list">
                    <% emails.each do |email| %>
                      <li><%= email %></li>
                    <% end %>
                  </ul>
                <% end %>
            </td>
          </tr>
          <tr class="result">
            <th><%= t('logins', 'Logins') %></th>
            <td><%= t('no_logins', 'no logins') %></td>
            <td>
              <% pseudonyms = Canvas::ICU.collate_by(user.pseudonyms.active + other_user.pseudonyms.active, &:unique_id) %>
              <% if pseudonyms.empty? %>
                <%= t('no_logins', 'no logins') %>
              <% else %>
                <table>
                  <% pseudonyms.each do |pseudonym| %>
                    <tr>
                      <td><%= pseudonym.unique_id %></td>
                      <td><%= pseudonym.account.name %></td>
                    </tr>
                  <% end %>
                </table>
              <% end %>
            </td>
          </tr>
          <tr class="result">
            <th><%= t('enrollments', 'Enrollments') %></th>
            <td><%= t('no_enrollments', 'no enrollments') %></td>
            <td>
              <% enrollments = (user.enrollments.current + other_user.enrollments.current).sort_by{|e| [e.state_sortable, e.rank_sortable, Canvas::ICU.collation_key(e.course.name)] } %>
              <% if enrollments.empty? %>
                <%= t('no_enrollments', 'no enrollments') %>
              <% else %>
                <table>
                  <% enrollments.each do |enrollment| %>
                    <tr>
                      <td><%= enrollment.course.name %></td>
                      <td><%= enrollment.readable_type %></td>
                    </tr>
                  <% end %>
                </table>
              <% end %>
            </td>
          </tr>
        </tbody>
      </table>
