@@ -44,6 +44,7 @@ export interface UsersContext {
4444export type UsersEvent =
4545 | { type : "GET_USERS" }
4646 | { type : "CREATE" ; user : TypesGen . CreateUserRequest }
47+ | { type : "CANCEL_CREATE_USER" }
4748 // Suspend events
4849 | { type : "SUSPEND_USER" ; userId : TypesGen . User [ "id" ] }
4950 | { type : "CONFIRM_USER_SUSPENSION" }
@@ -86,6 +87,7 @@ export const usersMachine = createMachine(
8687 on : {
8788 GET_USERS : "gettingUsers" ,
8889 CREATE : "creatingUser" ,
90+ CANCEL_CREATE_USER : { actions : [ "clearCreateUserError" ] } ,
8991 SUSPEND_USER : {
9092 target : "confirmUserSuspension" ,
9193 actions : [ "assignUserIdToSuspend" ] ,
@@ -120,12 +122,13 @@ export const usersMachine = createMachine(
120122 tags : "loading" ,
121123 } ,
122124 creatingUser : {
125+ entry : "clearCreateUserError" ,
123126 invoke : {
124127 src : "createUser" ,
125128 id : "createUser" ,
126129 onDone : {
127130 target : "idle" ,
128- actions : [ "displayCreateUserSuccess" , "redirectToUsersPage" , "clearCreateUserError" ] ,
131+ actions : [ "displayCreateUserSuccess" , "redirectToUsersPage" ] ,
129132 } ,
130133 onError : [
131134 {
@@ -283,7 +286,8 @@ export const usersMachine = createMachine(
283286 } ) ,
284287 clearCreateUserError : assign ( ( context : UsersContext ) => ( {
285288 ...context ,
286- createUserError : undefined ,
289+ createUserErrorMessage : undefined ,
290+ createUserFormErrors : undefined ,
287291 } ) ) ,
288292 clearSuspendUserError : assign ( {
289293 suspendUserError : ( _ ) => undefined ,
0 commit comments