diff --git a/apps/bright/lib/bright/patreon_entitlements.ex b/apps/bright/lib/bright/patrons/patreon_entitlements.ex
similarity index 83%
rename from apps/bright/lib/bright/patreon_entitlements.ex
rename to apps/bright/lib/bright/patrons/patreon_entitlements.ex
index d273cec..ff532b8 100644
--- a/apps/bright/lib/bright/patreon_entitlements.ex
+++ b/apps/bright/lib/bright/patrons/patreon_entitlements.ex
@@ -1,4 +1,4 @@
-defmodule Bright.PatreonEntitlements do
+defmodule Bright.Patrons.PatreonEntitlements do
@spec extract_tiers(map()) :: list(String.t())
def extract_tiers(response_body) do
response_body
diff --git a/apps/bright/lib/bright/tier_mapper.ex b/apps/bright/lib/bright/patrons/tier_mapper.ex
similarity index 73%
rename from apps/bright/lib/bright/tier_mapper.ex
rename to apps/bright/lib/bright/patrons/tier_mapper.ex
index bb9d58c..39d672d 100644
--- a/apps/bright/lib/bright/tier_mapper.ex
+++ b/apps/bright/lib/bright/patrons/tier_mapper.ex
@@ -1,4 +1,4 @@
-defmodule Bright.TierMapper do
+defmodule Bright.Patrons.TierMapper do
@patreon_tiers %{
"everyone" => 0,
"free" => 0,
@@ -34,10 +34,16 @@ defmodule Bright.TierMapper do
def get_tier_number(_, _), do: 0
+ def largest_tier_for_platform(_platform, []), do: 0
+ @spec largest_tier_for_platform(any(), nil | maybe_improper_list()) :: any()
def largest_tier_for_platform(platform, tier_ids)
- when is_list(tier_ids) and is_binary(platform) do
+ when is_binary(platform) and is_list(tier_ids) do
tier_ids
|> Enum.map(&get_tier_number(platform, &1))
|> Enum.max()
end
+
+ @spec largest_tier_for_platform(any(), list()) :: integer()
+ def largest_tier_for_platform(_, _), do: 0
+ def largest_tier_for_platform(_), do: 0
end
diff --git a/apps/bright/lib/bright/users/user.ex b/apps/bright/lib/bright/users/user.ex
index e833806..343068b 100644
--- a/apps/bright/lib/bright/users/user.ex
+++ b/apps/bright/lib/bright/users/user.ex
@@ -35,7 +35,7 @@ defmodule Bright.Users.User do
"""
def registration_changeset(user, attrs, _opts \\ []) do
user
- |> cast(attrs, [:patreon_id, :github_id, :role])
+ |> cast(attrs, [:patreon_id, :github_id, :role, :patron_tier])
|> validate_provider_id()
end
diff --git a/apps/bright/lib/bright_web/components/core_components.ex b/apps/bright/lib/bright_web/components/core_components.ex
index 5fd536e..f8377e9 100644
--- a/apps/bright/lib/bright_web/components/core_components.ex
+++ b/apps/bright/lib/bright_web/components/core_components.ex
@@ -19,6 +19,27 @@ defmodule BrightWeb.CoreComponents do
alias Phoenix.LiveView.JS
+ @doc """
+ Renders an external link.
+
+ ## Example:
+ ```heex
+ <.external_link href="https://example.com">Visit Example
+ ```
+ """
+ attr :rest, :global, doc: "the arbitrary HTML attributes to add to the flash container"
+ attr :href, :string, required: true
+ slot :inner_block, required: true
+
+ def(external_link(assigns)) do
+ ~H"""
+ <.link href={@href} target="_blank" rel="noopener noreferrer" {@rest}>
+ {render_slot(@inner_block)}
+ <.icon name="arrow-up-right-from-square" class="ml-0" />
+
+ """
+ end
+
@doc """
Renders a modal.
diff --git a/apps/bright/lib/bright_web/components/layouts/app.html.heex b/apps/bright/lib/bright_web/components/layouts/app.html.heex
index 7a4ed6b..6a5f494 100644
--- a/apps/bright/lib/bright_web/components/layouts/app.html.heex
+++ b/apps/bright/lib/bright_web/components/layouts/app.html.heex
@@ -1,4 +1,81 @@
-