File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 1
1
import { getAuditLogs } from "api/api"
2
+ import { getErrorMessage } from "api/errors"
3
+ import { displayError } from "components/GlobalSnackbar/utils"
2
4
import { assign , createMachine } from "xstate"
3
5
4
6
type AuditLogs = Awaited < ReturnType < typeof getAuditLogs > >
@@ -24,18 +26,29 @@ export const auditMachine = createMachine(
24
26
target : "success" ,
25
27
actions : [ "assignAuditLogs" ] ,
26
28
} ,
29
+ onError : {
30
+ target : "error" ,
31
+ actions : [ "displayLoadAuditLogsError" ] ,
32
+ } ,
27
33
} ,
28
34
} ,
29
35
success : {
30
36
type : "final" ,
31
37
} ,
38
+ error : {
39
+ type : "final" ,
40
+ } ,
32
41
} ,
33
42
} ,
34
43
{
35
44
actions : {
36
45
assignAuditLogs : assign ( {
37
46
auditLogs : ( _ , event ) => event . data ,
38
47
} ) ,
48
+ displayLoadAuditLogsError : ( _ , event ) => {
49
+ const message = getErrorMessage ( event . data , "Error on loading audit logs." )
50
+ displayError ( message )
51
+ } ,
39
52
} ,
40
53
services : {
41
54
loadAuditLogs : ( ) => getAuditLogs ( ) ,
You can’t perform that action at this time.
0 commit comments