Detect checkout email collisions and show login state in the navbar

Registering with an email that already has an account previously just
failed with a generic error and no clear next step. registerCustomer()
now flags emailExists specifically, and checkout switches straight to the
login toggle (email pre-filled, scrolled into view) instead. The account
icon also gets a small underline while logged in, matching the nav links'
active-state styling — it was otherwise the only nav element that gave no
visual signal of session state.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Marco
2026-07-22 08:26:00 +00:00
parent f0df359db4
commit ec75a480bd
4 changed files with 58 additions and 6 deletions
+15 -1
View File
@@ -287,7 +287,21 @@ without leaving the page.
server-rendered root layout) specifically so `app/layout.tsx` — otherwise
static/ISR-cacheable — doesn't get forced into per-request dynamic
rendering just to know one icon's href; briefly shows the logged-out
state on first paint until that fetch resolves.
state on first paint until that fetch resolves. The icon itself also
gets a small brand-colored underline while logged in — same visual
language as the desktop nav links' active-state indicator — since the
icon alone doesn't otherwise signal session state at a glance.
- **Checkout registration collisions**: if the email typed into Card 1
during inline registration already belongs to an existing account,
Payload's create call fails — `registerCustomer()` in `customerAuth.ts`
detects this specifically (`emailExists: true` on the returned
`AuthResult`, inferred from the field flagged in Payload's validation
error, since Payload's own message text doesn't distinguish "duplicate"
from other email-field failures) rather than just surfacing a generic
error. `CheckoutContent.tsx`'s `handleSubmit` reacts by switching
straight to the login toggle with that email pre-filled and
scroll-into-view, instead of leaving the customer stuck with an error
and no obvious next step.
- **`/konto/profil`** edits name + the one saved default address (deliberately
a single address, not a full address book — see the assistant's memory
note on optionally expanding this later), changes the password, shows