<% @page_title = "Import status" %>

<%= turbo_stream_from @import %>

<div class="panel panel--centered flex flex-column gap-half" style="--panel-size: 54ch;">
  <h1 class="txt-x-large font-weight-black margin-block-end">Import status</h1>

  <% case @import.status %>
  <% when "pending", "processing" %>
    <div class="import-status">
      Your import is in progress. This may take a while for large accounts.
    </div>
  <% when "completed" %>
    <div class="import-status import-status--success">
      <div><strong>Your import was successful!</strong></div>
      <%= link_to "Go to your account →", landing_url(script_name: @import.account.slug), class: "btn btn--link" %>
    </div>
  <% when "failed" %>
    <div class="import-status import-status--error">
      <div><strong>Import failed</strong></div>
      <% if @import.failed_due_to_conflict? %>
        <div>The account you’re trying to import already exists. Make sure you’re importing a <%= Fizzy.saas? ? "self-hosted" : "fizzy.do" %> account.</div>
      <% elsif @import.failed_due_to_invalid_export? %>
        <div>The .zip file you uploaded doesn’t look like a Fizzy account export.</div>
      <% else %>
        <div>This may be due to corrupted export data or a conflict with existing data. Please try again with a fresh export.</div>
      <% end %>
      <%= link_to "Try again", new_account_import_path, class: "btn" %>
    </div>
  <% end %>
</div>

<% content_for :footer do %>
  <%= render "sessions/footer" %>
<% end %>
