Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
@@ -1,11 +1,13 @@
|
||||
import { useMemo, useState } from "react";
|
||||
import { ActionFunction, LoaderFunctionArgs, MetaFunction } from "react-router";
|
||||
import { Form, Link, useActionData, useLoaderData, useNavigation } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherArrowLeft, FeatherCheckCircle, FeatherInfo, FeatherRefreshCw } from "@subframe/core";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
import type { Registration } from "@hivegrid/db/prisma-browser";
|
||||
import { getRegistrationByToken } from "~/utils/db/registration.db.server";
|
||||
import { getRegistrationVerificationViewByToken } from "~/utils/db/registration.db.server";
|
||||
import AuthService from "~/modules/users/services/AuthService";
|
||||
import { getPasswordChecks, type PasswordPolicy } from "~/modules/users/components/RegisterForm";
|
||||
import { loadPasswordPolicy } from "~/services/auth/password-policy.server";
|
||||
import { useRootData } from "~/utils/data/useRootData";
|
||||
import { AuthShell } from "~/components/auth/AuthShell";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
@@ -16,15 +18,15 @@ import { Loader } from "~/ui/components/Loader";
|
||||
import { Logo } from "~/ui/components/Logo";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
|
||||
// E-Mail-Bestaetigung -> nach Davids Subframe-"S02 Signup erfolgreich / Workspace wird vorbereitet".
|
||||
// E-Mail-Bestaetigung -> Passwort setzen -> Tarifaktivierung.
|
||||
//
|
||||
// Davids S02 ist input-los und auto-provisioniert. Die bestehende Backend-Kette verlangt aber, dass der
|
||||
// Nutzer hier ein Passwort setzt (das Registration-Modell hat KEINE Passwort-Spalte, das Passwort wird also
|
||||
// erst beim Verify gesammelt) und provisioniert SYNCHRON in der Action (kein Job/Polling). Deshalb:
|
||||
// - vor dem Absenden: kompakte Abschluss-Card (Passwort -> "Workspace einrichten"); restliche Stammdaten
|
||||
// - vor dem Absenden: kompakte Abschluss-Card (Passwort -> Tarifaktivierung); restliche Stammdaten
|
||||
// kommen aus der Registration als hidden-Felder (kein erneutes Tippen).
|
||||
// - waehrend des Absendens: Davids S02 "Workspace wird vorbereitet" (Checkliste + Loader) als der
|
||||
// Provisionierungs-Moment; bei Erfolg leitet die Action auf das Dashboard weiter.
|
||||
// - waehrend des Absendens: ehrliche Uebergangsansicht; bei Erfolg leitet die Action in die
|
||||
// verpflichtende Tarifaktivierung weiter. Produktzugriff folgt erst nach bestaetigter Zahlung.
|
||||
// [Backend-Flags] Davids reines Auto-S02 braucht: Passwort-Spalte auf Registration (Erfassung schon in S01),
|
||||
// asynchrone Provisionierung + Polling/Live-Checkliste. Davids "Erneut versuchen"/"Support kontaktieren"
|
||||
// sind hier weggelassen (synchroner Flow, keine echten Ziele).
|
||||
@@ -33,32 +35,31 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => [{ title: data?.t
|
||||
|
||||
type LoaderData = {
|
||||
title: string;
|
||||
registration: Registration | null;
|
||||
registration: { email: string } | null;
|
||||
creationRequestKey: string;
|
||||
verificationStatus: "pending" | "expired" | "used" | "invalid";
|
||||
passwordPolicy: PasswordPolicy;
|
||||
};
|
||||
export const loader = async ({ request, params }: LoaderFunctionArgs) => {
|
||||
const { t } = await getTranslations(request);
|
||||
const registration = await getRegistrationByToken(params.id ?? "");
|
||||
const verification = await getRegistrationVerificationViewByToken(params.id ?? "");
|
||||
const data: LoaderData = {
|
||||
title: `${t("account.verify.title")} | ${process.env.APP_NAME}`,
|
||||
registration,
|
||||
registration: verification.status === "pending" ? { email: verification.email } : null,
|
||||
creationRequestKey: verification.status === "pending" ? verification.creationRequestKey : "",
|
||||
verificationStatus: verification.status,
|
||||
passwordPolicy: loadPasswordPolicy(),
|
||||
};
|
||||
return data;
|
||||
};
|
||||
|
||||
type ActionData = {
|
||||
error?: string;
|
||||
creationRequestKey?: string;
|
||||
fieldErrors?: {
|
||||
email: string | undefined;
|
||||
password: string | undefined;
|
||||
};
|
||||
fields?: {
|
||||
email: string;
|
||||
password: string;
|
||||
company: string | undefined;
|
||||
firstName: string | undefined;
|
||||
lastName: string | undefined;
|
||||
slug: string | undefined;
|
||||
};
|
||||
};
|
||||
|
||||
export const action: ActionFunction = async ({ request, params }) => {
|
||||
@@ -73,13 +74,19 @@ export default function RegisterRoute() {
|
||||
const navigation = useNavigation();
|
||||
const isSubmitting = navigation.state !== "idle";
|
||||
const registration = data.registration;
|
||||
const canComplete = Boolean(registration && !registration.createdTenantId);
|
||||
const canComplete = Boolean(registration);
|
||||
const creationRequestKey = actionData?.creationRequestKey ?? data.creationRequestKey;
|
||||
const [password, setPassword] = useState("");
|
||||
const [passwordValidationRequested, setPasswordValidationRequested] = useState(false);
|
||||
const passwordChecks = useMemo(() => getPasswordChecks(password, data.passwordPolicy), [data.passwordPolicy, password]);
|
||||
const passwordMeetsClientPolicy = passwordChecks.length > 0 && passwordChecks.every((check) => check.valid);
|
||||
const showPasswordPolicyError = passwordValidationRequested && !passwordMeetsClientPolicy;
|
||||
|
||||
// S02 "Workspace wird vorbereitet" — Provisionierungs-Moment waehrend des Absendens.
|
||||
// Ehrliche Uebergangsansicht waehrend Passwort und Registrierung serverseitig abgeschlossen werden.
|
||||
if (canComplete && isSubmitting) {
|
||||
return (
|
||||
<div
|
||||
className="flex min-h-screen w-full flex-col items-center justify-center gap-8 bg-surface-neutral-primary px-4 py-12 mobile:gap-6 mobile:py-6"
|
||||
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.verify.preparing"
|
||||
>
|
||||
<Logo size="64" />
|
||||
@@ -88,33 +95,43 @@ export default function RegisterRoute() {
|
||||
<IconWithBackground size="large" round={true} icon={<FeatherRefreshCw />} />
|
||||
<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.preparingTitle")}</span>
|
||||
<span className="w-full text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary text-center">{t("account.verify.preparingBody")}</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary w-full text-center">
|
||||
{t("account.verify.preparingBody")}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex w-full flex-col items-start gap-3 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-4">
|
||||
<div className="border-border-default bg-surface-neutral-primary flex w-full flex-col items-start gap-3 rounded-md border border-solid px-4 py-4">
|
||||
<div className="flex w-full items-center gap-3">
|
||||
<FeatherCheckCircle className="text-body-default-regular-150 font-body-default-regular-150 text-text-feedback-positive" />
|
||||
<span className="grow shrink-0 basis-0 text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">{t("account.verify.stepAccountCreated")}</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary shrink-0 grow basis-0">
|
||||
{t("account.verify.stepAccountCreated")}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex w-full items-center gap-3">
|
||||
<FeatherCheckCircle className="text-body-default-regular-150 font-body-default-regular-150 text-text-feedback-positive" />
|
||||
<span className="grow shrink-0 basis-0 text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">{t("account.verify.stepEmailConfirmed")}</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary shrink-0 grow basis-0">
|
||||
{t("account.verify.stepEmailConfirmed")}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex w-full items-center gap-3">
|
||||
<Loader className="text-text-neutral-tertiary" size="small" />
|
||||
<span className="grow shrink-0 basis-0 text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-primary">{t("account.verify.stepWorkspaceConfiguring")}</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-primary shrink-0 grow basis-0">
|
||||
{t("account.verify.stepWorkspaceConfiguring")}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex w-full items-center justify-center gap-2">
|
||||
<FeatherInfo className="text-body-small-regular-150 font-body-small-regular-150 text-icon-neutral-tertiary" />
|
||||
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary text-center">{t("account.verify.autoRedirectNote")}</span>
|
||||
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary text-center">
|
||||
{t("account.verify.autoRedirectNote")}
|
||||
</span>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Abschluss-Card: Passwort setzen -> Workspace einrichten (Backend sammelt das Passwort erst hier).
|
||||
// Abschluss-Card: Passwort setzen -> Tarifaktivierung (Backend sammelt das Passwort erst hier).
|
||||
if (canComplete) {
|
||||
return (
|
||||
<AuthShell
|
||||
@@ -125,45 +142,93 @@ export default function RegisterRoute() {
|
||||
logoIconOnly={false}
|
||||
dataUiId="ui.auth.verify.page"
|
||||
>
|
||||
<Form method="post" noValidate className="flex w-full flex-col gap-4" data-ui-id="ui.auth.verify.form">
|
||||
<Form method="post" className="flex w-full flex-col gap-4" data-ui-id="ui.auth.verify.form">
|
||||
<input type="hidden" name="csrf" value={csrf} readOnly />
|
||||
<input type="hidden" name="email" value={registration?.email ?? ""} readOnly />
|
||||
<input type="hidden" name="company" value={registration?.company ?? ""} readOnly />
|
||||
<input type="hidden" name="first-name" value={registration?.firstName ?? ""} readOnly />
|
||||
<input type="hidden" name="last-name" value={registration?.lastName ?? ""} readOnly />
|
||||
<input type="hidden" name="creationRequestKey" value={creationRequestKey} readOnly />
|
||||
|
||||
<div className="flex w-full flex-col items-center gap-2 rounded-md border border-solid border-border-default bg-surface-neutral-primary 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="w-full text-body-default-semibold-0 font-body-default-semibold-0 text-text-neutral-primary text-center">{registration?.email}</span>
|
||||
<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">
|
||||
{registration?.email}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<TextInput
|
||||
className="h-auto w-full flex-none"
|
||||
fillContainer
|
||||
showLabel
|
||||
label={t("account.shared.password")}
|
||||
helpText={actionData?.fieldErrors?.password ?? ""}
|
||||
error={Boolean(actionData?.fieldErrors?.password)}
|
||||
type="password"
|
||||
>
|
||||
<TextInput.Input
|
||||
name="password"
|
||||
<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")}
|
||||
helpText={actionData?.fieldErrors?.password ?? ""}
|
||||
error={showPasswordPolicyError || Boolean(actionData?.fieldErrors?.password)}
|
||||
message={
|
||||
showPasswordPolicyError ? (
|
||||
<span id="verification-password-policy-error" role="alert" data-ui-id="ui.auth.verify.passwordPolicyError">
|
||||
{t("account.register.passwordRequirements.fixBeforeContinue")}
|
||||
</span>
|
||||
) : undefined
|
||||
}
|
||||
type="password"
|
||||
required
|
||||
autoComplete="new-password"
|
||||
autoFocus
|
||||
placeholder={t("account.register.passwordChoosePlaceholder")}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.verify.password"
|
||||
/>
|
||||
</TextInput>
|
||||
>
|
||||
<TextInput.Input
|
||||
name="password"
|
||||
type="password"
|
||||
required
|
||||
autoComplete="new-password"
|
||||
autoFocus
|
||||
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 || Boolean(actionData?.fieldErrors?.password)}
|
||||
aria-describedby={showPasswordPolicyError ? "verification-password-policy-error" : undefined}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.verify.password"
|
||||
/>
|
||||
</TextInput>
|
||||
<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.verify.passwordRequirements"
|
||||
>
|
||||
{passwordChecks.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>
|
||||
</div>
|
||||
|
||||
<Button type="submit" className="h-9 w-full flex-none" loading={isSubmitting} disabled={isSubmitting} data-ui-id="ui.auth.verify.submit">
|
||||
<Button
|
||||
type="submit"
|
||||
className="h-9 w-full flex-none"
|
||||
loading={isSubmitting}
|
||||
disabled={isSubmitting || !passwordMeetsClientPolicy}
|
||||
data-ui-id="ui.auth.verify.submit"
|
||||
>
|
||||
{t("account.verify.setupWorkspace")}
|
||||
</Button>
|
||||
|
||||
{actionData?.error && navigation.state === "idle" ? (
|
||||
<p className="text-center text-body-small-regular-0 font-body-small-regular-0 text-text-feedback-negative" role="alert">
|
||||
<p className="text-body-small-regular-0 font-body-small-regular-0 text-text-feedback-negative text-center" role="alert">
|
||||
{actionData.error}
|
||||
</p>
|
||||
) : null}
|
||||
@@ -172,16 +237,39 @@ export default function RegisterRoute() {
|
||||
);
|
||||
}
|
||||
|
||||
// Ungueltiger / bereits eingeloester Link.
|
||||
const invalidLinkMessage =
|
||||
data.verificationStatus === "expired"
|
||||
? t("account.verify.expiredLink")
|
||||
: data.verificationStatus === "used"
|
||||
? t("account.verify.usedLink")
|
||||
: t("account.verify.invalidLink");
|
||||
const invalidLinkDestination = data.verificationStatus === "expired" ? "/register" : "/login";
|
||||
const invalidLinkAction = data.verificationStatus === "expired" ? t("account.verify.restartRegistration") : t("account.verify.toLogin");
|
||||
|
||||
// Invalid, expired, or already-consumed link.
|
||||
return (
|
||||
<AuthShell title={t("account.verify.title")} subtitle={t("account.verify.invalidLink")} cardSize="medium" cardClassName="max-w-[448px]" logoIconOnly={false} dataUiId="ui.auth.verify.invalid">
|
||||
<AuthShell
|
||||
title={t("account.verify.title")}
|
||||
subtitle={invalidLinkMessage}
|
||||
cardSize="medium"
|
||||
cardClassName="max-w-[448px]"
|
||||
logoIconOnly={false}
|
||||
dataUiId="ui.auth.verify.invalid"
|
||||
>
|
||||
<div className="flex w-full items-center justify-center gap-1" data-ui-id="ui.auth.verify.toLogin">
|
||||
<Link to="/login" className="no-underline">
|
||||
<Link to={invalidLinkDestination} className="no-underline">
|
||||
<LinkButton size="small" icon={<FeatherArrowLeft />}>
|
||||
{t("account.verify.toLogin")}
|
||||
{invalidLinkAction}
|
||||
</LinkButton>
|
||||
</Link>
|
||||
</div>
|
||||
</AuthShell>
|
||||
);
|
||||
}
|
||||
|
||||
export function headers() {
|
||||
return {
|
||||
"Cache-Control": "no-store",
|
||||
"Referrer-Policy": "no-referrer",
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user