Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -1,6 +1,7 @@
import { useEffect, useRef, useState } from "react";
import { Form, useActionData, useNavigation, useSubmit } from "react-router";
import { useTranslation } from "react-i18next";
import { formatDate } from "~/locale/format";
import { QRCodeSVG } from "qrcode.react";
import {
FeatherArrowLeft,
@@ -22,6 +23,7 @@ import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Button } from "~/ui/components/Button";
import { Card } from "~/ui/components/Card";
import { CopyToClipboardButton } from "~/ui/components/CopyToClipboardButton";
import { Dialog } from "~/ui/components/Dialog";
import { IconButton } from "~/ui/components/IconButton";
import { IconWithBackground } from "~/ui/components/IconWithBackground";
import { InputOtp } from "~/ui/components/InputOtp";
@@ -30,6 +32,7 @@ import { Select } from "~/ui/components/Select";
import { TextInput } from "~/ui/components/TextInput";
import { TenantUserType } from "~/application/enums/tenants/TenantUserType";
import { useRootData } from "~/utils/data/useRootData";
import AvatarCropDialog from "./AvatarCropDialog";
// D-P2 — Settings > Profil nach Davids Subframe-"My Profile"-Design: Profil-Card (Avatar + Name inline-edit +
// E-Mail read-only) + Sicherheits-Card (Passwort ändern -> Modal, 2FA -> Verwalten/Setup/Disable-Modal). Praesentational,
@@ -72,14 +75,14 @@ function userDisplayName(user: ProfileUser): string {
// hier 1:1 als Markup nachgebaut, OHNE die Settings-Shell/Navigation umzubauen.
function NeutralCard({ children }: { children: React.ReactNode }) {
return (
<div className="flex h-full w-full flex-col items-start gap-3 rounded-lg bg-surface-neutral-secondary px-4 py-4">
<div className="flex w-full grow shrink-0 basis-0 flex-col items-start gap-3">{children}</div>
<div className="bg-surface-neutral-secondary flex h-full w-full flex-col items-start gap-3 rounded-lg px-4 py-4">
<div className="flex w-full shrink-0 grow basis-0 flex-col items-start gap-3">{children}</div>
</div>
);
}
function CardDivider() {
return <div className="flex h-px w-full flex-col items-center gap-2 bg-surface-neutral-tertiary" />;
return <div className="bg-surface-neutral-tertiary flex h-px w-full flex-col items-center gap-2" />;
}
function SettingRow({ label, helpText, children }: { label: React.ReactNode; helpText?: React.ReactNode; children: React.ReactNode }) {
@@ -88,10 +91,10 @@ function SettingRow({ label, helpText, children }: { label: React.ReactNode; hel
<div className="flex flex-col items-start gap-1">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{label}</span>
{helpText ? (
<span className="w-full text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">{helpText}</span>
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary w-full">{helpText}</span>
) : null}
</div>
<div className="flex grow shrink-0 basis-0 items-center justify-end">{children}</div>
<div className="flex shrink-0 grow basis-0 items-center justify-end">{children}</div>
</div>
);
}
@@ -147,6 +150,8 @@ export default function MyProfileScreen({
const fileInput = useRef<HTMLInputElement | null>(null);
const avatarForm = useRef<HTMLFormElement | null>(null);
const [avatarData, setAvatarData] = useState<string>("");
// Data URI of the picked file while the crop dialog is open; null when closed.
const [cropSource, setCropSource] = useState<string | null>(null);
// Schritt-Übergänge des 2FA-Flows aus der Action-Antwort ableiten.
useEffect(() => {
@@ -164,17 +169,24 @@ export default function MyProfileScreen({
if (!mfaStatus?.enabled && (twoFa === "disable" || twoFa === "manage")) setTwoFa(null);
}, [mfaStatus?.enabled, twoFa]);
// A picked file goes into the crop dialog first; only the section the user
// confirmed there is submitted. Clearing the input lets the same file be
// picked again after a cancel, which otherwise fires no change event.
function onPickAvatar(event: React.ChangeEvent<HTMLInputElement>) {
const file = event.target.files?.[0];
event.target.value = "";
if (!file) return;
const reader = new FileReader();
reader.onload = () => {
setAvatarData(String(reader.result ?? ""));
requestAnimationFrame(() => avatarForm.current && submit(avatarForm.current));
};
reader.onload = () => setCropSource(String(reader.result ?? ""));
reader.readAsDataURL(file);
}
function onCropConfirmed(dataUri: string) {
setCropSource(null);
setAvatarData(dataUri);
requestAnimationFrame(() => avatarForm.current && submit(avatarForm.current));
}
const mfaEnabled = Boolean(mfaStatus?.enabled);
const roleName = role === null || role === undefined ? "" : TenantUserType[role];
const roleLabel = roleName ? t(`settings.profile.types.${roleName}`) : "";
@@ -182,30 +194,20 @@ export default function MyProfileScreen({
return (
<div className="flex w-full flex-col items-start gap-4" data-ui-id="ui.settings.profile.page">
<div className="flex w-full flex-col items-start gap-4">
{/* Header */}
<div className="flex w-full flex-col items-start gap-2">
<span className="text-title-page font-title-page text-text-neutral-primary mobile:text-subtitle mobile:font-subtitle">
{t("settings.profile.accountSettings.title")}
</span>
<span className="w-full text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-tertiary">
{t("settings.profile.accountSettings.description")}
</span>
</div>
{/* Page headline (title/subtitle) lives in the route's shared PageHeader. */}
{/* Reihe 1 — Profil + Accountsicherheit */}
<div className="flex w-full items-start gap-4 mobile:flex-col">
<div className="mobile:flex-col flex w-full items-start gap-4">
<NeutralCard>
<div className="flex w-full items-center gap-6 mobile:flex-col mobile:items-start">
<div className="flex grow shrink-0 basis-0 items-center gap-4">
<Avatar size="large" image={user.avatar ?? undefined}>
<div className="mobile:flex-col mobile:items-start flex w-full items-center gap-6">
<div className="flex shrink-0 grow basis-0 items-center gap-4">
<Avatar size="extra-large" image={user.avatar ?? undefined}>
{initials(user)}
</Avatar>
<div className="flex grow shrink-0 basis-0 flex-col items-start gap-3">
<div className="flex shrink-0 grow basis-0 flex-col items-start gap-3">
<div className="flex flex-col items-start gap-0.5">
<span className="text-heading- font-heading- text-text-neutral-primary">{userDisplayName(user)}</span>
{roleLabel ? (
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{roleLabel}</span>
) : null}
{roleLabel ? <span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{roleLabel}</span> : null}
</div>
<div className="flex items-center gap-2">
{/* Bild ändern (Avatar-Upload, autosubmit per onPick) */}
@@ -215,7 +217,14 @@ export default function MyProfileScreen({
<input type="hidden" name="firstName" value={user.firstName ?? ""} readOnly />
<input type="hidden" name="lastName" value={user.lastName ?? ""} readOnly />
<input type="hidden" name="avatar" value={avatarData} readOnly />
<input ref={fileInput} type="file" accept="image/png,image/jpeg" className="hidden" onChange={onPickAvatar} data-ui-id="ui.settings.profile.avatarInput" />
<input
ref={fileInput}
type="file"
accept="image/png,image/jpeg"
className="hidden"
onChange={onPickAvatar}
data-ui-id="ui.settings.profile.avatarInput"
/>
<Button
type="button"
variant="secondary"
@@ -249,19 +258,18 @@ export default function MyProfileScreen({
</div>
</div>
</div>
<div className="flex w-px flex-none flex-col items-center self-stretch bg-surface-neutral-tertiary mobile:hidden" />
<div className="flex w-80 flex-none flex-col items-start gap-2 mobile:w-full">
<div className="bg-surface-neutral-tertiary mobile:hidden flex w-px flex-none flex-col items-center self-stretch" />
<div className="mobile:w-full flex w-80 flex-none flex-col items-start gap-2">
<span className="text-body-small-semibold-150 font-body-small-semibold-150 text-text-neutral-tertiary">
{t("settings.profile.security.accountSecurity")}
</span>
<div className="flex w-full items-center gap-3 rounded-md bg-surface-neutral-primary px-3 py-2">
<div className="bg-surface-neutral-primary flex w-full items-center gap-3 rounded-md px-3 py-2">
<FeatherShieldCheck
className={
"text-body-default-regular-0 font-body-default-regular-0 " +
(mfaEnabled ? "text-icon-feedback-positive" : "text-icon-neutral-tertiary")
"text-body-default-regular-0 font-body-default-regular-0 " + (mfaEnabled ? "text-icon-feedback-positive" : "text-icon-neutral-tertiary")
}
/>
<div className="flex grow shrink-0 basis-0 flex-col items-start">
<div className="flex shrink-0 grow basis-0 flex-col items-start">
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary">
{t("settings.profile.security.twoFactorShort")}
</span>
@@ -279,11 +287,11 @@ export default function MyProfileScreen({
</div>
{/* Reihe 2 — Basis info + Login info */}
<div className="flex w-full items-start gap-4 mobile:flex-col">
<div className="mobile:flex-col flex w-full items-start gap-4">
<NeutralCard>
<span className="text-heading- font-heading- text-text-neutral-primary">{t("settings.profile.basicInfo.title")}</span>
<CardDivider />
<Form method="post" replace className="flex w-full flex-col items-start gap-3">
<Form method="post" replace className="flex w-full flex-col items-start gap-3" data-ui-id="ui.settings.profile.form">
<input type="hidden" name="csrf" value={csrf} readOnly />
<input type="hidden" name="action" value="profile" readOnly />
{/* Avatar mitsenden, damit Speichern des Namens das vorhandene Bild nicht löscht. */}
@@ -293,6 +301,7 @@ export default function MyProfileScreen({
<TextInput.Input
name="firstName"
required
aria-label={t("models.user.firstName")}
defaultValue={user.firstName ?? ""}
placeholder={t("account.shared.firstNamePlaceholder")}
data-ui-id="ui.settings.profile.firstName"
@@ -304,6 +313,7 @@ export default function MyProfileScreen({
<TextInput className="h-auto w-56 flex-none">
<TextInput.Input
name="lastName"
aria-label={t("models.user.lastName")}
defaultValue={user.lastName ?? ""}
placeholder={t("account.shared.lastNamePlaceholder")}
data-ui-id="ui.settings.profile.lastName"
@@ -313,7 +323,14 @@ export default function MyProfileScreen({
<CardDivider />
<SettingRow label={t("settings.profile.basicInfo.phone")}>
<TextInput disabled className="h-auto w-56 flex-none" type="tel">
<TextInput.Input type="tel" disabled readOnly value={user.phone ?? ""} data-ui-id="ui.settings.profile.phone" />
<TextInput.Input
type="tel"
disabled
readOnly
aria-label={t("settings.profile.basicInfo.phone")}
value={user.phone ?? ""}
data-ui-id="ui.settings.profile.phone"
/>
</TextInput>
</SettingRow>
<CardDivider />
@@ -322,13 +339,21 @@ export default function MyProfileScreen({
disabled
className="h-auto w-56 flex-none"
placeholder={t("settings.profile.basicInfo.department")}
triggerAriaLabel={t("settings.profile.basicInfo.department")}
data-ui-id="ui.settings.profile.department"
/>
</SettingRow>
<CardDivider />
<SettingRow label={t("models.user.role")} helpText={t("settings.profile.basicInfo.roleAssignedByAdmin")}>
<TextInput disabled className="h-auto w-56 flex-none">
<TextInput.Input disabled readOnly value={roleLabel} placeholder={t("models.user.role")} data-ui-id="ui.settings.profile.role" />
<TextInput.Input
disabled
readOnly
aria-label={t("models.user.role")}
value={roleLabel}
placeholder={t("models.user.role")}
data-ui-id="ui.settings.profile.role"
/>
</TextInput>
</SettingRow>
<div className="flex w-full items-center justify-end">
@@ -345,15 +370,20 @@ export default function MyProfileScreen({
<CardDivider />
<SettingRow label={t("settings.profile.loginInfo.email")}>
<TextInput disabled className="h-auto w-72 flex-none" type="email">
<TextInput.Input type="email" disabled readOnly value={user.email} data-ui-id="ui.settings.profile.email" />
<TextInput.Input
type="email"
disabled
readOnly
aria-label={t("settings.profile.loginInfo.email")}
value={user.email}
data-ui-id="ui.settings.profile.email"
/>
</TextInput>
</SettingRow>
<CardDivider />
<SettingRow label={t("settings.profile.password")}>
<div className="flex items-center gap-3">
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary tracking-widest">
••••••••••
</span>
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary tracking-widest">••••••••••</span>
<Button size="small" onClick={() => setPwOpen(true)} data-ui-id="ui.settings.profile.password.open">
{t("settings.profile.changePassword")}
</Button>
@@ -374,6 +404,9 @@ export default function MyProfileScreen({
</div>
</div>
{cropSource ? (
<AvatarCropDialog source={cropSource} submitting={submitting} onCancel={() => setCropSource(null)} onConfirm={onCropConfirmed} />
) : null}
{pwOpen ? (
actionData?.passwordLocked ? (
<ChangePasswordLockedDialog retryLabel={actionData.passwordLockedRetryLabel} onClose={() => setPwOpen(false)} />
@@ -398,17 +431,27 @@ export default function MyProfileScreen({
);
}
function ModalShell({ children, dataUiId, center = false }: { children: React.ReactNode; dataUiId: string; center?: boolean }) {
function ModalShell({
children,
dataUiId,
center = false,
onClose,
}: {
children: React.ReactNode;
dataUiId: string;
center?: boolean;
onClose: () => void;
}) {
return (
<div className="fixed inset-0 z-50 flex flex-col items-center justify-center gap-2 bg-surface-neutral-overlay px-4 py-4" data-ui-id={dataUiId}>
<DialogOverlay dataUiId={dataUiId} onClose={onClose}>
<div
className={`flex w-full max-w-[480px] flex-col gap-6 rounded-md border border-solid border-border-default bg-surface-neutral-modal px-6 py-6 shadow-lg mobile:max-w-full ${
className={`border-border-default bg-surface-neutral-modal mobile:max-w-full flex w-full max-w-[480px] flex-col gap-6 rounded-md border border-solid px-6 py-6 shadow-lg ${
center ? "items-center text-center" : "items-start"
}`}
>
{children}
</div>
</div>
</DialogOverlay>
);
}
@@ -443,32 +486,37 @@ function ChangePasswordDialog({
const strength = passwordStrength(pw);
const fullName = [user.firstName, user.lastName].filter(Boolean).join(" ");
return (
<DialogOverlay dataUiId="ui.settings.profile.password.modal">
<div className="flex w-full flex-col items-start gap-6 rounded-lg border border-solid border-border-default bg-surface-neutral-secondary px-6 py-6 shadow-lg max-w-[480px] relative mobile:px-4 mobile:py-5">
<DialogOverlay dataUiId="ui.settings.profile.password.modal" onClose={onClose}>
<div className="border-border-default bg-surface-neutral-secondary mobile:px-4 mobile:py-5 relative flex w-full max-w-[480px] flex-col items-start gap-6 rounded-lg border border-solid px-6 py-6 shadow-lg">
<IconButton
className="absolute right-3 top-3"
className="absolute top-3 right-3"
variant="ghost"
size="small"
icon={<FeatherX />}
aria-label={t("shared.close")}
onClick={onClose}
data-ui-id="ui.settings.profile.password.close"
/>
<div className="flex w-full flex-col items-center justify-center gap-1">
<div className="flex h-11 w-11 flex-none items-center justify-center rounded-round bg-surface-feedback-subtle-information">
<div className="rounded-round bg-surface-feedback-subtle-information flex h-11 w-11 flex-none items-center justify-center">
<FeatherShieldCheck className="text-heading- font-heading- text-icon-feedback-information" />
</div>
<span className="w-full text-heading- font-heading- text-text-neutral-primary text-center">{t("settings.profile.reauth.title")}</span>
<span className="w-full text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary text-center">
<span className="text-heading- font-heading- text-text-neutral-primary w-full text-center">{t("settings.profile.reauth.title")}</span>
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary w-full text-center">
{t("settings.profile.reauth.subtitle")}
</span>
</div>
<div className="flex w-full items-center gap-3 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-3">
<Avatar size="medium" image={user.avatar ?? undefined}>{initials(user)}</Avatar>
<div className="flex grow shrink-0 basis-0 flex-col items-start">
<span className="w-full text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary">{fullName || user.email}</span>
<span className="w-full text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">{user.email}</span>
<div className="border-border-default bg-surface-neutral-secondary flex w-full items-center gap-3 rounded-md border border-solid px-4 py-3">
<Avatar size="medium" image={user.avatar ?? undefined}>
{initials(user)}
</Avatar>
<div className="flex shrink-0 grow basis-0 flex-col items-start">
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary w-full">{fullName || user.email}</span>
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary w-full">{user.email}</span>
</div>
<BadgeFeedback farbe="subtle-neutral" size="small">{t("settings.profile.reauth.currentAccount")}</BadgeFeedback>
<BadgeFeedback farbe="subtle-neutral" size="small">
{t("settings.profile.reauth.currentAccount")}
</BadgeFeedback>
</div>
<Form method="post" replace className="flex w-full flex-col items-start gap-6">
<input type="hidden" name="csrf" value={csrf} readOnly />
@@ -495,18 +543,32 @@ function ChangePasswordDialog({
data-ui-id="ui.settings.profile.password.new"
/>
</TextInput>
<Progress className="h-auto w-full flex-none" hideLabel value={strength} state={strength >= 80 ? "success" : undefined} />
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">{t("settings.profile.passwordDialog.hint")}</span>
<Progress
className="h-auto w-full flex-none"
hideLabel
value={strength}
state={strength >= 80 ? "success" : undefined}
aria-label={t("settings.profile.passwordDialog.hint")}
/>
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">
{t("settings.profile.passwordDialog.hint")}
</span>
</div>
<TextInput className="h-auto w-full flex-none" showLabel label={t("settings.profile.passwordDialog.confirm")} type="password">
<TextInput.Input name="passwordNewConfirm" type="password" required autoComplete="new-password" data-ui-id="ui.settings.profile.password.confirm" />
</TextInput>
{error ? <span className="text-body-small-regular-0 font-body-small-regular-0 text-text-feedback-negative">{error}</span> : null}
<div className="flex w-full items-center justify-end gap-2 mobile:flex-col-reverse">
<Button className="h-9 grow shrink-0 basis-0" type="button" variant="secondary" onClick={onClose} data-ui-id="ui.settings.profile.password.cancel">
<div className="mobile:flex-col-reverse flex w-full items-center justify-end gap-2">
<Button className="h-9 shrink-0 grow basis-0" type="button" variant="secondary" onClick={onClose} data-ui-id="ui.settings.profile.password.cancel">
{t("shared.cancel")}
</Button>
<Button className="h-9 grow shrink-0 basis-0" type="submit" iconRight={<FeatherArrowRight />} loading={submitting} data-ui-id="ui.settings.profile.password.submit">
<Button
className="h-9 shrink-0 grow basis-0"
type="submit"
iconRight={<FeatherArrowRight />}
loading={submitting}
data-ui-id="ui.settings.profile.password.submit"
>
{t("settings.profile.mfa.setup.next")}
</Button>
</div>
@@ -519,13 +581,13 @@ function ChangePasswordDialog({
function ChangePasswordLockedDialog({ retryLabel, onClose }: { retryLabel?: string; onClose: () => void }) {
const { t } = useTranslation();
return (
<DialogOverlay dataUiId="ui.settings.profile.password.locked">
<Card className="max-w-[480px] mobile:gap-6 mobile:shadow-lg mobile:px-4 mobile:py-5">
<DialogOverlay dataUiId="ui.settings.profile.password.locked" onClose={onClose}>
<Card className="mobile:gap-6 mobile:shadow-lg mobile:px-4 mobile:py-5 max-w-[480px]">
<div className="flex w-full flex-col items-center gap-4">
<IconWithBackground variant="warning" size="extra-large" round={true} icon={<FeatherShieldAlert />} />
<div className="flex w-full flex-col items-center gap-1">
<span className="w-full text-heading- font-heading- text-text-neutral-primary text-center">{t("settings.profile.changePasswordLocked.title")}</span>
<span className="w-full text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary text-center">
<span className="text-heading- font-heading- text-text-neutral-primary w-full text-center">{t("settings.profile.changePasswordLocked.title")}</span>
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary w-full text-center">
{t("settings.profile.changePasswordLocked.subtitle")}
</span>
</div>
@@ -555,15 +617,31 @@ function ChangePasswordLockedDialog({ retryLabel, onClose }: { retryLabel?: stri
);
}
function DialogOverlay({ children, dataUiId }: { children: React.ReactNode; dataUiId: string }) {
// Entspricht Davids DialogLayout/Dialog-Overlay (zentrierte Card auf abgedunkeltem Hintergrund).
function DialogOverlay({ children, dataUiId, onClose }: { children: React.ReactNode; dataUiId: string; onClose: () => void }) {
// Davids DialogLayout (zentrierte Card auf abgedunkeltem Hintergrund) — aber
// durch die geteilte Dialog-Komponente, wie jeder andere Pop-up im Produkt.
// Vorher war das ein handgebautes `fixed inset-0` mitten im Seiteninhalt: das
// dunkelte nur den Inhaltsbereich ab, weil Sidebar und Kopfleiste auf
// derselben z-Ebene darueber lagen, und brachte weder Fokus-Falle noch
// Escape-to-close mit. Die Dialog-Komponente portalisiert nach document.body
// und loest das strukturell.
//
// Dialog.Content bleibt hier bewusst transparent und randlos: die Karte
// darin ist Davids Screen und bringt Rahmen, Flaeche und Schatten selbst mit.
return (
<div
className="fixed inset-0 z-50 flex flex-col items-center justify-center gap-2 bg-surface-neutral-overlay px-4 py-4"
data-ui-id={dataUiId}
<Dialog
open
onOpenChange={(open: boolean) => {
if (!open) onClose();
}}
>
{children}
</div>
<Dialog.Content
className="max-h-[90vh] w-auto min-w-0 max-w-[92vw] overflow-auto border-none bg-transparent shadow-none"
data-ui-id={dataUiId}
>
{children}
</Dialog.Content>
</Dialog>
);
}
@@ -591,7 +669,7 @@ function TwoFaModal({
onClose: () => void;
}) {
const { t, i18n } = useTranslation();
const secret = otpauthUri ? new URLSearchParams(otpauthUri.split("?")[1] ?? "").get("secret") ?? "" : "";
const secret = otpauthUri ? (new URLSearchParams(otpauthUri.split("?")[1] ?? "").get("secret") ?? "") : "";
const groupedSecret = secret.replace(/(.{4})/g, "$1 ").trim();
const [digits, setDigits] = useState<string[]>(Array(6).fill(""));
const code = digits.join("");
@@ -607,15 +685,15 @@ function TwoFaModal({
if (step === "manage") {
const activatedLabel =
enabledAt != null
? t("settings.profile.mfa.manage.activatedAt", { date: new Date(enabledAt).toLocaleDateString(i18n.language) })
? t("settings.profile.mfa.manage.activatedAt", { date: formatDate(enabledAt, i18n.language) })
: t("settings.profile.mfa.status.enabled");
return (
<DialogOverlay dataUiId="ui.settings.profile.mfa.manage.dialog">
<div className="flex h-auto w-auto min-w-[384px] max-w-[576px] max-h-[90vh] flex-none flex-col items-start gap-2 overflow-auto rounded-md border border-solid border-border-default bg-surface-neutral-modal shadow-lg mobile:w-full mobile:min-w-0">
<div className="flex w-full items-start gap-4 px-4 pt-4 mobile:pb-4">
<div className="flex grow shrink-0 basis-0 flex-col items-start gap-1">
<span className="w-full text-heading- font-heading- text-text-neutral-primary">{t("settings.profile.mfa.title")}</span>
<span className="w-full text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
<DialogOverlay dataUiId="ui.settings.profile.mfa.manage.dialog" onClose={onClose}>
<div className="border-border-default bg-surface-neutral-modal mobile:w-full mobile:min-w-0 flex h-auto max-h-[90vh] w-auto max-w-[576px] min-w-[384px] flex-none flex-col items-start gap-2 overflow-auto rounded-md border border-solid shadow-lg">
<div className="mobile:pb-4 flex w-full items-start gap-4 px-4 pt-4">
<div className="flex shrink-0 grow basis-0 flex-col items-start gap-1">
<span className="text-heading- font-heading- text-text-neutral-primary w-full">{t("settings.profile.mfa.title")}</span>
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary w-full">
{t("settings.profile.mfa.manage.subtitle")}
</span>
</div>
@@ -623,11 +701,13 @@ function TwoFaModal({
<IconButton variant="ghost" icon={<FeatherX />} onClick={onClose} data-ui-id="ui.settings.profile.mfa.manage.close" />
</div>
</div>
<div className="flex w-full flex-col items-start gap-3 px-4 pb-4 mobile:pt-4">
<div className="flex w-full items-end justify-end gap-4 rounded-md border border-solid border-border-negative-subtle bg-surface-feedback-subtle-negative px-4 py-3 mobile:flex-col mobile:items-start mobile:justify-start mobile:gap-3">
<div className="flex grow shrink-0 basis-0 flex-col items-start gap-1">
<span className="text-body-small-semibold-0 font-body-small-semibold-0 text-text-neutral-primary">{t("settings.profile.mfa.disable.title")}</span>
<span className="w-full text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">
<div className="mobile:pt-4 flex w-full flex-col items-start gap-3 px-4 pb-4">
<div className="border-border-negative-subtle bg-surface-feedback-subtle-negative mobile:flex-col mobile:items-start mobile:justify-start mobile:gap-3 flex w-full items-end justify-end gap-4 rounded-md border border-solid px-4 py-3">
<div className="flex shrink-0 grow basis-0 flex-col items-start gap-1">
<span className="text-body-small-semibold-0 font-body-small-semibold-0 text-text-neutral-primary">
{t("settings.profile.mfa.disable.title")}
</span>
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary w-full">
{t("settings.profile.mfa.manage.deactivateHint")}
</span>
</div>
@@ -643,15 +723,17 @@ function TwoFaModal({
</Button>
</div>
<div className="flex w-full flex-col items-start gap-1">
<span className="text-body-extra-small-semibold-150 font-body-extra-small-semibold-150 uppercase tracking-wider text-text-neutral-tertiary">
<span className="text-body-extra-small-semibold-150 font-body-extra-small-semibold-150 text-text-neutral-tertiary tracking-wider uppercase">
{t("settings.profile.mfa.manage.methodsLabel")}
</span>
<div className="flex w-full flex-col items-start rounded-md border border-solid border-border-default bg-surface-neutral-secondary">
<div className="flex w-full items-center gap-3 px-4 py-3 mobile:flex-col mobile:items-start">
<div className="border-border-default bg-surface-neutral-secondary flex w-full flex-col items-start rounded-md border border-solid">
<div className="mobile:flex-col mobile:items-start flex w-full items-center gap-3 px-4 py-3">
<IconWithBackground variant="neutral" size="large" icon={<FeatherSmartphone />} />
<div className="flex grow shrink-0 basis-0 flex-col items-start gap-1">
<div className="flex shrink-0 grow basis-0 flex-col items-start gap-1">
<div className="flex items-center gap-2">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{t("settings.profile.mfa.authenticatorApp")}</span>
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
{t("settings.profile.mfa.authenticatorApp")}
</span>
</div>
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">{activatedLabel}</span>
</div>
@@ -688,23 +770,29 @@ function TwoFaModal({
if (step === "success") {
return (
<ModalShell dataUiId="ui.settings.profile.mfa.success" center>
<FeatherCheckCircle className="text-[48px] font-[400] text-icon-feedback-positive" />
<ModalShell dataUiId="ui.settings.profile.mfa.success" center onClose={onClose}>
<FeatherCheckCircle className="text-icon-feedback-positive text-[48px] font-[400]" />
<div className="flex w-full flex-col items-center gap-2">
<span className="text-heading- font-heading- text-text-neutral-primary">{t("settings.profile.mfa.success.title")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{t("settings.profile.mfa.success.subtitle")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{t("settings.profile.mfa.success.subtitle")}
</span>
</div>
{recoveryCodes && recoveryCodes.length > 0 ? (
<div className="flex w-full flex-col items-start gap-2 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-2 rounded-md border border-solid px-4 py-4">
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-secondary">{t("settings.profile.mfa.recoveryCodes")}</span>
<div className="grid w-full grid-cols-2 gap-1">
{recoveryCodes.map((code) => (
<span key={code} className="font-mono text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-primary">{code}</span>
<span key={code} className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-primary font-mono">
{code}
</span>
))}
</div>
</div>
) : null}
<Button className="h-10 w-full flex-none" variant="primary" onClick={onClose} data-ui-id="ui.settings.profile.mfa.done">{t("settings.profile.mfa.success.done")}</Button>
<Button className="h-10 w-full flex-none" variant="primary" onClick={onClose} data-ui-id="ui.settings.profile.mfa.done">
{t("settings.profile.mfa.success.done")}
</Button>
</ModalShell>
);
}
@@ -713,22 +801,22 @@ function TwoFaModal({
// (Der Passwort-Gate-Step "password" läuft davor, da startTotpEnrollment das aktuelle Passwort verlangt.)
if (step === "qr") {
return (
<DialogOverlay dataUiId="ui.settings.profile.mfa.setup">
<DialogOverlay dataUiId="ui.settings.profile.mfa.setup" onClose={onClose}>
<Card
className="h-auto w-auto min-w-[384px] max-w-[576px] max-h-[90vh] overflow-auto mobile:w-full mobile:min-w-0 mobile:px-4 mobile:py-4 mobile:shadow-lg"
className="mobile:w-full mobile:min-w-0 mobile:px-4 mobile:py-4 mobile:shadow-lg h-auto max-h-[90vh] w-auto max-w-[576px] min-w-[384px] overflow-auto"
size="large"
>
<div className="flex w-full items-start justify-between">
<div className="flex grow shrink-0 basis-0 flex-col items-center gap-1">
<div className="flex shrink-0 grow basis-0 flex-col items-center gap-1">
<span className="text-heading- font-heading- text-text-neutral-primary text-center">{t("settings.profile.mfa.manage.addDevice")}</span>
<span className="w-full text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary text-center">
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary w-full text-center">
{t("settings.profile.mfa.add.subtitle")}
</span>
</div>
<IconButton variant="ghost" size="small" icon={<FeatherX />} onClick={onClose} data-ui-id="ui.settings.profile.mfa.setup.close" />
</div>
<div className="flex w-full flex-col items-center gap-2">
<div className="flex h-44 w-44 flex-none items-center justify-center rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-2 py-2">
<div className="border-border-default bg-surface-neutral-secondary flex h-44 w-44 flex-none items-center justify-center rounded-md border border-solid px-2 py-2">
{otpauthUri ? <QRCodeSVG className="h-40 w-40 flex-none" value={otpauthUri} size={160} /> : null}
</div>
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary text-center">
@@ -738,13 +826,21 @@ function TwoFaModal({
{secret ? (
<>
<div className="flex w-full items-center gap-2.5">
<div className="flex h-px grow shrink-0 basis-0 flex-col items-center bg-border-default" />
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">{t("settings.profile.mfa.setup.manualKey")}</span>
<div className="flex h-px grow shrink-0 basis-0 flex-col items-center bg-border-default" />
<div className="bg-border-default flex h-px shrink-0 grow basis-0 flex-col items-center" />
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">
{t("settings.profile.mfa.setup.manualKey")}
</span>
<div className="bg-border-default flex h-px shrink-0 grow basis-0 flex-col items-center" />
</div>
<div className="flex w-full items-center justify-between rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-1 py-1">
<span className="grow shrink-0 basis-0 text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary text-center">{groupedSecret}</span>
<CopyToClipboardButton clipboardText={secret} tooltipText={t("settings.profile.mfa.add.copyKey")} />
<div className="border-border-default bg-surface-neutral-secondary flex w-full items-center justify-between rounded-md border border-solid px-1 py-1">
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary shrink-0 grow basis-0 text-center">
{groupedSecret}
</span>
<CopyToClipboardButton
clipboardText={secret}
tooltipText={t("settings.profile.mfa.add.copyKey")}
successKey="settings.profile.mfa.add.keyCopied"
/>
</div>
</>
) : null}
@@ -753,7 +849,9 @@ function TwoFaModal({
<input type="hidden" name="action" value="confirmTotpEnrollment" readOnly />
<input type="hidden" name="code" value={code} readOnly />
<div className="flex w-full flex-col items-center gap-2">
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-secondary text-center">{t("settings.profile.mfa.add.codeLabel")}</span>
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-secondary text-center">
{t("settings.profile.mfa.add.codeLabel")}
</span>
<div className="flex w-full flex-col items-center gap-2 px-1 py-1">
<InputOtp state={mfaError ? "error" : "default"} title="" helperText={mfaError ?? ""}>
{Array.from({ length: 6 }).map((_, i) => (
@@ -771,7 +869,7 @@ function TwoFaModal({
</InputOtp>
</div>
</div>
<div className="flex w-full items-center justify-end gap-2 mobile:flex-col-reverse">
<div className="mobile:flex-col-reverse flex w-full items-center justify-end gap-2">
<Button type="button" className="mobile:w-full" variant="secondary" onClick={onClose} data-ui-id="ui.settings.profile.mfa.setup.cancel">
{t("shared.cancel")}
</Button>
@@ -796,38 +894,51 @@ function TwoFaModal({
// das bestehende disableTotpEnrollment verifiziert das Passwort -> Bestätigung bleibt Passwort-basiert.
if (step === "disable") {
return (
<DialogOverlay dataUiId="ui.settings.profile.mfa.disable">
<Card className="w-full max-w-[480px] max-h-[90vh] overflow-auto mobile:gap-6 mobile:px-4 mobile:py-5 mobile:shadow-lg">
<DialogOverlay dataUiId="ui.settings.profile.mfa.disable" onClose={onClose}>
<Card className="mobile:gap-6 mobile:px-4 mobile:py-5 mobile:shadow-lg max-h-[90vh] w-full max-w-[480px] overflow-auto">
<div className="flex w-full flex-col items-center justify-center gap-1">
<IconWithBackground variant="destructive" size="large" round={true} icon={<FeatherShieldOff />} />
<span className="w-full text-heading- font-heading- text-text-neutral-primary text-center">{t("settings.profile.mfa.deactivate.title")}</span>
<span className="w-full text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary text-center">
<span className="text-heading- font-heading- text-text-neutral-primary w-full text-center">{t("settings.profile.mfa.deactivate.title")}</span>
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary w-full text-center">
{t("settings.profile.mfa.deactivate.subtitle")}
</span>
</div>
<div className="flex w-full flex-col items-center justify-center gap-2 rounded-md border border-solid border-border-negative-subtle bg-surface-feedback-subtle-negative px-4 py-3">
<div className="border-border-negative-subtle bg-surface-feedback-subtle-negative flex w-full flex-col items-center justify-center gap-2 rounded-md border border-solid px-4 py-3">
<div className="flex w-full items-center justify-center gap-2">
<span className="grow shrink-0 basis-0 text-body-small-semibold-150 font-body-small-semibold-150 text-text-feedback-negative text-center">
<span className="text-body-small-semibold-150 font-body-small-semibold-150 text-text-feedback-negative shrink-0 grow basis-0 text-center">
{t("settings.profile.mfa.deactivate.consequencesTitle")}
</span>
</div>
<div className="flex w-full flex-col items-start gap-2">
<span className="w-full text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">{t("settings.profile.mfa.deactivate.consequence1")}</span>
<span className="w-full text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">{t("settings.profile.mfa.deactivate.consequence2")}</span>
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary w-full">
{t("settings.profile.mfa.deactivate.consequence1")}
</span>
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary w-full">
{t("settings.profile.mfa.deactivate.consequence2")}
</span>
</div>
</div>
<Form method="post" replace className="contents">
<input type="hidden" name="csrf" value={csrf} readOnly />
<input type="hidden" name="action" value="disableTotpEnrollment" readOnly />
<div className="flex w-full flex-col items-center justify-center gap-2">
<span className="text-body-small-medium-150 font-body-small-medium-150 text-text-neutral-secondary">{t("settings.profile.passwordDialog.current")}</span>
<span className="text-body-small-medium-150 font-body-small-medium-150 text-text-neutral-secondary">
{t("settings.profile.passwordDialog.current")}
</span>
<TextInput className="h-auto w-full flex-none" type="password">
<TextInput.Input name="passwordCurrent" type="password" required autoFocus autoComplete="current-password" data-ui-id="ui.settings.profile.mfa.disablePassword" />
<TextInput.Input
name="passwordCurrent"
type="password"
required
autoFocus
autoComplete="current-password"
data-ui-id="ui.settings.profile.mfa.disablePassword"
/>
</TextInput>
{mfaError ? <span className="text-body-small-regular-0 font-body-small-regular-0 text-text-feedback-negative">{mfaError}</span> : null}
</div>
<div className="flex h-px w-full flex-none flex-col items-center bg-border-default" />
<div className="flex w-full items-center justify-end gap-2 mobile:flex-col-reverse">
<div className="bg-border-default flex h-px w-full flex-none flex-col items-center" />
<div className="mobile:flex-col-reverse flex w-full items-center justify-end gap-2">
<Button type="button" className="mobile:w-full" variant="secondary" onClick={onClose} data-ui-id="ui.settings.profile.mfa.disableCancel">
{t("shared.cancel")}
</Button>
@@ -850,10 +961,12 @@ function TwoFaModal({
// step === "password" — Setup-Gate (Action verlangt aktuelles Passwort, bevor der QR erzeugt wird)
return (
<ModalShell dataUiId="ui.settings.profile.mfa.gate">
<ModalShell dataUiId="ui.settings.profile.mfa.gate" onClose={onClose}>
<div className="flex w-full flex-col items-start gap-2">
<span className="text-heading- font-heading- text-text-neutral-primary">{t("settings.profile.mfa.setup.title")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{t("settings.profile.mfa.gate.subtitle")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{t("settings.profile.mfa.gate.subtitle")}
</span>
</div>
<Form method="post" replace className="flex w-full flex-col items-start gap-4">
<input type="hidden" name="csrf" value={csrf} readOnly />
@@ -862,9 +975,13 @@ function TwoFaModal({
<TextInput.Input name="passwordCurrent" type="password" required autoComplete="current-password" data-ui-id="ui.settings.profile.mfa.gatePassword" />
</TextInput>
{mfaError ? <span className="text-body-small-regular-0 font-body-small-regular-0 text-text-feedback-negative">{mfaError}</span> : null}
<div className="flex w-full items-center justify-end gap-2 mobile:flex-col-reverse mobile:items-stretch">
<Button type="button" variant="tertiary" onClick={onClose}>{t("shared.cancel")}</Button>
<Button type="submit" variant="primary" loading={submitting} data-ui-id="ui.settings.profile.mfa.gateSubmit">{t("settings.profile.mfa.setup.next")}</Button>
<div className="mobile:flex-col-reverse mobile:items-stretch flex w-full items-center justify-end gap-2">
<Button type="button" variant="tertiary" onClick={onClose}>
{t("shared.cancel")}
</Button>
<Button type="submit" variant="primary" loading={submitting} data-ui-id="ui.settings.profile.mfa.gateSubmit">
{t("settings.profile.mfa.setup.next")}
</Button>
</div>
</Form>
</ModalShell>