{% extends "default.html" %}

{% set active_page = "dashboard" %}
{% block title %}Send {{ alias.email }}{% endblock %}
{% block default_content %}

  <div class="card">
    <div class="card-body">
      <h1 class="h3">Transfer {{ alias.email }}</h1>
      <p>
        This page allows you to transfer {{ alias.email }} to another person so they can use it to receive and send
        emails.
      </p>
      {% if alias_transfer_url %}

        <em data-toggle="tooltip"
            title="Click to copy"
            class="clipboard"
            data-clipboard-text="{{ alias_transfer_url }}">{{ alias_transfer_url }}</em>
        <p class="mt-5">
          Please copy the transfer URL. <strong>We won't be able to display it again</strong>. If you need to access it again you can generate a new URL.
        </p>
        <p class="mt-2">
          This transfer URL is <strong>valid for 24 hours</strong>. If it hasn't been used by then it will be automatically disabled.
        </p>
        <form method="post">
          {{ csrf_form.csrf_token }}
          <input type="hidden" name="form-name" value="remove">
          <button class="btn btn-warning mt-2">Remove alias transfer URL</button>
          <div class="small-text">If you don't want to share this alias anymore, you can remove the share URL.</div>
        </form>
      {% else %}
        {% if link_active %}

          <p class="alert alert-info">
            You have an active transfer link. If you don't want to share this alias anymore, please delete the link.
          </p>
          <form method="post">
            {{ csrf_form.csrf_token }}
            <input type="hidden" name="form-name" value="remove">
            <button class="btn btn-warning mt-2">Remove alias transfer URL</button>
          </form>
        {% else %}
          <p>
            In order to transfer ownership,
            please create the <b>Share URL</b> 👇 and send it to the other person.
          </p>
          <form method="post">
            {{ csrf_form.csrf_token }}
            <input type="hidden" name="form-name" value="create">
            <button class="btn btn-primary mt-2">Generate a new alias transfer URL</button>
          </form>
        {% endif %}
      {% endif %}
      <p class="mt-5">This person can then confirm the reception and become the owner of the alias.</p>
      <div class="alert alert-danger">After the confirmation, you can no longer use this alias.</div>
    </div>
  </div>
{% endblock %}
