File tree 2 files changed +6
-10
lines changed
2 files changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -61,12 +61,7 @@ export const mapApiErrorToFieldErrors = (
61
61
export const getErrorMessage = (
62
62
error : unknown ,
63
63
defaultMessage : string ,
64
- ) : string =>
65
- isApiError ( error )
66
- ? error . response . data . message
67
- : error instanceof Error
68
- ? error . message
69
- : defaultMessage ;
64
+ ) : string => ( isApiError ( error ) ? error . response . data . message : defaultMessage ) ;
70
65
71
66
/**
72
67
*
Original file line number Diff line number Diff line change 1
1
import { action } from "@storybook/addon-actions" ;
2
- import { MockAuthMethods } from "testHelpers/entities" ;
2
+ import { MockAuthMethods , mockApiError } from "testHelpers/entities" ;
3
3
import { LoginPageView } from "./LoginPageView" ;
4
4
import type { Meta , StoryObj } from "@storybook/react" ;
5
5
@@ -24,14 +24,15 @@ export const Example: Story = {
24
24
} ,
25
25
} ;
26
26
27
- const err = new Error ( "Username or email are wrong." ) ;
28
-
29
27
export const AuthError : Story = {
30
28
args : {
31
29
isLoading : false ,
32
30
onSignIn : action ( "onSignIn" ) ,
33
31
context : {
34
- error : err ,
32
+ error : mockApiError ( {
33
+ message : "User or password is incorrect" ,
34
+ detail : "Please, try again" ,
35
+ } ) ,
35
36
data : {
36
37
authMethods : MockAuthMethods ,
37
38
hasFirstUser : false ,
You can’t perform that action at this time.
0 commit comments