<div class="box box--message">
  <h2><%- @T('Last sync') %></h2>
  <% if _.isEmpty(@job.started_at): %>
    <% if @job.result && @job.result.error: %>
        <div class="alert alert--danger" role="alert"><%- @T('An error occurred: %s', @job.result.error) %></div>
    <% else if @job.result && @job.result.info: %>
        <div class="alert alert--info" role="alert"><%- @T('Info: %s', @job.result.info) %></div>
    <% else: %>
      <p><%- @T('Job is waiting to get started...') %></p>
    <% end %>
  <% else: %>
    <% if @job.finished_at: %>
      <p><%- @Ttimestamp(@job.started_at) %> - <%- @Ttimestamp(@job.finished_at) %></p>
      <% if @job.result && @job.result.error: %>
        <div class="alert alert--danger" role="alert"><%- @T('An error occurred: %s', @job.result.error) %></div>
      <% else if @job.result && @job.result.info: %>
        <div class="alert alert--info" role="alert"><%- @T('Info: %s', @job.result.info) %></div>
      <% end %>
    <% else: %>
      <% if @job.result && @job.result.error: %>
        <p><%- @Ttimestamp(@job.started_at) %></p>
        <div class="alert alert--danger" role="alert"><%- @T('An error occurred: %s', @job.result.error) %></div>
      <% else if @job.result && !@job.result.sum: %>
        <p><%- @Ttimestamp(@job.started_at) %> - <%- @T('Counting entries. This may take a while.') %></p>
      <% else: %>
        <p><%- @Ttimestamp(@job.started_at) %> - <%- @T('Running...') %></p>
        <div class="flex">
          <progress max="<%= @job.result.total %>" value="<%= @job.result.sum %>"></progress>
        </div>
      <% end %>
    <% end %>
    <% if !_.isEmpty(@job.result) && @job.result.sum: %>
      <ul>
        <li><%- @T('%s user to %s user', 'Exchange', 'Zammad') %> (<%= @job.result.sum %>/<%= @job.result.total %>):
          <ul>
            <li><%- @T('Users') %>: <%= @job.result.created %> <%- @T('created') %>, <%= @job.result.updated %> <%- @T('updated') %>, <%= @job.result.unchanged %> <%- @T('untouched') %>, <%= @job.result.skipped %> <%- @T('skipped') %>, <%= @job.result.failed %> <%- @T('failed') %>
          </ul>
          </li>
          <% if !_.isEmpty(@job.result.folders): %>
            <li><%- @T('%s folders', 'Exchange') %>:
              <ul>
                <% for folder, result of @job.result.folders: %>
                  <li><%- folder %>: <%= result.created %> <%- @T('created') %>, <%= result.updated %> <%- @T('updated') %>, <%= result.unchanged %> <%- @T('untouched') %>, <%= result.failed %> <%- @T('failed') %>
                <% end %>
              </ul>
            </li>
          <% end %>
      </ul>
    <% end %>
    <% if @job.finished_at: %>
      <button type="submit" class="btn btn--primary js-start-sync"><%- @T('Start new') %></button>
    <% end %>
  <% end %>
</div>
