{% extends "meta.html" %}
{% set sub = user.subscription %}

{% block title %}
<title>Cancel your subscription - {{cfg("sr.ht", "site-name")}} meta</title>
{% endblock %}

{% block content %}
<div class="row">
  <form class="col-md-8 offset-md-2" method="POST">
    {{csrf_token()}}
    <h3>Cancel your subscription</h3>
    {% if user.payment_status == PaymentStatus.DELINQUENT %}
    <p>
      Your account is currently past due. Cancelling your subscription will
      convert your account to a non-paying account and we will stop attempting
      to collect your renewal payment.
    </p>
    {% elif user.payment_status == PaymentStatus.CURRENT %}

    {% if sub.status == SubscriptionStatus.ACTIVE %}
    <p>
      Your subscription is currently paid and up-to-date until the next
      automatic payment scheduled for {{user.payment_due.strftime("%B %d, %Y")}}.
      The next automatic payment will be cancelled and you will retain access
      to paid services until the end of the current payment term.
    </p>
    {% elif sub.status == SubscriptionStatus.SETTLEMENT %}
    <div class="alert alert-warning">
      Your subscription payment was charged {{sub.updated | date}} and is
      awaiting settlement. Cancelling your subscription renewal
      <strong>will not</strong> cancel the pending payment. If you want to
      request a refund for this payment, please
      <a href="mailto:{{cfg('sr.ht', 'owner-email')}}">contact support</a>.
    </div>

    <p>
      Your next automatic payment is scheduled for
      {{user.payment_due.strftime("%B %d, %Y")}}. If you cancel your subscription,
      this payment will be cancelled, and you will retain access to paid
      services until this date.
    </p>
    {% endif %}

    {% if sub.product.retired %}
    <div class="alert alert-danger">
      <strong>Notice</strong>: Your paid subscription is no longer offered to
      new customers at your current price. If you cancel your subscription, you
      will have to pay the new price when you sign up again.
    </div>
    {% endif %}

    {% endif %}
    <button type="submit" class="btn btn-danger">
      Cancel my subscription
      {{icon('caret-right')}}
    </button>
    <a
      href="{{url_for("billing.billing_GET")}}"
      class="btn btn-default"
    >Go back {{icon('caret-right')}}</a>
  </form>
</div>
{% endblock %}
