{% extends 'default.html' %}

{% set active_page = "dashboard" %}

{% block title %}
  Pricing
{% endblock %}

{% block head %}
  <script src="https://cdn.paddle.com/paddle/paddle.js"></script>
  <script>
    if (window.Paddle === undefined) {
      console.log("cannot load Paddle from CDN");
      document.write('<script src="/static/vendor/paddle.js"><\/script>')
    }
  </script>

{% endblock %}

{% block default_content %}
  <div class="row">
    <div class="col-sm-6 col-lg-6">
      <div class="card">
        <div class="card-body text-center">
          <div class="h3">Premium</div>

          <ul class="list-unstyled leading-loose mb-3">
            <li><i class="fe fe-check text-success mr-2" aria-hidden="true"></i> Unlimited Alias</li>
            <li><i class="fe fe-check text-success mr-2" aria-hidden="true"></i>
              Custom Domain
            </li>
            <li><i class="fe fe-check text-success mr-2" aria-hidden="true"></i>
              Catch-all (or wildcard) alias
            </li>
            <li><i class="fe fe-check text-success mr-2" aria-hidden="true"></i>
              Directory (or Username)
            </li>
            <li><i class="fe fe-check text-success mr-2" aria-hidden="true"></i>
              Multiple Mailboxes
            </li>
          </ul>

          <div class="small-text">More info on our <a href="https://simplelogin.io/pricing" target="_blank">Pricing
            Page <i class="fe fe-external-link"></i>
          </a></div>
        </div>
      </div>
    </div>

    <div class="col-sm-6 col-lg-6">
      <div class="display-6 my-3">
        🔐 Secure payments by
        <a href="https://paddle.com" target="_blank">Paddle<i class="fe fe-external-link"></i></a></li>
        </a>
      </div>

      {% if current_user.is_cancel() %}
      <div class="alert alert-primary" role="alert">
        You have an active subscription until {{current_user.next_bill_date()}}. <br>
        Please note that if you re-subscribe now, this will be a completely
        new subscription and
        your payment method will be charged <b>immediately</b>.
      </div>
      {% endif %}

      <div class="mb-3">
        Paddle supported payment methods include bank cards (Mastercard, Visa, American Express, etc) or PayPal. <br>
        Send us an email at <a href="mailto:hi@simplelogin.io">hi@simplelogin.io</a> if you need other payment options
        (e.g. IBAN transfer).
      </div>

      <button class="btn btn-success" onclick="upgrade({{ PADDLE_MONTHLY_PRODUCT_ID }})">
        Monthly <br>
        $2.99/month
      </button>

      <button class="btn btn-primary" onclick="upgrade({{ PADDLE_YEARLY_PRODUCT_ID }})">
        Yearly <br>
        $29.99/year
      </button>

      <hr class="my-6">
      If you have a lifetime licence, please go to this page to apply your licence code.
      <a href="{{ url_for('dashboard.lifetime_licence') }}">Lifetime Licence</a>
    </div>
  </div>


  <script type="text/javascript">
    Paddle.Setup({vendor: {{ PADDLE_VENDOR_ID }}});

    function upgrade(productId) {
      Paddle.Checkout.open({
        product: productId,
        email: "{{ current_user.email }}",
        success: "{{ success_url }}"
      });
    }
  </script>

{% endblock %}