11import { MfaFactor } from '@logto/schemas' ;
22import classNames from 'classnames' ;
33import { type TFuncKey } from 'i18next' ;
4+ import { useTranslation } from 'react-i18next' ;
45
56import ArrowNext from '@/assets/icons/arrow-next.svg?react' ;
67import FactorBackupCode from '@/assets/icons/factor-backup-code.svg?react' ;
@@ -56,8 +57,25 @@ const linkFactorDescription: Record<MfaFactor, TFuncKey> = {
5657} ;
5758
5859const MfaFactorButton = ( { factor, isBinding, isDisabled, maskedIdentifier, onClick } : Props ) => {
60+ const { t } = useTranslation ( ) ;
5961 const Icon = factorIcon [ factor ] ;
6062
63+ const getDescriptionForMaskedIdentifier = ( ) => {
64+ if ( ! maskedIdentifier ) {
65+ return null ;
66+ }
67+
68+ if ( factor === MfaFactor . EmailVerificationCode ) {
69+ return t ( 'mfa.send_to_email' , { identifier : maskedIdentifier } ) ;
70+ }
71+
72+ if ( factor === MfaFactor . PhoneVerificationCode ) {
73+ return t ( 'mfa.send_to_phone' , { identifier : maskedIdentifier } ) ;
74+ }
75+
76+ return maskedIdentifier ;
77+ } ;
78+
6179 return (
6280 < button
6381 className = { classNames (
@@ -78,7 +96,7 @@ const MfaFactorButton = ({ factor, isBinding, isDisabled, maskedIdentifier, onCl
7896 </ div >
7997 < div className = { mfaFactorButtonStyles . description } >
8098 { maskedIdentifier ? (
81- < span > { maskedIdentifier } </ span >
99+ < span > { getDescriptionForMaskedIdentifier ( ) } </ span >
82100 ) : (
83101 < DynamicT forKey = { ( isBinding ? linkFactorDescription : factorDescription ) [ factor ] } />
84102 ) }
0 commit comments