{# The health card — crate::pages::admin::ecb::ui::StatusFragment, and what ecb.html embeds on first load. It carries its own poll trigger rather than the page carrying it, so the trigger travels with each swap: while a batch is running the card asks for itself every few seconds, and the card that comes back after the batch finishes has no trigger, which is what stops the polling. #}

{{ page.headline() }} {% if page.import_running %}{{ nav.tr("ecb-import-running") }}{% endif %}

{{ page.explanation() }}

{# The question a reader came with. Coverage is a publication date, and turning it into "which transaction dates will post" means applying the rule the backend applies -- so the backend applies it and sends both bounds, rather than the page inviting the reader to do it in their head. #}

{{ nav.tr("ecb-postable-lead") }}

{% if let Some(through) = page.transactions_postable_through %}
{{ nav.tr("ecb-ordinary-transactions") }}
{{ nav.tr("ecb-dated-up-to") }} {{ through }}
{{ nav.tr("ecb-ordinary-rate-hint") }}
{{ nav.tr("ecb-statements-title") }}
{{ nav.tr("ecb-dated-up-to") }} {{ page.statements_postable_through.as_deref().unwrap_or("—") }}
{{ nav.tr("ecb-statements-rate-hint") }}

{{ nav.tr("ecb-postable-limit-hint") }}

{% else %}

{{ nav.tr("ecb-nothing") }} {{ nav.tr("ecb-no-publication-hint") }}

{% endif %}
{# Coverage first and on its own line: the two dates and the gap between them are the whole answer, and burying them in a four-column grid made them read as trivia. #}
{{ nav.tr("ecb-verified-through") }} {%- if let Some(date) = page.verified_through_date %}{{ date }} {%- else %}{{ nav.tr("ecb-never") }}{% endif -%}
{%- if page.healthy %}{{ nav.tr("ecb-up-to-date") }} {%- else if page.days_behind > 0 %}{{ page.behind_label() }} {%- else %}{{ nav.tr("ecb-no-coverage") }}{% endif -%}
{{ nav.tr("ecb-should-reach") }} {{ page.latest_verifiable_date }}
{{ nav.tr("ecb-last-attempt") }}
{% if let Some(when) = page.last_attempt() %}{{ when }}{% else %}{{ nav.tr("ecb-none-recorded") }}{% endif %}
{{ nav.tr("ecb-last-success") }}
{% if let Some(when) = page.last_success() %}{{ when }}{% else %}{{ nav.tr("ecb-none") }}{% endif %}
{{ nav.tr("ecb-next-import") }}
{{ page.next_import() }}
{% if let Some(date) = page.verified_through_date %}{{ nav.tr_args("ecb-currencies-on", [("date", date.clone())]) }}{% else %}{{ nav.tr("ecb-the-covered-day") }}{% endif %}
{%- if page.covered_currencies.is_empty() %}{{ nav.tr("ecb-none") }} {%- else %}{{ page.covered_currencies.len() }}{% endif -%}
{% if !page.covered_currencies.is_empty() %}
{% for currency in page.currencies() %}{{ currency }}{% endfor %}
{% endif %} {% if let Some(failure) = page.last_failure() %}

{{ nav.tr_args("ecb-most-recent-failure", [("batch", failure.batch_id.to_string()), ("started", failure.started())]) }} {% if let Some(message) = failure.error_message %}{{ message }}{% else %}{{ nav.tr("ecb-no-reason-recorded") }}{% endif %}

{% endif %}