'use client' import * as React from 'react' import { formatDistanceToNow } from 'date-fns' import { Trash2 } from 'lucide-react' import { useT } from '@open-mercato/shared/lib/i18n/context' import { IconButton } from '@open-mercato/ui/primitives/icon-button' import type { MfaMethod } from '../types' type MfaProviderMethodListItemProps = { method: MfaMethod deleting?: boolean onDelete: (method: MfaMethod) => void } function formatLastUsed(value: string | null, t: ReturnType): string { if (!value) return t('security.profile.mfa.method.neverUsed', 'Never used') const parsed = new Date(value) if (Number.isNaN(parsed.getTime())) { return t('security.profile.mfa.method.unknownTime', 'Unknown') } return formatDistanceToNow(parsed, { addSuffix: true }) } export default function MfaProviderMethodListItem({ method, deleting = false, onDelete, }: MfaProviderMethodListItemProps) { 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)}

onDelete(method)} >
) }