@@ -44,6 +44,7 @@ export interface UsersContext {
44
44
export type UsersEvent =
45
45
| { type : "GET_USERS" }
46
46
| { type : "CREATE" ; user : TypesGen . CreateUserRequest }
47
+ | { type : "CANCEL_CREATE_USER" }
47
48
// Suspend events
48
49
| { type : "SUSPEND_USER" ; userId : TypesGen . User [ "id" ] }
49
50
| { type : "CONFIRM_USER_SUSPENSION" }
@@ -86,6 +87,7 @@ export const usersMachine = createMachine(
86
87
on : {
87
88
GET_USERS : "gettingUsers" ,
88
89
CREATE : "creatingUser" ,
90
+ CANCEL_CREATE_USER : { actions : [ "clearCreateUserError" ] } ,
89
91
SUSPEND_USER : {
90
92
target : "confirmUserSuspension" ,
91
93
actions : [ "assignUserIdToSuspend" ] ,
@@ -120,12 +122,13 @@ export const usersMachine = createMachine(
120
122
tags : "loading" ,
121
123
} ,
122
124
creatingUser : {
125
+ entry : "clearCreateUserError" ,
123
126
invoke : {
124
127
src : "createUser" ,
125
128
id : "createUser" ,
126
129
onDone : {
127
130
target : "idle" ,
128
- actions : [ "displayCreateUserSuccess" , "redirectToUsersPage" , "clearCreateUserError" ] ,
131
+ actions : [ "displayCreateUserSuccess" , "redirectToUsersPage" ] ,
129
132
} ,
130
133
onError : [
131
134
{
@@ -283,7 +286,8 @@ export const usersMachine = createMachine(
283
286
} ) ,
284
287
clearCreateUserError : assign ( ( context : UsersContext ) => ( {
285
288
...context ,
286
- createUserError : undefined ,
289
+ createUserErrorMessage : undefined ,
290
+ createUserFormErrors : undefined ,
287
291
} ) ) ,
288
292
clearSuspendUserError : assign ( {
289
293
suspendUserError : ( _ ) => undefined ,
0 commit comments