import { formatNumber } from '@ringcentral-integration/commons/lib/formatNumber' ; import { isE164 , parseIncompletePhoneNumber , } from '@ringcentral-integration/phone-number' ; export const formatContactPhoneNumber = ( phoneNumber = '' , countryCode , isMultipleSiteEnabled , siteCode ? ) => { if ( ! phoneNumber ) { return phoneNumber ; } const cleanedNumber = parseIncompletePhoneNumber ( phoneNumber . toString ( ) ) ; const isE164Number = isE164 ( cleanedNumber ) ; if ( isE164Number ) { const formattedNumber = formatNumber ( { phoneNumber , countryCode , } ) ; return formattedNumber ; } if ( isMultipleSiteEnabled && siteCode ) { const formattedNumber = formatNumber ( { phoneNumber , countryCode , siteCode , isMultipleSiteEnabled , } ) ; return formattedNumber ; } return phoneNumber ; } ;