Skip to content

Commit 7f2c142

Browse files
committed
move user not found to constants
1 parent 30ea366 commit 7f2c142

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,5 @@ export const PASSWORDLESS_ERROR_MESSAGES = [
265265
]
266266

267267
export const INVALID_TOKEN_ERROR = /invalid token/i
268+
269+
export const USER_NOT_FOUND_ERROR = /user not found/i

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ import PasswordlessEmailConfirmation from '@salesforce/retail-react-app/app/comp
3333
import {noop} from '@salesforce/retail-react-app/app/utils/utils'
3434
import {
3535
API_ERROR_MESSAGE,
36-
FEATURE_UNAVAILABLE_ERROR_MESSAGE,
3736
CREATE_ACCOUNT_FIRST_ERROR_MESSAGE,
37+
FEATURE_UNAVAILABLE_ERROR_MESSAGE,
3838
LOGIN_TYPES,
39-
PASSWORDLESS_ERROR_MESSAGES
39+
PASSWORDLESS_ERROR_MESSAGES,
40+
USER_NOT_FOUND_ERROR
4041
} from '@salesforce/retail-react-app/app/constants'
4142
import useNavigation from '@salesforce/retail-react-app/app/hooks/use-navigation'
4243
import {usePrevious} from '@salesforce/retail-react-app/app/hooks/use-previous'
@@ -106,7 +107,7 @@ export const AuthModal = ({
106107
await authorizePasswordlessLogin.mutateAsync({userid: email})
107108
setCurrentView(EMAIL_VIEW)
108109
} catch (error) {
109-
const message = /user not found/i.test(error.message)
110+
const message = USER_NOT_FOUND_ERROR.test(error.message)
110111
? formatMessage(CREATE_ACCOUNT_FIRST_ERROR_MESSAGE)
111112
: PASSWORDLESS_ERROR_MESSAGES.some((msg) => msg.test(error.message))
112113
? formatMessage(FEATURE_UNAVAILABLE_ERROR_MESSAGE)

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ import LoginForm from '@salesforce/retail-react-app/app/components/login'
2727
import PasswordlessEmailConfirmation from '@salesforce/retail-react-app/app/components/email-confirmation/index'
2828
import {
2929
API_ERROR_MESSAGE,
30+
CREATE_ACCOUNT_FIRST_ERROR_MESSAGE,
3031
INVALID_TOKEN_ERROR,
3132
INVALID_TOKEN_ERROR_MESSAGE,
3233
FEATURE_UNAVAILABLE_ERROR_MESSAGE,
3334
LOGIN_TYPES,
3435
PASSWORDLESS_LOGIN_LANDING_PATH,
3536
PASSWORDLESS_ERROR_MESSAGES,
36-
CREATE_ACCOUNT_FIRST_ERROR_MESSAGE
37+
USER_NOT_FOUND_ERROR
3738
} from '@salesforce/retail-react-app/app/constants'
3839
import {usePrevious} from '@salesforce/retail-react-app/app/hooks/use-previous'
3940
import {isServer} from '@salesforce/retail-react-app/app/utils/utils'
@@ -111,7 +112,7 @@ const Login = ({initialView = LOGIN_VIEW}) => {
111112
await authorizePasswordlessLogin.mutateAsync({userid: email})
112113
setCurrentView(EMAIL_VIEW)
113114
} catch (error) {
114-
const message = /user not found/i.test(error.message)
115+
const message = USER_NOT_FOUND_ERROR.test(error.message)
115116
? formatMessage(CREATE_ACCOUNT_FIRST_ERROR_MESSAGE)
116117
: PASSWORDLESS_ERROR_MESSAGES.some((msg) => msg.test(error.message))
117118
? formatMessage(FEATURE_UNAVAILABLE_ERROR_MESSAGE)

0 commit comments

Comments
 (0)