defmodule MvWeb.ImportLive.Components do @moduledoc """ Function components for the Import LiveView: import form, progress, results, custom fields notice, and template links. Keeps the main LiveView focused on mount/handle_event/handle_info and glue code. """ use Phoenix.Component use Gettext, backend: MvWeb.Gettext import MvWeb.CoreComponents use Phoenix.VerifiedRoutes, endpoint: MvWeb.Endpoint, router: MvWeb.Router, statics: MvWeb.static_paths() @doc """ Renders the info box explaining that data fields must exist before import and linking to Manage Member Data (custom fields). """ def custom_fields_notice(assigns) do ~H"""
{gettext( "Use the data field name as the CSV column header in your file. Data fields must exist in Mila before importing, because unknown data field columns will be ignored with a warning. Groups and membership fees are not supported for import." )}
<.link href={~p"/settings#custom_fields"} class="link" data-testid="custom-fields-link" > {gettext("Manage Member Data")}
{gettext("Download CSV templates:")}
{gettext("Processing chunk %{current} of %{total}...", current: @import_progress.current_chunk, total: @import_progress.total_chunks )}
<% end %> <%= if @import_progress.status == :done or @import_status == :error do %> <.import_results {assigns} /> <% end %><.icon name="hero-check-circle" class="size-4 inline mr-1" aria-hidden="true" /> {gettext("Successfully inserted: %{count} member(s)", count: @import_progress.inserted )}
<%= if @import_progress.failed > 0 do %><.icon name="hero-exclamation-circle" class="size-4 inline mr-1" aria-hidden="true" /> {gettext("Failed: %{count} row(s)", count: @import_progress.failed)}
<% end %> <%= if @import_progress.errors_truncated? do %><.icon name="hero-information-circle" class="size-4 inline mr-1" aria-hidden="true" /> {gettext("Error list truncated to %{count} entries", count: @max_errors)}
<% end %>