extract site_name and site_description from theme settings into standalone settings

site_name and site_description are shop identity, not theme concerns.
They now live in the Settings table as first-class settings with their
own assigns (@site_name, @site_description) piped through hooks and
plugs. The setup wizard writes site_name on account creation, and the
theme editor reads/writes via Settings.put_setting. Removed the
"configure your shop" checklist item since currency/country aren't
built yet. Also adds shop name field to setup wizard step 1.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-03-03 14:52:31 +00:00
parent 8ea77e5992
commit 5b41f3fedf
25 changed files with 464 additions and 255 deletions

View File

@@ -27,7 +27,7 @@ defmodule Berrypod.Release do
case Settings.get_setting("theme_settings") do
nil ->
{:ok, _} = Settings.apply_preset(:studio)
{:ok, _} = Settings.apply_preset(:studio, skip_customised_flag: true)
:ok
_exists ->

View File

@@ -74,7 +74,6 @@ defmodule Berrypod.Settings do
def get_theme_settings do
case get_setting("theme_settings") do
nil ->
# Return defaults
%ThemeSettings{}
settings_map when is_map(settings_map) ->
@@ -84,6 +83,16 @@ defmodule Berrypod.Settings do
end
end
@doc "Returns the shop name from Settings, falling back to a default."
def site_name do
get_setting("site_name") || "Store Name"
end
@doc "Returns the shop description from Settings, falling back to a default."
def site_description do
get_setting("site_description") || "Discover unique products and original designs."
end
@doc """
Updates the theme settings.
@@ -93,7 +102,7 @@ defmodule Berrypod.Settings do
{:ok, %ThemeSettings{}}
"""
def update_theme_settings(attrs) when is_map(attrs) do
def update_theme_settings(attrs, opts \\ []) when is_map(attrs) do
current = get_theme_settings()
changeset = ThemeSettings.changeset(current, attrs)
@@ -102,7 +111,10 @@ defmodule Berrypod.Settings do
settings = Ecto.Changeset.apply_changes(changeset)
json = Jason.encode!(settings)
put_setting("theme_settings", json, "json")
put_setting("theme_customised", true, "boolean")
unless opts[:skip_customised_flag] do
put_setting("theme_customised", true, "boolean")
end
# Invalidate and rewarm CSS cache
alias Berrypod.Theme.{CSSCache, CSSGenerator}
@@ -125,11 +137,11 @@ defmodule Berrypod.Settings do
{:ok, %ThemeSettings{}}
"""
def apply_preset(preset_name) when is_atom(preset_name) do
def apply_preset(preset_name, opts \\ []) when is_atom(preset_name) do
preset = Berrypod.Theme.Presets.get(preset_name)
if preset do
update_theme_settings(preset)
update_theme_settings(preset, opts)
else
{:error, :preset_not_found}
end

View File

@@ -15,8 +15,6 @@ defmodule Berrypod.Settings.ThemeSettings do
field :accent_color, :string, default: "#f97316"
# Branding
field :site_name, :string, default: "Store Name"
field :site_description, :string, default: "Discover unique products and original designs."
field :logo_mode, :string, default: "text-only"
field :logo_image_id, :binary_id
field :logo_size, :integer, default: 36
@@ -68,8 +66,6 @@ defmodule Berrypod.Settings.ThemeSettings do
:grid_columns,
:header_layout,
:accent_color,
:site_name,
:site_description,
:logo_mode,
:logo_image_id,
:logo_size,

View File

@@ -3,7 +3,7 @@ defmodule Berrypod.Setup do
Aggregates setup status checks for the setup flow and launch checklist.
"""
alias Berrypod.{Accounts, Orders, Products, Settings}
alias Berrypod.{Accounts, Mailer, Orders, Products, Settings, Shipping}
@setup_secret_key :berrypod_setup_secret
@@ -62,10 +62,12 @@ defmodule Berrypod.Setup do
## Launch checklist phase
* `products_synced` / `product_count` — products imported
* `has_shipping` — at least one shipping rate exists
* `theme_customised` — theme settings have been saved at least once
* `has_orders` — at least one paid order exists
* `email_configured` — email adapter configured and verified
* `site_live` — shop is open to the public
* `can_go_live` — minimum requirements met to go live
* `can_go_live` — minimum requirements met to go live (includes shipping)
* `checklist_dismissed` — admin has dismissed the launch checklist
"""
def setup_status do
@@ -77,6 +79,7 @@ defmodule Berrypod.Setup do
stripe_connected = Settings.has_secret?("stripe_api_key")
admin_created = Accounts.has_admin?()
site_live = Settings.site_live?()
has_shipping = Shipping.has_shipping_rates?()
%{
# Setup phase
@@ -89,10 +92,12 @@ defmodule Berrypod.Setup do
# Launch checklist
products_synced: products_synced,
product_count: product_count,
has_shipping: has_shipping,
theme_customised: Settings.get_setting("theme_customised", false) == true,
has_orders: Orders.has_paid_orders?(),
email_configured: Mailer.email_configured?(),
site_live: site_live,
can_go_live: provider_connected and products_synced and stripe_connected,
can_go_live: provider_connected and products_synced and stripe_connected and has_shipping,
checklist_dismissed: Settings.get_setting("checklist_dismissed", false) == true
}
end

View File

@@ -310,6 +310,15 @@ defmodule Berrypod.Shipping do
# Queries
# =============================================================================
@doc """
Returns true if at least one shipping rate exists.
"""
def has_shipping_rates? do
ShippingRate
|> limit(1)
|> Repo.exists?()
end
@doc """
Returns a list of distinct country codes that have shipping rates.