improve setup UX: password field, setup hook, checklist banners, theme tweaks
All checks were successful
deploy / deploy (push) Successful in 1m31s

- add password field and required shop name to setup wizard
- extract SetupHook for DRY redirect to /setup when no admin exists
- add ?from=checklist param to checklist hrefs with contextual banner on
  email settings and theme pages for easy return to dashboard
- remove email warning banner from admin layout (checklist covers it)
- make email a required checklist item (no longer optional)
- add DevReset module for wiping dev data without restart
- rename "Theme Studio" to "Theme", drop subtitle
- lower theme editor side-by-side breakpoint from 64em to 48em
- clean up login/registration pages (remove dead registration_open code)
- fix settings.put_secret to invalidate cache after write

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-03-03 17:41:08 +00:00
parent 0853b6f528
commit 64f083d271
23 changed files with 309 additions and 118 deletions

View File

@@ -54,7 +54,10 @@ defmodule BerrypodWeb.Setup.Onboarding do
|> assign(:secret_verified, false)
|> assign(:secret_form, to_form(%{"secret" => ""}, as: :secret))
# Account (card 1)
|> assign(:account_form, to_form(%{"email" => "", "shop_name" => ""}, as: :account))
|> assign(
:account_form,
to_form(%{"email" => "", "password" => "", "shop_name" => ""}, as: :account)
)
# Provider (card 2)
|> assign(:providers, Provider.all())
|> assign(:selected_provider, nil)
@@ -81,32 +84,38 @@ defmodule BerrypodWeb.Setup.Onboarding do
def handle_event("create_account", %{"account" => params}, socket) do
email = params["email"]
password = params["password"]
shop_name = String.trim(params["shop_name"] || "")
if email == "" do
{:noreply, put_flash(socket, :error, "Please enter your email address")}
else
if shop_name != "" do
cond do
shop_name == "" ->
{:noreply, put_flash(socket, :error, "Please enter a shop name")}
email == "" ->
{:noreply, put_flash(socket, :error, "Please enter your email address")}
true ->
Settings.put_setting("site_name", shop_name, "string")
end
case Accounts.register_and_confirm_admin(%{email: email}) do
{:ok, user} ->
token = Accounts.generate_login_token(user)
{:noreply, redirect(socket, to: ~p"/setup/login/#{token}")}
case Accounts.register_and_confirm_admin(%{email: email, password: password}) do
{:ok, user} ->
token = Accounts.generate_login_token(user)
{:noreply, redirect(socket, to: ~p"/setup/login/#{token}")}
{:error, :admin_already_exists} ->
{:noreply,
socket
|> put_flash(:error, "An admin account already exists")
|> push_navigate(to: ~p"/setup")}
{:error, :admin_already_exists} ->
{:noreply,
socket
|> put_flash(:error, "An admin account already exists")
|> push_navigate(to: ~p"/setup")}
{:error, changeset} ->
{:noreply,
socket
|> assign(:account_form, to_form(changeset, as: :account))
|> put_flash(:error, "Could not create account")}
end
{:error, changeset} ->
form = to_form(params, as: :account, errors: changeset.errors, action: :validate)
{:noreply,
socket
|> assign(:account_form, form)
|> put_flash(:error, "Could not create account")}
end
end
end
@@ -255,6 +264,7 @@ defmodule BerrypodWeb.Setup.Onboarding do
label="Shop name"
placeholder="e.g. Acme Prints"
autocomplete="off"
required
phx-mounted={@current_step == 1 && JS.focus()}
/>
<.input
@@ -264,6 +274,14 @@ defmodule BerrypodWeb.Setup.Onboarding do
autocomplete="email"
required
/>
<.input
field={@account_form[:password]}
type="password"
label="Password"
placeholder="12 characters minimum"
autocomplete="new-password"
required
/>
<div class="setup-actions">
<.button phx-disable-with="Creating account...">Create account</.button>
</div>