0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-02-17 22:04:19 -05:00

fix(ui): format phone number in multiple places (#2918)

This commit is contained in:
simeng-li 2023-01-12 16:22:32 +08:00 committed by GitHub
parent 17266913df
commit d6aeaf9b0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

View file

@ -5,6 +5,7 @@ import { useNavigate } from 'react-router-dom';
import { useConfirmModal } from '@/hooks/use-confirm-modal';
import type { VerificationCodeIdentifier } from '@/types';
import { formatPhoneNumberWithCountryCallingCode } from '@/utils/country-code';
export enum IdentifierErrorType {
IdentifierNotExist = 'IdentifierNotExist',
@ -33,7 +34,10 @@ const useIdentifierErrorAlert = () => {
type: t(
`description.${identifierType === SignInIdentifier.Email ? 'email' : 'phone_number'}`
),
identifier,
identifier:
identifierType === SignInIdentifier.Email
? identifier
: formatPhoneNumberWithCountryCallingCode(identifier),
}
),
cancelText: 'action.got_it',

View file

@ -14,6 +14,7 @@ import { useConfirmModal } from '@/hooks/use-confirm-modal';
import useRequiredProfileErrorHandler from '@/hooks/use-required-profile-error-handler';
import { useSieMethods } from '@/hooks/use-sie';
import type { VerificationCodeIdentifier } from '@/types';
import { formatPhoneNumberWithCountryCallingCode } from '@/utils/country-code';
import useGeneralVerificationCodeErrorHandler from './use-general-verification-code-error-handler';
import useIdentifierErrorAlert, { IdentifierErrorType } from './use-identifier-error-alert';
@ -52,7 +53,10 @@ const useRegisterFlowCodeVerification = (
confirmText: 'action.sign_in',
ModalContent: t('description.create_account_id_exists', {
type: t(`description.${method === SignInIdentifier.Email ? 'email' : 'phone_number'}`),
value: target,
value:
method === SignInIdentifier.Email
? target
: formatPhoneNumberWithCountryCallingCode(target),
}),
});

View file

@ -16,6 +16,7 @@ import { useSieMethods } from '@/hooks/use-sie';
import type { VerificationCodeIdentifier } from '@/types';
import { SearchParameters } from '@/types';
import { getSearchParameters } from '@/utils';
import { formatPhoneNumberWithCountryCallingCode } from '@/utils/country-code';
import useGeneralVerificationCodeErrorHandler from './use-general-verification-code-error-handler';
import useIdentifierErrorAlert, { IdentifierErrorType } from './use-identifier-error-alert';
@ -57,7 +58,10 @@ const useSignInFlowCodeVerification = (
confirmText: 'action.create',
ModalContent: t('description.sign_in_id_does_not_exist', {
ype: t(`description.${method === SignInIdentifier.Email ? 'email' : 'phone_number'}`),
value: target,
value:
method === SignInIdentifier.Email
? target
: formatPhoneNumberWithCountryCallingCode(target),
}),
});