531 lines
26 KiB
TypeScript
531 lines
26 KiB
TypeScript
import { useEffect, useMemo, useRef, useState } from "react";
|
|
import { Form, Link, useNavigate, useNavigation, useSearchParams } from "react-router";
|
|
import { useTranslation } from "react-i18next";
|
|
import { FeatherArrowLeft, FeatherBuilding, FeatherMailCheck, FeatherPencil, FeatherRotateCw } from "@subframe/core";
|
|
import { useRootData } from "~/utils/data/useRootData";
|
|
import { AuthShell } from "~/components/auth/AuthShell";
|
|
import { Alert } from "~/ui/components/Alert";
|
|
import { Button } from "~/ui/components/Button";
|
|
import { Card } from "~/ui/components/Card";
|
|
import { IconWithBackground } from "~/ui/components/IconWithBackground";
|
|
import { LinkButton } from "~/ui/components/LinkButton";
|
|
import { Logo } from "~/ui/components/Logo";
|
|
import { Progress } from "~/ui/components/Progress";
|
|
import { StepperHorizontal } from "~/ui/components/StepperHorizontal";
|
|
import { TextInput } from "~/ui/components/TextInput";
|
|
import { getPasswordChecks, type PasswordPolicy } from "~/modules/users/components/RegisterForm";
|
|
import { RegistrationPlanStep } from "~/modules/users/components/RegistrationPlanStep";
|
|
|
|
// Signup-Screens nach Davids Subframe-"WF-P2"-Designs:
|
|
// S01 "Signup" -> Form (Logo + Card "Konto erstellen": E-Mail, Passwort+Staerke, Vor-/Nachname,
|
|
// Firmenname, Sicherheitspruefung/Captcha, 2 Consents, "Konto erstellen").
|
|
// S03 "E-Mail bestaetigen" -> verificationEmailSent-Status (Logo + Card: Mail-Check-Icon, Titel, gesendete
|
|
// Adresse, Hinweis-Alert, "E-Mail erneut senden" / "E-Mail aendern" / "Zur Anmeldung").
|
|
// Voll an die bestehende Register-Action verdrahtet (Feld-Namen, Password-Policy, Captcha, Lead-Felder).
|
|
//
|
|
// Token-genaue Uebernahme + bewusste Abweichungen (vom Backend erzwungen, nicht erfunden):
|
|
// - Davids S01 zeigt das Passwort IMMER. Bei aktiver E-Mail-Verifizierung sammelt das Backend das Passwort
|
|
// aber erst beim Verify (Registration-Modell hat KEINE Passwort-Spalte) -> showPasswordInput bleibt
|
|
// `!requireEmailVerification` (launch-sicherer Default ist ON -> Passwort genau einmal im Verify-Schritt).
|
|
// Eine explizit deaktivierte Verifizierung zeigt das Passwort weiterhin direkt in S01. [Backend-Flag]
|
|
// - Davids S01 hat KEIN Telefon-/USt-IdNr-Feld -> entfernt (wurden ohnehin nie persistiert).
|
|
// - Davids S01 hat 2 Consents (AGB, Datenschutz); der separate AVV/DPA-Consent wurde gestrichen. [Flag]
|
|
// - Davids PasswordStrengthIndicator existiert nicht in ~/ui -> bestehender Progress-Balken beibehalten.
|
|
// - Davids statische Captcha-Box ("Ich bin kein Roboter") -> echtes mCaptcha-Widget in Davids Box-Optik,
|
|
// nur sichtbar wenn Captcha aktiv ist.
|
|
// - S03 resend posts `intent=resendVerification`. The server verifies the persisted HMAC-bound pending
|
|
// capability, rotates its token and TTL atomically, and returns the new request key for the next click.
|
|
|
|
type RegisterData = { company?: string; firstName?: string; lastName?: string; email?: string; slug?: string };
|
|
|
|
export type RegistrationPlanOptionData = {
|
|
readonly planId: string;
|
|
readonly planCode: string;
|
|
readonly titleKey: string;
|
|
readonly descriptionKey: string;
|
|
readonly priceId: string;
|
|
readonly amountCents: number;
|
|
readonly baseAmountCents: number;
|
|
readonly currency: string;
|
|
readonly billingPeriod: number;
|
|
readonly includedOfficeSeatQuantity: number;
|
|
readonly includedFieldSeatQuantity: number;
|
|
readonly includedStorageGb: number;
|
|
readonly storagePerAdditionalSeatGb: number;
|
|
readonly extraOfficeSeatQuantity: number;
|
|
readonly extraFieldSeatQuantity: number;
|
|
readonly recommended: boolean;
|
|
};
|
|
|
|
type RegistrationPlanAdviceData = {
|
|
readonly plans: readonly RegistrationPlanOptionData[];
|
|
readonly selectedPriceId: string;
|
|
readonly recommendedPriceId: string;
|
|
readonly officeSeatQuantity: number;
|
|
readonly fieldSeatQuantity: number;
|
|
};
|
|
|
|
export default function RegisterScreen({
|
|
requireCaptcha = false,
|
|
error,
|
|
captchaResetKey,
|
|
verificationEmailSent,
|
|
data = {},
|
|
leadConversion,
|
|
passwordPolicy,
|
|
creationRequestKey,
|
|
subscriptionPlans,
|
|
selectedSubscriptionPriceId,
|
|
recommendedSubscriptionPriceId,
|
|
initialOfficeSeatQuantity,
|
|
initialFieldSeatQuantity,
|
|
}: {
|
|
requireCaptcha?: boolean;
|
|
error?: string;
|
|
/** Changes after every failed initial submit so single-use CAPTCHA proofs cannot poison retries. */
|
|
captchaResetKey?: string;
|
|
verificationEmailSent?: boolean;
|
|
data?: RegisterData;
|
|
leadConversion?: { leadId: string; token: string; planId?: string | null };
|
|
passwordPolicy?: PasswordPolicy;
|
|
creationRequestKey: string;
|
|
subscriptionPlans: readonly RegistrationPlanOptionData[];
|
|
selectedSubscriptionPriceId: string;
|
|
recommendedSubscriptionPriceId: string;
|
|
initialOfficeSeatQuantity: number;
|
|
initialFieldSeatQuantity: number;
|
|
}) {
|
|
const { t } = useTranslation();
|
|
const { appConfiguration, csrf } = useRootData();
|
|
const navigation = useNavigation();
|
|
const navigate = useNavigate();
|
|
const [searchParams] = useSearchParams();
|
|
const isSubmitting = navigation.state !== "idle";
|
|
const redirect = searchParams.get("redirect") ?? "";
|
|
const formRef = useRef<HTMLFormElement>(null);
|
|
const passwordInputRef = useRef<HTMLInputElement>(null);
|
|
|
|
// Controlled, damit Werte ueber den Wechsel Form <-> "E-Mail bestaetigt"-Status erhalten bleiben
|
|
// (E-Mail-Anzeige in S03, Resend ohne erneutes Tippen).
|
|
const [email, setEmail] = useState(data.email ?? "");
|
|
const [password, setPassword] = useState("");
|
|
const [company, setCompany] = useState(data.company ?? "");
|
|
const [firstName, setFirstName] = useState(data.firstName ?? "");
|
|
const [lastName, setLastName] = useState(data.lastName ?? "");
|
|
const [selectedPriceId, setSelectedPriceId] = useState(selectedSubscriptionPriceId);
|
|
const [step, setStep] = useState<"account" | "team" | "plan">("account");
|
|
const [officeSeatQuantity, setOfficeSeatQuantity] = useState(initialOfficeSeatQuantity);
|
|
const [fieldSeatQuantity, setFieldSeatQuantity] = useState(initialFieldSeatQuantity);
|
|
const [planOptions, setPlanOptions] = useState(subscriptionPlans);
|
|
const [recommendedPriceId, setRecommendedPriceId] = useState(recommendedSubscriptionPriceId);
|
|
const [planManuallyOverridden, setPlanManuallyOverridden] = useState(selectedSubscriptionPriceId !== recommendedSubscriptionPriceId);
|
|
const [planAdviceLoading, setPlanAdviceLoading] = useState(false);
|
|
const [planAdviceFailed, setPlanAdviceFailed] = useState(false);
|
|
const [planAdviceRetryKey, setPlanAdviceRetryKey] = useState(0);
|
|
const [acceptTerms, setAcceptTerms] = useState(false);
|
|
const [acceptPrivacy, setAcceptPrivacy] = useState(false);
|
|
const [captchaStatus, setCaptchaStatus] = useState<"pending" | "solved" | "error">("pending");
|
|
const [passwordValidationRequested, setPasswordValidationRequested] = useState(false);
|
|
|
|
const requireEmailVerification = appConfiguration.auth.requireEmailVerification;
|
|
const showPasswordInput = !requireEmailVerification;
|
|
const captchaEnabled = requireCaptcha && appConfiguration.auth.captcha.enabled;
|
|
const checks = useMemo(() => getPasswordChecks(password, passwordPolicy), [password, passwordPolicy]);
|
|
const strength = checks.length === 0 ? 0 : Math.round((checks.filter((c) => c.valid).length / checks.length) * 100);
|
|
const passwordMeetsClientPolicy = !showPasswordInput || checks.length === 0 || checks.every((check) => check.valid);
|
|
const showPasswordPolicyError = passwordValidationRequested && !passwordMeetsClientPolicy;
|
|
|
|
useEffect(() => {
|
|
if (captchaResetKey) setCaptchaStatus("pending");
|
|
}, [captchaResetKey]);
|
|
|
|
useEffect(() => {
|
|
if (verificationEmailSent) return;
|
|
if (
|
|
!Number.isSafeInteger(officeSeatQuantity) ||
|
|
!Number.isSafeInteger(fieldSeatQuantity) ||
|
|
officeSeatQuantity < 1 ||
|
|
officeSeatQuantity > 10_000 ||
|
|
fieldSeatQuantity < 0 ||
|
|
fieldSeatQuantity > 10_000
|
|
) {
|
|
setPlanAdviceFailed(true);
|
|
return;
|
|
}
|
|
const controller = new AbortController();
|
|
const timer = window.setTimeout(async () => {
|
|
setPlanAdviceLoading(true);
|
|
setPlanAdviceFailed(false);
|
|
try {
|
|
const params = new URLSearchParams({ office: String(officeSeatQuantity), field: String(fieldSeatQuantity) });
|
|
const response = await fetch(`/auth/registration-plan-advice?${params}`, {
|
|
headers: { Accept: "application/json" },
|
|
signal: controller.signal,
|
|
});
|
|
if (!response.ok) throw new Error("Registration plan advice failed");
|
|
const advice = (await response.json()) as RegistrationPlanAdviceData;
|
|
setPlanOptions(advice.plans);
|
|
setRecommendedPriceId(advice.recommendedPriceId);
|
|
if (!planManuallyOverridden) setSelectedPriceId(advice.recommendedPriceId);
|
|
} catch {
|
|
if (!controller.signal.aborted) setPlanAdviceFailed(true);
|
|
} finally {
|
|
if (!controller.signal.aborted) setPlanAdviceLoading(false);
|
|
}
|
|
}, 250);
|
|
return () => {
|
|
window.clearTimeout(timer);
|
|
controller.abort();
|
|
};
|
|
}, [fieldSeatQuantity, officeSeatQuantity, planAdviceRetryKey, planManuallyOverridden, verificationEmailSent]);
|
|
|
|
function showTeamStep() {
|
|
setPasswordValidationRequested(true);
|
|
const accountStep = formRef.current?.querySelector('[data-ui-id="ui.auth.register.accountStep"]');
|
|
if (!accountStep) return;
|
|
const controls = Array.from(accountStep.querySelectorAll<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>("input, select, textarea"));
|
|
const nativeFieldsValid = controls.every((control) => control.reportValidity());
|
|
if (!passwordMeetsClientPolicy) {
|
|
passwordInputRef.current?.focus();
|
|
return;
|
|
}
|
|
if (nativeFieldsValid) setStep("team");
|
|
}
|
|
|
|
function selectPlan(priceId: string) {
|
|
setPlanManuallyOverridden(true);
|
|
setSelectedPriceId(priceId);
|
|
}
|
|
|
|
// S03 "E-Mail bestaetigen" — Davids Status-Card.
|
|
if (verificationEmailSent) {
|
|
return (
|
|
<div
|
|
className="bg-surface-neutral-primary mobile:gap-6 mobile:py-6 flex min-h-screen w-full flex-col items-center justify-center gap-8 px-4 py-12"
|
|
data-ui-id="ui.auth.register.verificationSent"
|
|
>
|
|
<Logo size="64" />
|
|
<Card size="large" variant="default" className="max-w-[448px]">
|
|
<div className="flex w-full flex-col items-center gap-5">
|
|
<IconWithBackground variant="information" size="large" round={true} icon={<FeatherMailCheck />} />
|
|
<div className="flex w-full flex-col items-center gap-2">
|
|
<span className="text-heading- font-heading- text-text-neutral-primary text-center">{t("account.verify.confirmEmailTitle")}</span>
|
|
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary w-full text-center">
|
|
{t("account.verify.confirmEmailBody")}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
<div className="border-border-default bg-surface-neutral-primary flex w-full flex-col items-center gap-2 rounded-md border border-solid px-4 py-3">
|
|
<span className="text-body-extra-small-medium-150 font-body-extra-small-medium-150 text-text-neutral-tertiary">
|
|
{t("account.verify.linkSentTo")}
|
|
</span>
|
|
<span
|
|
className="text-body-default-semibold-0 font-body-default-semibold-0 text-text-neutral-primary w-full text-center"
|
|
data-ui-id="ui.auth.register.sentEmail"
|
|
>
|
|
{email}
|
|
</span>
|
|
</div>
|
|
<Alert variant="neutral" notDismissible={true} title="" description={t("account.verify.checkInboxHint")} />
|
|
{error && navigation.state === "idle" ? (
|
|
<p
|
|
className="text-body-small-regular-0 font-body-small-regular-0 text-text-feedback-negative text-center"
|
|
role="alert"
|
|
data-ui-id="ui.auth.register.resendError"
|
|
>
|
|
{error}
|
|
</p>
|
|
) : null}
|
|
<div className="flex w-full flex-col items-center gap-3">
|
|
{/* The resend intent proves the persisted HMAC-bound pending capability; the server rotates token and TTL before queueing a new mail job. */}
|
|
<Form method="post" className="w-full">
|
|
<input type="hidden" name="csrf" value={csrf} readOnly />
|
|
<input type="hidden" name="redirectTo" value={redirect} readOnly />
|
|
<input type="hidden" name="intent" value="resendVerification" readOnly />
|
|
<input type="hidden" name="creationRequestKey" value={creationRequestKey} readOnly />
|
|
<input type="hidden" name="email" value={email} readOnly />
|
|
<input type="hidden" name="company" value={company} readOnly />
|
|
<input type="hidden" name="first-name" value={firstName} readOnly />
|
|
<input type="hidden" name="last-name" value={lastName} readOnly />
|
|
<input type="hidden" name="selectedSubscriptionPriceId" value={selectedPriceId} readOnly />
|
|
<input type="hidden" name="selectedOfficeSeatQuantity" value={officeSeatQuantity} readOnly />
|
|
<input type="hidden" name="selectedFieldSeatQuantity" value={fieldSeatQuantity} readOnly />
|
|
{leadConversion ? (
|
|
<>
|
|
<input type="hidden" name="leadId" value={leadConversion.leadId} readOnly />
|
|
<input type="hidden" name="leadToken" value={leadConversion.token} readOnly />
|
|
{leadConversion.planId ? <input type="hidden" name="leadPlanId" value={leadConversion.planId} readOnly /> : null}
|
|
</>
|
|
) : null}
|
|
<Button
|
|
type="submit"
|
|
className="h-10 w-full flex-none"
|
|
icon={<FeatherRotateCw />}
|
|
loading={isSubmitting}
|
|
disabled={isSubmitting}
|
|
data-ui-id="ui.auth.register.resend"
|
|
>
|
|
{t("account.register.resendEmail")}
|
|
</Button>
|
|
</Form>
|
|
<Button
|
|
className="h-10 w-full flex-none"
|
|
variant="secondary"
|
|
icon={<FeatherPencil />}
|
|
onClick={() => navigate("/signup?restart=1")}
|
|
data-ui-id="ui.auth.register.changeEmail"
|
|
>
|
|
{t("account.verify.changeEmail")}
|
|
</Button>
|
|
</div>
|
|
<div className="flex w-full items-center justify-center gap-1 px-2">
|
|
<Link to="/login" className="no-underline" data-ui-id="ui.auth.register.toLogin">
|
|
<LinkButton size="small" icon={<FeatherArrowLeft />}>
|
|
{t("account.verify.toLogin")}
|
|
</LinkButton>
|
|
</Link>
|
|
</div>
|
|
</Card>
|
|
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary max-w-[400px] text-center">
|
|
{t("account.verify.linkValidityNote")}
|
|
</span>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
// S01 "Signup".
|
|
return (
|
|
<AuthShell
|
|
title={step === "account" ? t("account.register.title") : step === "team" ? t("account.register.teamStepTitle") : t("account.register.planStepTitle")}
|
|
subtitle={
|
|
step === "account"
|
|
? t("account.register.signupSubtitle")
|
|
: step === "team"
|
|
? t("account.register.teamStepSubtitle")
|
|
: t("account.register.planStepSubtitle")
|
|
}
|
|
cardSize={step === "account" ? "large" : "extra-large"}
|
|
cardClassName={step === "account" ? "max-w-[448px]" : "max-w-[960px]"}
|
|
logoSize="32"
|
|
dataUiId="ui.auth.register.page"
|
|
footer={
|
|
<>
|
|
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">{t("account.register.haveAccount")}</span>
|
|
<Link to="/login" className="no-underline" data-ui-id="ui.auth.register.login">
|
|
<LinkButton size="small" hideIcon>
|
|
{t("account.register.signIn")}
|
|
</LinkButton>
|
|
</Link>
|
|
</>
|
|
}
|
|
>
|
|
{appConfiguration.auth.authMethods.emailPassword.enabled ? (
|
|
<Form ref={formRef} method="post" className="flex w-full flex-col gap-4" data-ui-id="ui.auth.register.form">
|
|
<StepperHorizontal className="pb-1" data-ui-id="ui.auth.register.steps">
|
|
<StepperHorizontal.Step
|
|
firstStep
|
|
variant={step === "account" ? "active" : "completed"}
|
|
stepNumber="1"
|
|
label={t("account.register.accountStepLabel")}
|
|
/>
|
|
<StepperHorizontal.Step
|
|
variant={step === "team" ? "active" : step === "plan" ? "completed" : "default"}
|
|
stepNumber="2"
|
|
label={t("account.register.teamStepLabel")}
|
|
/>
|
|
<StepperHorizontal.Step lastStep variant={step === "plan" ? "active" : "default"} stepNumber="3" label={t("account.register.planStepLabel")} />
|
|
</StepperHorizontal>
|
|
<input type="hidden" name="redirectTo" value={redirect} readOnly />
|
|
<input type="hidden" name="csrf" value={csrf} readOnly />
|
|
<input type="hidden" name="creationRequestKey" value={creationRequestKey} readOnly />
|
|
<input type="hidden" name="selectedSubscriptionPriceId" value={selectedPriceId} readOnly />
|
|
<input type="hidden" name="acceptTerms" value={acceptTerms ? "true" : "false"} readOnly />
|
|
<input type="hidden" name="acceptPrivacy" value={acceptPrivacy ? "true" : "false"} readOnly />
|
|
{leadConversion ? (
|
|
<>
|
|
<input type="hidden" name="leadId" value={leadConversion.leadId} readOnly />
|
|
<input type="hidden" name="leadToken" value={leadConversion.token} readOnly />
|
|
{leadConversion.planId ? <input type="hidden" name="leadPlanId" value={leadConversion.planId} readOnly /> : null}
|
|
</>
|
|
) : null}
|
|
|
|
<div className={step === "account" ? "flex w-full flex-col gap-4" : "hidden"} data-ui-id="ui.auth.register.accountStep">
|
|
{/* Davids Felder-Gruppe (gap-4). */}
|
|
<div className="flex w-full flex-col items-start gap-4">
|
|
<TextInput className="h-auto w-full flex-none" fillContainer showLabel label={t("account.shared.email")} type="email">
|
|
<TextInput.Input
|
|
name="email"
|
|
type="email"
|
|
required
|
|
autoComplete="email"
|
|
placeholder={t("account.shared.emailPlaceholder")}
|
|
value={email}
|
|
onChange={(event) => setEmail(event.target.value)}
|
|
readOnly={Boolean(leadConversion)}
|
|
disabled={isSubmitting}
|
|
data-ui-id="ui.auth.register.email"
|
|
/>
|
|
</TextInput>
|
|
|
|
{showPasswordInput ? (
|
|
<div className="flex w-full flex-col items-start gap-2">
|
|
<TextInput
|
|
className="h-auto w-full flex-none"
|
|
fillContainer
|
|
showLabel
|
|
label={t("account.shared.password")}
|
|
type="password"
|
|
error={showPasswordPolicyError}
|
|
message={
|
|
showPasswordPolicyError ? (
|
|
<span id="registration-password-policy-error" role="alert" data-ui-id="ui.auth.register.passwordPolicyError">
|
|
{t("account.register.passwordRequirements.fixBeforeContinue")}
|
|
</span>
|
|
) : undefined
|
|
}
|
|
>
|
|
<TextInput.Input
|
|
ref={passwordInputRef}
|
|
name="password"
|
|
type="password"
|
|
required
|
|
autoComplete="new-password"
|
|
placeholder={t("account.register.passwordChoosePlaceholder")}
|
|
value={password}
|
|
onChange={(event) => {
|
|
setPassword(event.target.value);
|
|
if (passwordValidationRequested) setPasswordValidationRequested(false);
|
|
}}
|
|
onBlur={() => {
|
|
if (password.length > 0 && !passwordMeetsClientPolicy) setPasswordValidationRequested(true);
|
|
}}
|
|
aria-invalid={showPasswordPolicyError}
|
|
aria-describedby={showPasswordPolicyError ? "registration-password-policy-error" : undefined}
|
|
disabled={isSubmitting}
|
|
data-ui-id="ui.auth.register.password"
|
|
/>
|
|
</TextInput>
|
|
{passwordPolicy ? (
|
|
<>
|
|
<Progress className="h-auto w-full flex-none" hideLabel label={t("account.register.passwordStrength")} value={strength} />
|
|
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-tertiary">
|
|
{t("account.register.passwordStrength")}
|
|
</span>
|
|
<ul
|
|
className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 flex w-full flex-col gap-1"
|
|
aria-live="polite"
|
|
aria-label={t("account.register.passwordRequirements.label")}
|
|
data-ui-id="ui.auth.register.passwordRequirements"
|
|
>
|
|
{checks.map((check) => {
|
|
const label = t(check.label, check.args);
|
|
const status = check.valid ? t("account.register.passwordRequirements.met") : t("account.register.passwordRequirements.notMet");
|
|
return (
|
|
<li
|
|
key={check.key}
|
|
className={
|
|
check.valid
|
|
? "text-text-feedback-positive"
|
|
: showPasswordPolicyError
|
|
? "text-text-feedback-negative"
|
|
: "text-text-neutral-tertiary"
|
|
}
|
|
aria-label={`${status}: ${label}`}
|
|
>
|
|
<span aria-hidden="true">{check.valid ? "[x]" : "[ ]"}</span> {label}
|
|
</li>
|
|
);
|
|
})}
|
|
</ul>
|
|
</>
|
|
) : null}
|
|
</div>
|
|
) : null}
|
|
|
|
<div className="mobile:flex-col flex w-full items-start gap-4">
|
|
<TextInput className="h-auto shrink-0 grow basis-0" showLabel label={t("models.user.firstName")}>
|
|
<TextInput.Input
|
|
name="first-name"
|
|
required={appConfiguration.auth.requireName}
|
|
placeholder={t("account.shared.firstNamePlaceholder")}
|
|
value={firstName}
|
|
onChange={(event) => setFirstName(event.target.value)}
|
|
disabled={isSubmitting}
|
|
data-ui-id="ui.auth.register.firstName"
|
|
/>
|
|
</TextInput>
|
|
<TextInput className="h-auto shrink-0 grow basis-0" showLabel label={t("models.user.lastName")}>
|
|
<TextInput.Input
|
|
name="last-name"
|
|
required={appConfiguration.auth.requireName}
|
|
placeholder={t("account.shared.lastNamePlaceholder")}
|
|
value={lastName}
|
|
onChange={(event) => setLastName(event.target.value)}
|
|
disabled={isSubmitting}
|
|
data-ui-id="ui.auth.register.lastName"
|
|
/>
|
|
</TextInput>
|
|
</div>
|
|
|
|
<TextInput className="h-auto w-full flex-none" fillContainer showLabel label={t("account.register.companyLabel")} icon={<FeatherBuilding />}>
|
|
<TextInput.Input
|
|
name="company"
|
|
required={appConfiguration.auth.requireOrganization}
|
|
placeholder={t("account.register.companyPlaceholder")}
|
|
value={company}
|
|
onChange={(event) => setCompany(event.target.value)}
|
|
disabled={isSubmitting}
|
|
data-ui-id="ui.auth.register.company"
|
|
/>
|
|
</TextInput>
|
|
</div>
|
|
|
|
<Button type="button" className="h-9 w-full flex-none" onClick={showTeamStep} data-ui-id="ui.auth.register.toTeamStep">
|
|
{t("account.register.continueToTeam")}
|
|
</Button>
|
|
</div>
|
|
|
|
<RegistrationPlanStep
|
|
visible={step !== "account"}
|
|
screen={step === "team" ? "team" : "plan"}
|
|
plans={planOptions}
|
|
selectedPriceId={selectedPriceId}
|
|
recommendedPriceId={recommendedPriceId}
|
|
officeSeatQuantity={officeSeatQuantity}
|
|
fieldSeatQuantity={fieldSeatQuantity}
|
|
planAdviceLoading={planAdviceLoading}
|
|
planAdviceFailed={planAdviceFailed}
|
|
isSubmitting={isSubmitting}
|
|
acceptTerms={acceptTerms}
|
|
acceptPrivacy={acceptPrivacy}
|
|
captchaEnabled={captchaEnabled}
|
|
captchaConfig={appConfiguration.auth.captcha}
|
|
captchaResetKey={captchaResetKey}
|
|
captchaStatus={captchaStatus}
|
|
requireEmailVerification={requireEmailVerification}
|
|
error={navigation.state === "idle" ? error : undefined}
|
|
onSelectPlan={selectPlan}
|
|
onOfficeSeatQuantityChange={setOfficeSeatQuantity}
|
|
onFieldSeatQuantityChange={setFieldSeatQuantity}
|
|
onAcceptTermsChange={setAcceptTerms}
|
|
onAcceptPrivacyChange={setAcceptPrivacy}
|
|
onCaptchaStatusChange={setCaptchaStatus}
|
|
onRetryPlanAdvice={() => {
|
|
setPlanAdviceFailed(false);
|
|
setPlanAdviceRetryKey((current) => current + 1);
|
|
}}
|
|
onContinue={() => setStep("plan")}
|
|
onBack={() => setStep(step === "plan" ? "team" : "account")}
|
|
/>
|
|
{/* The interactive seat controls live only on the team step and are
|
|
unmounted on the final plan step. Keep the submitted contract
|
|
present for the whole wizard so server-side price validation
|
|
always receives the exact quantities the customer reviewed. */}
|
|
<input type="hidden" name="selectedOfficeSeatQuantity" value={officeSeatQuantity} readOnly />
|
|
<input type="hidden" name="selectedFieldSeatQuantity" value={fieldSeatQuantity} readOnly />
|
|
</Form>
|
|
) : null}
|
|
</AuthShell>
|
|
);
|
|
}
|