'use client' import { formatDistanceToNow } from 'date-fns' import { ShieldCheck } from 'lucide-react' import { useT } from '@open-mercato/shared/lib/i18n/context' import { Button } from '@open-mercato/ui/primitives/button' import type { MfaMethod } from '../types' type MfaMethodCardProps = { method: MfaMethod removing?: boolean onRemove: (method: MfaMethod) => void } function formatLastUsed(value: string | null, localeT: ReturnType): string { if (!value) { return localeT('security.profile.mfa.method.neverUsed', 'Never used') } const parsed = new Date(value) if (Number.isNaN(parsed.getTime())) { return localeT('security.profile.mfa.method.unknownTime', 'Unknown') } return formatDistanceToNow(parsed, { addSuffix: true }) } export default function MfaMethodCard({ method, removing = false, onRemove }: MfaMethodCardProps) { const t = useT() return (

{method.label ?? method.type}

{t('security.profile.mfa.method.type', 'Type')}: {method.type}

{t('security.profile.mfa.method.lastUsed', 'Last used')}: {formatLastUsed(method.lastUsedAt, t)}

) }