defmodule PlausibleWeb.Components.Billing.PlanBox do @moduledoc false use PlausibleWeb, :component require Plausible.Billing.Subscription.Status alias PlausibleWeb.Components.Billing.{PlanBenefits} alias Plausible.Billing.{Plan, Quota, Subscription} @plan_box_price_container_class "relative h-20 pt-4 max-h-20 whitespace-nowrap overflow-hidden" def standard(assigns) do highlight = cond do assigns.owned && assigns.recommended -> "Current" assigns.recommended -> "Recommended" true -> nil end assigns = assigns |> assign(:highlight, highlight) |> assign(:price_container_class, @plan_box_price_container_class) ~H"""
{@text}
Custom
""" end defp render_price_info(assigns) do ~H""" <.price_tag kind={@kind} selected_interval={@selected_interval} plan_to_render={@plan_to_render} />{@monthly_cost} /month
""" end defp price_tag(%{selected_interval: :yearly} = assigns) do monthly_cost = case assigns.plan_to_render do %{monthly_cost: nil} -> "N/A" %{monthly_cost: monthly_cost} -> Plausible.Billing.format_price(monthly_cost) end {yearly_cost, monthly_cost_with_discount} = case assigns.plan_to_render do %{yearly_cost: nil} -> {"N/A", "N/A"} %{yearly_cost: yearly_cost} -> { Plausible.Billing.format_price(yearly_cost), Plausible.Billing.format_price(Money.div!(yearly_cost, 12)) } end assigns = assigns |> assign(:monthly_cost, monthly_cost) |> assign(:yearly_cost, yearly_cost) |> assign(:monthly_cost_with_discount, monthly_cost_with_discount) ~H"""
{Phoenix.Naming.humanize(limit)}