mirror of
https://github.com/bitbaum/evig.git
synced 2026-12-06 01:47:28 +01:00
fix(it-hilfe): show sign-in CTA when anonymous submitter has existing account
Silent UX gap in the just-shipped anonymous-post flow. Three submitter
states needed three success branches but only two existed:
newAccount=true → "check your email" claim screen ✓
status=unauth, newAccount=false → (missing) silently redirected to
the request page, where the still-
logged-out browser tab couldn't
accept offers or take owner
actions, with no hint that the
user has an account or what to do
status=auth (logged-in submitter) → normal redirect to request ✓
Real submitter behaviour: someone uses anonymous-post with an email
that already has an account (forgot they had one, switched browsers,
old subscription, etc.). Backend correctly attaches the request to
that account (62ba111c suppresses the duplicate email for them). But
the frontend was treating them like a logged-in user on the success
path — redirect to /it-hilfe/<requestId>, no sign-in prompt.
Fix:
1. useCreateITHilfeForm now tracks `existingAccountAttached` alongside
`anonymousAccountCreated`. Flips when result.data.newAccount is
false AND `status === 'unauthenticated'`. Also tracks
`submittedRequestId` so the page can build a callbackUrl.
2. /it-hilfe/create gains a third success branch: "We attached your
request to your existing account under <email>. Sign in to see
and manage offers." Primary CTA is a sign-in button with
`?callbackUrl=/it-hilfe/<requestId>` so the user lands on their
own request after authenticating — same one-tap-to-request seam
we closed for the new-account path via the claim email's
callbackUrl (aedf208b).
End state: every combination of (auth, account-existed-or-not) leaves
the user with a clear next action and a working link to their request.
tsc + lint clean on touched files. 458 IT-Hilfe tests across 33 suites
pass (no new tests for this — the change is purely UI-state branching,
hook has no test suite, and the route response shape is unchanged so
existing route tests still cover the API contract).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
40cce8e2ca
commit
c8eebb2de4
2 files changed
+46
-3
No files matched your search
@@ -47,6 +47,8 @@ export default function CreatePeerRepairPage() {
|
||||
error,
|
||||
success,
|
||||
anonymousAccountCreated,
|
||||
existingAccountAttached,
|
||||
submittedRequestId,
|
||||
formData,
|
||||
aiFieldMeta,
|
||||
updateField,
|
||||
@@ -88,6 +90,31 @@ export default function CreatePeerRepairPage() {
|
||||
)
|
||||
}
|
||||
|
||||
if (success && existingAccountAttached) {
|
||||
const loginHref = submittedRequestId
|
||||
? `/auth/login?callbackUrl=${encodeURIComponent(`/it-hilfe/${submittedRequestId}`)}`
|
||||
: '/auth/login'
|
||||
return (
|
||||
<PageShell maxWidth="2xl" py="py-24" className="text-center">
|
||||
<CheckCircle className="w-16 h-16 text-primary-500 mx-auto mb-4" />
|
||||
<Heading level={2} className="text-2xl text-neutral-900 dark:text-white mb-2">
|
||||
Anfrage gespeichert!
|
||||
</Heading>
|
||||
<p className="text-neutral-600 dark:text-neutral-400 mb-6 max-w-prose mx-auto">
|
||||
Wir haben deine Anfrage an dein bestehendes Konto unter{' '}
|
||||
<strong>{formData.submitterEmail}</strong> angehängt.
|
||||
Melde dich an, um Angebote zu sehen und deine Anfrage zu verwalten.
|
||||
</p>
|
||||
<Button as={Link} href={loginHref} variant="primary">
|
||||
Anmelden
|
||||
</Button>
|
||||
<p className="text-xs text-neutral-500 dark:text-neutral-500 mt-6">
|
||||
Passwort vergessen? Du kannst es auf der Anmeldeseite zurücksetzen.
|
||||
</p>
|
||||
</PageShell>
|
||||
)
|
||||
}
|
||||
|
||||
if (success) {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-24">
|
||||
|
||||
@@ -35,6 +35,13 @@ export function useCreateITHilfeForm(errorCreateFailed: string, errorGeneric: st
|
||||
// check their email instead of redirecting (they can't view the request
|
||||
// until they set a password via the claim link).
|
||||
const [anonymousAccountCreated, setAnonymousAccountCreated] = useState(false)
|
||||
// `existingAccountAttached` flips when a logged-out submitter's email
|
||||
// matched an existing account. The request was attached silently; we
|
||||
// can't auto-redirect to the request page because the browser tab is
|
||||
// still logged-out, so owner actions wouldn't work — show a "sign in
|
||||
// to manage" CTA instead.
|
||||
const [existingAccountAttached, setExistingAccountAttached] = useState(false)
|
||||
const [submittedRequestId, setSubmittedRequestId] = useState<string | null>(null)
|
||||
const [formData, setFormData] = useState<ITHilfeCreateFormData>(INITIAL_IT_HILFE_FORM)
|
||||
const [aiFieldMeta, setAiFieldMeta] = useState<Record<string, AIFieldMetadataEntry>>({})
|
||||
|
||||
@@ -151,11 +158,18 @@ export function useCreateITHilfeForm(errorCreateFailed: string, errorGeneric: st
|
||||
}
|
||||
|
||||
setSuccess(true)
|
||||
// newAccount → backend just provisioned an account; user must claim
|
||||
// via email link before they can view the request. Skip the redirect
|
||||
// and let the page render the check-your-email state.
|
||||
setSubmittedRequestId(result.data.requestId)
|
||||
// Three branches based on auth state + whether the backend created
|
||||
// a new account:
|
||||
//
|
||||
// newAccount=true → "check your email" claim flow
|
||||
// status=unauth, newAccount=false → "we attached this to your
|
||||
// existing account, sign in"
|
||||
// status=authenticated (or default) → normal redirect to request
|
||||
if (result.data.newAccount) {
|
||||
setAnonymousAccountCreated(true)
|
||||
} else if (status === 'unauthenticated') {
|
||||
setExistingAccountAttached(true)
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
router.push(`/it-hilfe/${result.data!.requestId}`)
|
||||
@@ -176,6 +190,8 @@ export function useCreateITHilfeForm(errorCreateFailed: string, errorGeneric: st
|
||||
error,
|
||||
success,
|
||||
anonymousAccountCreated,
|
||||
existingAccountAttached,
|
||||
submittedRequestId,
|
||||
formData,
|
||||
aiFieldMeta,
|
||||
updateField,
|
||||
|
||||
Reference in new issue
Block a user