From 77aa579ee4612162c0c7a72e0be8ac595d51a5bc Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sun, 12 Jul 2026 14:03:15 +0000 Subject: [PATCH] Changes Co-authored-by: wolfoftyreso-debug <250630591+wolfoftyreso-debug@users.noreply.github.com> --- src/components/PlansSection.tsx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/components/PlansSection.tsx b/src/components/PlansSection.tsx index fe64b66..6081a2b 100644 --- a/src/components/PlansSection.tsx +++ b/src/components/PlansSection.tsx @@ -206,6 +206,33 @@ const PlansSection = () => { setSubmitting(true); try { + // Auto-create account for guests, then sign in + if (!user && form.password) { + const { data: accData, error: accErr } = await supabase.functions.invoke("create-account", { + body: { + email: result.data.epost, + password: form.password, + company: result.data.företag, + phone: result.data.telefon ?? "", + }, + }); + if (accErr) throw accErr; + if ((accData as any)?.error) throw new Error((accData as any).error); + + const { error: signInErr } = await supabase.auth.signInWithPassword({ + email: result.data.epost, + password: form.password, + }); + if (signInErr) { + if ((accData as any)?.existed) { + throw new Error( + "Ett konto finns redan för denna e-post. Fel lösenord — logga in eller använd 'Glömt lösenord'.", + ); + } + throw signInErr; + } + } + const body = { method, employees,