Files
TREK/client/src/mobile/screens/admin/MAdminResetMfaSheet.tsx
T
Maurice b7951baf23 fix(ci): green the dev gates after the native and popup rounds
- RTL: the measured pills and centred controls use logical forms or a marked line
- i18n: the two native widget numbers are positions, not counts (NOT_PLURAL)
- Types: styleOverride on the lazy GL map, the location and shared-file payloads,
  the capabilities fallback, the transport sheet's stay metadata
- ESLint: latest-value refs move to layout effects, usePresence keeps the last
  open state in state, the booking import opens clean with a shared document
  kept in the list (the reset effect used to clear it again)
- Layers: the phone import sheet lives under mobile/ and reads through tripRepo;
  the offline host check moves to utils/tileUrl
- Sizes: plugin layer geometry, hardNavigate and the exit animations get
  modules of their own
- Tests follow the status radios, the stay chip overview, the dock + button
  for the first list and the field token; store registry lists the new stores
2026-11-06 18:24:25 +01:00

64 lines
2.3 KiB
TypeScript

import { ShieldOff } from 'lucide-react';
import { useState } from 'react';
import type { TranslationFn } from '../../../types';
import MSheet from '../../components/MSheet';
import { MAdminButton, MAdminSheetFrame } from './MAdminUi';
interface MAdminResetMfaSheetProps {
open: boolean;
onClose: () => void;
user: { id: number; username: string } | null;
/** Resolves true once the reset worked; the sheet only closes then. */
onReset: (user: { id: number }) => Promise<boolean>;
t: TranslationFn;
}
// The confirm before an admin turns off another user's two-factor login. It
// keeps its own busy state so the admin sheet layer does not have to.
export default function MAdminResetMfaSheet({ open, onClose, user, onReset, t }: MAdminResetMfaSheetProps) {
const [resetting, setResetting] = useState(false);
// The sheet stays open and busy while the reset runs and closes once it worked.
const reset = async () => {
if (!user) return;
setResetting(true);
try {
if (await onReset(user)) onClose();
} finally {
setResetting(false);
}
};
return (
<MSheet open={open} onClose={onClose} ariaLabel={t('admin.mfa.reset')}>
<MAdminSheetFrame
icon={<ShieldOff size={19} strokeWidth={1.8} />}
title={t('admin.mfa.reset')}
onClose={onClose}
footer={
<>
<MAdminButton variant="ghost" disabled={resetting} onClick={onClose}>
{t('common.cancel')}
</MAdminButton>
<MAdminButton variant="danger" busy={resetting} onClick={() => void reset()}>
{t('admin.mfa.reset')}
</MAdminButton>
</>
}
>
<div className="flex gap-3">
<span className="flex h-10 w-10 flex-none items-center justify-center rounded-full bg-[color:color-mix(in_srgb,var(--m-st-danger)_12%,transparent)] text-[color:var(--m-st-danger)]">
<ShieldOff size={18} strokeWidth={2.2} />
</span>
<div className="min-w-0 flex-1">
<p className="text-body font-bold text-m-ink">
{t('admin.mfa.resetConfirm', { name: user?.username ?? '' })}
</p>
<p className="mt-1 font-geist text-caption leading-relaxed text-m-muted">{t('admin.mfa.resetHint')}</p>
</div>
</div>
</MAdminSheetFrame>
</MSheet>
);
}