Last active
June 24, 2021 18:03
-
-
Save wlee221/3fb1458b6f466ef5fd6300e2e619831b to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Machine( | |
{ | |
id: 'signUp', | |
initial: "edit", | |
exit: ["clearFormValues", "clearError"], | |
states: { | |
edit: { | |
id: "edit", | |
initial: "noError", | |
type: "parallel", | |
states: { | |
authError: { | |
initial: "none", | |
states: { | |
none: {}, | |
error: {}, | |
}, | |
}, | |
validationError: { | |
initial: "none", | |
states: { | |
none: {}, | |
error: {}, | |
}, | |
on: { | |
INPUT: [ | |
{ | |
actions: ["handleInput", "clearPwMismatchError"], | |
cond: "pwMatches", | |
target: ".none", | |
}, | |
{ | |
actions: ["handleInput", "setPwMismatchError"], | |
target: ".error", | |
}, | |
], | |
}, | |
}, | |
}, | |
on: { | |
SUBMIT: { | |
target: "submit", | |
in: { | |
edit: { | |
validationError: "none", | |
}, | |
}, | |
}, | |
}, | |
}, | |
submit: { | |
entry: "clearError", | |
invoke: { | |
src: "signUp", | |
onDone: { | |
actions: "setUser", | |
target: "resolved", | |
}, | |
onError: { | |
actions: "setCognitoError", | |
target: "edit.authError.error", | |
}, | |
}, | |
}, | |
resolved: { | |
type: "final", | |
}, | |
}, | |
}, | |
{ | |
guards: { | |
pwMatches: (context, event) => { | |
return false; | |
}, | |
}, | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment