{% extends "admin_app.html" %}
{% from "library.j2" import showuri, form_button, standard_button, extract_circle_name, invite_type_description %}
{% block head_lead %}
{{ super() }}
{% include "copy-snippet.html" %}
{% endblock %}
{% block content %}
<h1>{% trans %}View invitation{% endtrans %}</h1>
<form method="POST">
{{ form.csrf_token }}
<div class="form layout-expanded">
	<dl>
		<dt>{% trans %}Valid until{% endtrans %}</dt>
		<dd>{{ invite.expires | format_date }}</dd>
		<dt><label for="link-field">{% trans %}Link{% endtrans %}</label></dt>
		<dd>{% call showuri(invite.landing_page, id_="link-field") %}{% endcall %}</dd>
		<dt>{% trans %}Invitation type{% endtrans %}</dt>
		<dd>{% call invite_type_description(invite) %}{% endcall %}</dd>
		{%- set ngroups = invite.group_ids | length -%}
		{%- if ngroups > 1 -%}
		{#- not supported via the web UI, but we should still display it properly -#}
		<dt>{% trans %}Circles{% endtrans %}</dt>
		<dd><p>{% trans %}Users joining via this invitation will be added to the following circles:{% endtrans %}</p><ul>
			{%- for group_id in invite.group_ids -%}
				<li>{%- call extract_circle_name(circle_map, group_id) -%}{%- endcall -%}</li>
			{%- endfor -%}
		</ul></dd>
		{%- else -%}
		<dt>{% trans %}Circle{% endtrans %}</dt>
		<dd>
			{%- if ngroups == 1 -%}
			{%- set group_id = invite.group_ids[0] -%}
			{%- call extract_circle_name(circle_map, group_id) -%}{%- endcall -%}
			{%- else -%}
			<em>{% trans %}The user will not be added to any circle and will have no contacts.{% endtrans %}</em>
			{%- endif -%}
		</dd>
		{%- endif -%}
		{%- if invite.type_.value == "roster" -%}
		<dt>{% trans %}Contact{% endtrans %}</dt>
		<dd>{% trans peer_jid=invite.jid %}The user will get added as contact of {{ peer_jid }}.{% endtrans %}</dd>
		{%- endif -%}
		<dt>{% trans %}Created{% endtrans %}</dt>
		<dd>{{ invite.created_at | format_date }}</dd>
	</dl>
	<div class="f-bbox">
		{%- call standard_button("back", url_for(".invitations"), class="tertiary") %}
			{% trans %}Return to invitation list{% endtrans %}
		{%- endcall %}
		{%- call form_button("remove_link", form.action_revoke, class="primary danger") %}{% endcall -%}
	</div>
</div>
</form>
{% endblock %}
