Skip to content

Commit ca22bef

Browse files
authored
Merge branch 'W-17458039-handle-error-states' into W-17271709-passwordless-login-in-checkout
2 parents 5f0c2da + ba3d8f4 commit ca22bef

File tree

8 files changed

+49
-10
lines changed

8 files changed

+49
-10
lines changed

packages/template-retail-react-app/app/constants.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ export const FEATURE_UNAVAILABLE_ERROR_MESSAGE = defineMessage({
9999
defaultMessage: 'This feature is not currently available.',
100100
id: 'global.error.feature_unavailable'
101101
})
102+
export const CREATE_ACCOUNT_FIRST_ERROR_MESSAGE = defineMessage({
103+
defaultMessage: 'This feature is not currently available. You must create an account to access this feature.',
104+
id: 'global.error.create_account'
105+
})
102106

103107
export const HOME_HREF = '/'
104108

@@ -255,7 +259,6 @@ export const PASSWORDLESS_LOGIN_LANDING_PATH = '/passwordless-login-landing'
255259

256260
export const PASSWORDLESS_ERROR_MESSAGES = [
257261
/callback_uri doesn't match/i,
258-
/error getting user info/i,
259262
/passwordless permissions error/i,
260263
/client secret is not provided/i,
261264
]

packages/template-retail-react-app/app/hooks/use-auth-modal.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import ResetPasswordForm from '@salesforce/retail-react-app/app/components/reset
3131
import RegisterForm from '@salesforce/retail-react-app/app/components/register'
3232
import PasswordlessEmailConfirmation from '@salesforce/retail-react-app/app/components/email-confirmation/index'
3333
import {noop} from '@salesforce/retail-react-app/app/utils/utils'
34-
import {API_ERROR_MESSAGE, FEATURE_UNAVAILABLE_ERROR_MESSAGE, LOGIN_TYPES, PASSWORDLESS_ERROR_MESSAGES} from '@salesforce/retail-react-app/app/constants'
34+
import {API_ERROR_MESSAGE, FEATURE_UNAVAILABLE_ERROR_MESSAGE, CREATE_ACCOUNT_FIRST_ERROR_MESSAGE, LOGIN_TYPES, PASSWORDLESS_ERROR_MESSAGES} from '@salesforce/retail-react-app/app/constants'
3535
import useNavigation from '@salesforce/retail-react-app/app/hooks/use-navigation'
3636
import {usePrevious} from '@salesforce/retail-react-app/app/hooks/use-previous'
3737
import {usePasswordReset} from '@salesforce/retail-react-app/app/hooks/use-password-reset'
@@ -105,9 +105,11 @@ export const AuthModal = ({
105105
}
106106
setCurrentView(EMAIL_VIEW)
107107
} catch (error) {
108-
const message = PASSWORDLESS_ERROR_MESSAGES.some(msg => msg.test(error.message))
109-
? formatMessage(FEATURE_UNAVAILABLE_ERROR_MESSAGE)
110-
: formatMessage(API_ERROR_MESSAGE)
108+
const message = /error getting user info/i.test(error.message)
109+
? formatMessage(CREATE_ACCOUNT_FIRST_ERROR_MESSAGE)
110+
: PASSWORDLESS_ERROR_MESSAGES.some(msg => msg.test(error.message))
111+
? formatMessage(FEATURE_UNAVAILABLE_ERROR_MESSAGE)
112+
: formatMessage(API_ERROR_MESSAGE)
111113
form.setError('global', { type: 'manual', message })
112114
}
113115
}

packages/template-retail-react-app/app/pages/login/index.jsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ import {
3131
FEATURE_UNAVAILABLE_ERROR_MESSAGE,
3232
LOGIN_TYPES,
3333
PASSWORDLESS_LOGIN_LANDING_PATH,
34-
PASSWORDLESS_ERROR_MESSAGES
34+
PASSWORDLESS_ERROR_MESSAGES,
35+
CREATE_ACCOUNT_FIRST_ERROR_MESSAGE
3536
} from '@salesforce/retail-react-app/app/constants'
3637
import {usePrevious} from '@salesforce/retail-react-app/app/hooks/use-previous'
3738
import {isServer} from '@salesforce/retail-react-app/app/utils/utils'
@@ -113,9 +114,11 @@ const Login = ({initialView = LOGIN_VIEW}) => {
113114
}
114115
setCurrentView(EMAIL_VIEW)
115116
} catch (error) {
116-
const message = PASSWORDLESS_ERROR_MESSAGES.some(msg => msg.test(error.message))
117-
? formatMessage(FEATURE_UNAVAILABLE_ERROR_MESSAGE)
118-
: formatMessage(API_ERROR_MESSAGE)
117+
const message = /error getting user info/i.test(error.message)
118+
? formatMessage(CREATE_ACCOUNT_FIRST_ERROR_MESSAGE)
119+
: PASSWORDLESS_ERROR_MESSAGES.some(msg => msg.test(error.message))
120+
? formatMessage(FEATURE_UNAVAILABLE_ERROR_MESSAGE)
121+
: formatMessage(API_ERROR_MESSAGE)
119122
form.setError('global', { type: 'manual', message })
120123
}
121124
}
@@ -133,7 +136,6 @@ const Login = ({initialView = LOGIN_VIEW}) => {
133136
}
134137
handleMergeBasket()
135138
} else if (loginType === LOGIN_TYPES.PASSWORDLESS) {
136-
setCurrentView(EMAIL_VIEW)
137139
setPasswordlessLoginEmail(data.email)
138140
await handlePasswordlessLogin(data.email)
139141
}

packages/template-retail-react-app/app/static/translations/compiled/en-GB.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,12 @@
15271527
"value": "Wishlist"
15281528
}
15291529
],
1530+
"global.error.create_account": [
1531+
{
1532+
"type": 0,
1533+
"value": "This feature is not currently available. You must create an account to access this feature."
1534+
}
1535+
],
15301536
"global.error.feature_unavailable": [
15311537
{
15321538
"type": 0,

packages/template-retail-react-app/app/static/translations/compiled/en-US.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,12 @@
15271527
"value": "Wishlist"
15281528
}
15291529
],
1530+
"global.error.create_account": [
1531+
{
1532+
"type": 0,
1533+
"value": "This feature is not currently available. You must create an account to access this feature."
1534+
}
1535+
],
15301536
"global.error.feature_unavailable": [
15311537
{
15321538
"type": 0,

packages/template-retail-react-app/app/static/translations/compiled/en-XA.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3199,6 +3199,20 @@
31993199
"value": "]"
32003200
}
32013201
],
3202+
"global.error.create_account": [
3203+
{
3204+
"type": 0,
3205+
"value": "["
3206+
},
3207+
{
3208+
"type": 0,
3209+
"value": "Ŧħīş ƒḗḗȧȧŧŭŭřḗḗ īş ƞǿǿŧ ƈŭŭřřḗḗƞŧŀẏ ȧȧṽȧȧīŀȧȧƀŀḗḗ. Ẏǿǿŭŭ ḿŭŭşŧ ƈřḗḗȧȧŧḗḗ ȧȧƞ ȧȧƈƈǿǿŭŭƞŧ ŧǿǿ ȧȧƈƈḗḗşş ŧħīş ƒḗḗȧȧŧŭŭřḗḗ."
3210+
},
3211+
{
3212+
"type": 0,
3213+
"value": "]"
3214+
}
3215+
],
32023216
"global.error.feature_unavailable": [
32033217
{
32043218
"type": 0,

packages/template-retail-react-app/translations/en-GB.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,9 @@
630630
"global.account.link.wishlist": {
631631
"defaultMessage": "Wishlist"
632632
},
633+
"global.error.create_account": {
634+
"defaultMessage": "This feature is not currently available. You must create an account to access this feature."
635+
},
633636
"global.error.feature_unavailable": {
634637
"defaultMessage": "This feature is not currently available."
635638
},

packages/template-retail-react-app/translations/en-US.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,9 @@
630630
"global.account.link.wishlist": {
631631
"defaultMessage": "Wishlist"
632632
},
633+
"global.error.create_account": {
634+
"defaultMessage": "This feature is not currently available. You must create an account to access this feature."
635+
},
633636
"global.error.feature_unavailable": {
634637
"defaultMessage": "This feature is not currently available."
635638
},

0 commit comments

Comments
 (0)