11import React from 'react'
2- import { useSelector } from 'react-redux'
32
3+ import { useTheme } from '@mui/material'
44import InputAdornment from '@mui/material/InputAdornment'
55import Stack from '@mui/material/Stack'
66import Button from '@mui/material/Button'
77import { Text } from '@mxenabled/mxui'
88import { Link } from '@mui/material'
99
10- import { RootState } from 'src/redux/Store'
1110import { __ } from 'src/utilities/Intl'
11+ import useAnalyticsPath from 'src/hooks/useAnalyticsPath'
1212import { TextField } from 'src/privacy/input'
13+ import { PageviewInfo } from 'src/const/Analytics'
1314import styles from './returnUserExperience.module.css'
1415
1516export const RuxPhoneNumber = ( {
@@ -19,21 +20,27 @@ export const RuxPhoneNumber = ({
1920 userEnteredPhone : string
2021 setUserEnteredPhone : ( phone : string ) => void
2122} ) => {
22- const appName = useSelector (
23- ( state : RootState ) => state . profiles . client . oauth_app_name || 'This app' ,
24- )
23+ useAnalyticsPath ( ...PageviewInfo . CONNECT_RUX_PHONE_NUMBER )
24+ const { palette } = useTheme ( )
2525
2626 return (
2727 < >
2828 < Stack className = { styles . titleContainer } spacing = "6px" >
2929 < Text bold = { true } className = { styles . centerText } truncate = { false } variant = "h2" >
30- { __ ( 'Connect your accounts ' ) }
30+ { __ ( 'Connect faster with your phone number ' ) }
3131 </ Text >
3232 < Text className = { styles . centerText } truncate = { false } variant = "subtitle1" >
33- { __ ( '%1 uses MX to connect your accounts.' , appName ) }
33+ { __ ( 'Login or sign up with MX to securely access your saved accounts. ' ) }
3434 < Link
35+ className = { styles . primaryLink }
3536 href = "https://mx.com/learn-more"
36- sx = { { color : 'tokens.TextColor.ButtonLink' , marginLeft : 0 } }
37+ sx = { {
38+ color : palette . primary . main ,
39+ fontWeight : 'normal' ,
40+ marginLeft : 0 ,
41+ textDecoration : 'underline' ,
42+ } }
43+ target = "_blank"
3744 underline = "always"
3845 variant = "subtitle1"
3946 >
@@ -46,34 +53,58 @@ export const RuxPhoneNumber = ({
4653 InputProps = { {
4754 startAdornment : (
4855 < InputAdornment position = "start" >
49- < div >
50- < Text variant = "body1" > Phone</ Text >
51- < Text bold = { true } variant = "h2" >
56+ < div style = { { display : 'flex' , alignItems : 'center' } } >
57+ < Text style = { { paddingLeft : '10px' , paddingRight : '16px' } } variant = "body1" >
58+ Phone
59+ </ Text >
60+ < Text sx = { { fontWeight : 400 } } variant = "h2" >
5261 +1
5362 </ Text >
5463 </ div >
5564 </ InputAdornment >
5665 ) ,
66+ style : {
67+ paddingRight : '14px' ,
68+ margin : '40px 0' ,
69+ fontSize : '23px' ,
70+ fontWeight : '400' ,
71+ height : 'auto' ,
72+ maxHeight : '60px' ,
73+ } ,
5774 } }
58- onChange = { ( e : React . ChangeEvent < HTMLInputElement > ) => setUserEnteredPhone ( e . target . value ) }
75+ fullWidth = { true }
76+ name = "phoneNumber"
77+ onChange = { ( e : React . ChangeEvent < HTMLInputElement > ) =>
78+ setUserEnteredPhone ( e . target . value . replace ( / \D / g, '' ) . slice ( 0 , 10 ) )
79+ }
5980 required = { true }
60- value = { userEnteredPhone }
81+ value = { formatPhone ( userEnteredPhone ) }
6182 />
6283
63- < Stack className = { styles . buttonContainer } spacing = "8px" >
64- < Text variant = "caption" >
84+ < Stack spacing = "8px" >
85+ < Text truncate = { false } variant = "caption" >
6586 { /* --TR: Full string 'By selecting "Get code", you agree to MX's Terms & Conditions' */ }
66- { __ ( 'By selecting "Get code", you agree to' ) }
67- < Link href = "https://www.mx.com/terms/" variant = "caption" >
87+ { __ ( 'By selecting "Continue", you agree to ' ) }
88+ < Link
89+ href = "https://www.mx.com/terms/"
90+ sx = { {
91+ fontWeight : 'normal' ,
92+ marginLeft : 0 ,
93+ marginRight : 0 ,
94+ textDecoration : 'underline' ,
95+ } }
96+ target = "_blank"
97+ underline = "always"
98+ variant = "caption"
99+ >
68100 { /* TODO: Do we translate this below? */ }
69101 { __ ( "MX's Terms & Conditions" ) }
70102 </ Link >
71- .
72103 </ Text >
73- < Button fullWidth = { true } onClick = { ( ) => { } } >
104+ < Button onClick = { ( ) => { } } variant = "contained" >
74105 { __ ( 'Continue' ) }
75106 </ Button >
76- < Button fullWidth = { true } onClick = { ( ) => { } } variant = "outlined " >
107+ < Button onClick = { ( ) => { } } variant = "text " >
77108 { __ ( 'Continue without phone number' ) }
78109 </ Button >
79110 </ Stack >
@@ -82,3 +113,12 @@ export const RuxPhoneNumber = ({
82113}
83114
84115export default RuxPhoneNumber
116+
117+ const formatPhone = ( value : string ) => {
118+ const digits = value . replace ( / \D / g, '' ) . slice ( 0 , 10 )
119+
120+ if ( digits . length === 0 ) return digits
121+ if ( digits . length <= 3 ) return `(${ digits } `
122+ if ( digits . length <= 6 ) return `(${ digits . slice ( 0 , 3 ) } ) ${ digits . slice ( 3 ) } `
123+ return `(${ digits . slice ( 0 , 3 ) } ) ${ digits . slice ( 3 , 6 ) } - ${ digits . slice ( 6 ) } `
124+ }
0 commit comments