// AK-P21 Interim-UI (AD-28) — tenant deletion wizard as a REAL ~/ui Dialog // (size M 720) with a StepperHorizontal. Copy and structure adapted from // David's Subframe pages "S01 Settings Workspaces Loeschbereich" + // "M01 Loeschung anfragen" (WF-P2 Konto loeschen) and the re-auth step from // "M01 Identitaet bestaetigen" (WF-P2 Change Password). Steps: // explain (30d grace, read-only, hard delete) → export offer → billing note // (Lago/Mollie gateway wording, AD-27) → verify (password + optional TOTP) → // slug confirm phrase. Submits go through the injected onSubmit callback — // no fetching in here. Final Subframe optics = tracked design-nachzug. // // Interim simplification: the TOTP code uses a single TextInput instead of // the InputOtp compound; David's final D-P21 screens may swap it back. import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { FeatherCheck, FeatherDownload, FeatherInfo, FeatherSend, FeatherShieldCheck, FeatherTrash2 } from "@subframe/core"; import { Alert } from "~/ui/components/Alert"; import { Button } from "~/ui/components/Button"; import { Dialog } from "~/ui/components/Dialog"; import { StepperHorizontal } from "~/ui/components/StepperHorizontal"; import { TextArea } from "~/ui/components/TextArea"; import { TextInput } from "~/ui/components/TextInput"; export type TenantDeletionSubmitFields = { password: string; otpCode: string; slugConfirm: string; reasonText: string; }; export type TenantDeletionWizardDialogProps = { open: boolean; tenantSlug: string; graceDays: number; requiresOtp: boolean; submitting: boolean; errorKey?: string | null; onSubmit: (fields: TenantDeletionSubmitFields) => void; onOpenExport: () => void; onClose: () => void; }; const STEPS = ["explain", "export", "billing", "verify", "confirm"] as const; const bodyText = "text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary"; export function TenantDeletionWizardDialog(props: TenantDeletionWizardDialogProps) { const { open, tenantSlug, graceDays, requiresOtp, submitting, errorKey, onSubmit, onOpenExport, onClose } = props; const { t } = useTranslation(); const [step, setStep] = useState(0); const [password, setPassword] = useState(""); const [otpCode, setOtpCode] = useState(""); const [slugConfirm, setSlugConfirm] = useState(""); const [reasonText, setReasonText] = useState(""); useEffect(() => { if (open) { setStep(0); setPassword(""); setOtpCode(""); setSlugConfirm(""); setReasonText(""); } }, [open]); const verifyIncomplete = password.trim().length === 0 || (requiresOtp && otpCode.trim().length < 6); const slugMismatch = slugConfirm.length > 0 && slugConfirm !== tenantSlug; const confirmIncomplete = slugConfirm !== tenantSlug; function submit() { onSubmit({ password: password.trim(), otpCode: otpCode.trim(), slugConfirm, reasonText: reasonText.trim() }); } return ( (nextOpen ? undefined : onClose())}>
{t("settings.privacy.deletion.wizard.title")} {errorKey ? : null}
{STEPS.map((key, index) => ( ))} {step === 0 ? (
{t("settings.privacy.deletion.wizard.explain.body", { days: graceDays })}
{t("settings.privacy.deletion.wizard.explain.notImmediateTitle")}
{(["grace", "readOnly", "cancel"] as const).map((point) => (
{t(`settings.privacy.deletion.wizard.explain.point.${point}`, { days: graceDays })}
))}
) : null} {step === 1 ? (
{t("settings.privacy.deletion.wizard.export.title")} {t("settings.privacy.deletion.wizard.export.description")}
{t("settings.privacy.deletion.wizard.export.skipHint")}
) : null} {step === 2 ? (
{t("settings.privacy.deletion.wizard.billing.timing")}
) : null} {step === 3 ? (
{t("settings.privacy.deletion.wizard.verify.body")}
setPassword(event.target.value)} required data-wizard-field="password" /> {requiresOtp ? ( setOtpCode(event.target.value.replace(/\D/g, ""))} required data-wizard-field="otpCode" /> ) : null}
) : null} {step === 4 ? (
setSlugConfirm(event.target.value)} placeholder={tenantSlug} required data-wizard-field="slugConfirm" />
) : null}
{step > 0 ? ( ) : null} {step < STEPS.length - 1 ? ( ) : ( )}
); }