Skip to content

Instantly share code, notes, and snippets.

@scottmessinger
Last active December 3, 2020 18:09
Show Gist options
  • Save scottmessinger/ab05c8ab1d178e2f60a98cb039c0890e to your computer and use it in GitHub Desktop.
Save scottmessinger/ab05c8ab1d178e2f60a98cb039c0890e to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const hasAccount = () => {}
const doesNotHaveAccount = () => {}
const fetchMachine = Machine({
id: "signFlow",
initial: "signs",
states: {
transitionToUserPage: { done: true },
signs: {
type: "parallel",
states: {
screen: {
id: "screen",
initial: "justEmail",
states: {
justEmail: {
on: {
SUBMIT: { target: ".checkingEmail" },
},
initial: "dataEntry",
states: {
dataEntry: {},
checkingEmail: {
onEntry: ["checkEmail"],
on: {
SUCCESS: "#screen.signIn",
ERROR: "#screen.signUp",
},
},
},
},
signIn: {
on: {
SUBMIT: { target: ".submitting" },
},
initial: "dataEntry",
states: {
dataEntry: {},
submitting: {
onEntry: ["signIn"],
on: {
SUCCESS: "#signFlow.transitionToUserPage",
ERROR: "dataEntry",
},
},
},
},
signUp: {
on: {
SUBMIT: { target: ".submitting" },
},
initial: "dataEntry",
states: {
dataEntry: {},
submitting: {
onEntry: ["signUp"],
on: {
SUCCESS: "#signFlow.accountInfo",
ERROR: "dataEntry",
},
},
},
},
},
},
email: {
initial: "initial",
states: {
initial: {},
isValid: {},
isFocused: {},
isInvalid: {},
},
},
password: {
initial: "initial",
states: {
initial: {},
doesNotMatch: {},
},
},
genericError: {
initial: "none",
states: {
none: {},
present: {},
},
},
isSigningIn: {
initial: "nope",
states: {
nope: {},
yes: {},
},
},
},
},
accountInfo: {
type: "parallel",
states: {
salutation: {
},
firstName: {},
lastName: {},
role: {},
screens: {
initial: "dataEntry",
states: {
dataEntry: {
on: {
SUBMIT: "submitting",
},
},
submitting: {
onEntry: ["updateAccount"],
on: {
SUCCESS: [
{
target: "#signFlow.transitionToPlanbookPage",
cond: "shouldGoStraightToPlanbook"
},
{
target: "#signFlow.transitionToGroupPage",
cond: "shouldGoStraightToGroup"
},
{
target: "#signFlow.planbookInfo"
}
],
ERROR: "dataEntry",
},
},
},
},
},
on: {
SUBMIT: {
target: "planbookInfo",
},
},
},
planbookInfo: {
on: {
SUBMIT: {
target: "planbookEntry",
},
},
},
planbookEntry: {
on: {
SUBMIT: {
target: "transitionToPlanbookPage",
},
},
},
transitionToPlanbookPage: { done: true },
transitionToGroupPage: { done: true },
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment