%= if !Keyword.fetch!(Application.get_env(:plausible, :selfhost), :disable_subscription) do %>
Subscription Plan
<%= if @subscription do %>
<%= present_subscription_status(@subscription.status) %>
<% end %>
<%= if @subscription && @subscription.status == "deleted" do %>
<%= if @subscription.next_bill_date && Timex.compare(@subscription.next_bill_date, Timex.today()) >= 0 do %>
Your subscription is cancelled but you have access to your stats until <%= Timex.format!(@subscription.next_bill_date, "{Mshort} {D}, {YYYY}") %>. Upgrade below to make sure you don't lose access.
<% else %>
Your subscription is cancelled. Upgrade below to get access to your stats again.
<% end %>
<% end %>
Monthly quota
<%= if @subscription do %>
<%= subscription_quota(@subscription) %> pageviews
<%= case @subscription.status do %>
<% "active" -> %>
<%= link("Change plan", to: "/billing/change-plan", class: "text-sm text-indigo-500 font-medium") %>
<% "past_due" -> %>
Change plan
<% _ -> %>
<% end %>
<% else %>
Free trial
<%= link("Upgrade", to: "/billing/upgrade", class: "text-sm text-indigo-500 font-medium") %>
<% end %>
Next bill amount
<%= if @subscription && @subscription.status in ["active", "past_due"] do %>
$<%= @subscription.next_bill_amount %>
<%= if @subscription.update_url do %>
<%= link("Update billing info", to: @subscription.update_url, class: "text-sm text-indigo-500 font-medium") %>
<% end %>
<% else %>
---
<% end %>
Next bill date
<%= if @subscription && @subscription.next_bill_date && @subscription.status in ["active", "past_due"] do %>
<%= Timex.format!(@subscription.next_bill_date, "{Mshort} {D}, {YYYY}") %>
(<%= subscription_interval(@subscription) %> billing)
<% else %>
---
<% end %>
Your usage
<%= delimit_integer(Plausible.Billing.usage(@conn.assigns[:current_user])) %>
pageviews in the last 30 days
<%= cond do %>
<% @subscription && @subscription.status in ["active", "past_due", "paused"] && @subscription.cancel_url -> %>
<%= link("Cancel my subscription", to: @subscription.cancel_url, class: "inline-block mt-4 px-4 py-2 border border-gray-300 text-sm leading-5 font-medium rounded-md text-red-700 bg-white hover:text-red-500 focus:outline-none focus:border-blue-300 focus:ring active:text-red-800 active:bg-gray-50 transition ease-in-out duration-150") %>
<% true -> %>
<%= link("Upgrade", to: "/billing/upgrade", class: "inline-block px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-500 focus:outline-none focus:border-indigo-700 focus:ring active:bg-indigo-700 transition ease-in-out duration-150") %>
<% end %>
<% end %>
Account settings
<%= form_for @changeset, "/settings", [class: "max-w-sm"], fn f -> %>
<%= label f, :name, class: "block text-gray-700 text-sm font-bold mb-2" %>
<%= text_input f, :name, class: "transition bg-gray-100 appearance-none border border-transparent rounded w-full p-2 text-gray-700 leading-normal appearance-none focus:outline-none focus:border-gray-300" %>
<%= error_tag f, :name %>
<%= label f, :email, class: "block text-gray-700 text-sm font-bold mb-2" %>
<%= email_input f, :email, class: "transition bg-gray-100 appearance-none border border-transparent rounded w-full p-2 text-gray-700 leading-normal appearance-none focus:outline-none focus:border-gray-300" %>
<%= error_tag f, :email %>
<%= submit "Save changes", class: "button mt-4" %>
<% end %>
Delete account
Deleting your account removes all sites and stats you've collected
<%= if @subscription && @subscription.status == "active" do %>
Delete my account
Your account cannot be deleted because you have an active subscription. If you want to delete your account, please cancel your subscription first.
<% else %>
<%= link("Delete my account", to: "/me", class: "inline-block mt-4 px-4 py-2 border border-gray-300 text-sm leading-5 font-medium rounded-md text-red-700 bg-white hover:text-red-500 focus:outline-none focus:border-blue-300 focus:ring active:text-red-800 active:bg-gray-50 transition ease-in-out duration-150", method: "delete", data: [confirm: "Deleting your account cannot be reversed. Are you sure?"]) %>
<% end %>