<%- title t('importing.title') %>

<p><%= t('importing.intro', site_name: site_name) %></p>

<%= form_tag(import_add_path) do |f| %>
  <p>
    <label for="sync-urls"><%= t('importing.url_entry_label') %></label><br>
    <textarea id="sync-urls" name="sync_urls" rows="5" required style="width: 75%"></textarea>
  </p>

  <p class="radio-group">
    <%= t('importing.language.label') %><br>
    <input name="sync-language" id="sync-language-detect" type="radio" checked value=""><label for="sync-language-detect"><%= t('importing.language.detect') %></label><br>
    <input name="sync-language" id="sync-language-js" type="radio" value="js"><label for="sync-language-js"><%= t('importing.language.js') %></label><br>
    <input name="sync-language" id="sync-language-css" type="radio" value="css"><label for="sync-language-css"><%= t('importing.language.css') %></label>
  </p>

  <p class="radio-group">
    <%= t('importing.sync_type_label') %><br>
    <input name="sync-type" id="sync-type-2" type="radio" checked value="automatic"><label for="sync-type-2"><%= t('scripts.sync_type_2.name') %> - <%= t('scripts.sync_type_2.description') %></label><br>
    <input name="sync-type" id="sync-type-1" type="radio" value="manual"><label for="sync-type-1"><%= t('scripts.sync_type_1.name') %> - <%= t('scripts.sync_type_1.description') %></label>
  </p>

  <%= it('importing.additional_info_html', webhook_info_link: user_webhook_info_path, site_name: site_name) %>

  <%= submit_tag t('importing.submit') %>
<% end %>

<% if @syncing_scripts.any? %>
  <h3><%= t('importing.previously_imported.heading') %></h3>
  <ul>
    <% @syncing_scripts.each do |script| %>
      <% if script.sync_error.nil? %>
        <li class="successful-sync"><%= t('importing.previously_imported.successful_entry_html', script_link: link_to(script.name, script), sync_type: t("scripts.sync_type_#{Script.sync_types[script.sync_type]}.name"), last_sync_date: script.last_successful_sync_date.nil? ? t('importing.previously_imported.unknown_date') : markup_date(script.last_successful_sync_date)) %></li>
      <% else %>
        <li class="failed-sync"><%= t('importing.previously_imported.failed_entry_html', script_link: link_to(script.name, script), sync_type: t("scripts.sync_type_#{Script.sync_types[script.sync_type]}.name"), last_sync_attempt_date: script.last_attempted_sync_date.nil? ? t('importing.previously_imported.unknown_date') : markup_date(script.last_attempted_sync_date), sync_error: script.sync_error) %></li>
      <% end %>
    <% end %>
  </ul>
<% end %>
