Skip to content

Instantly share code, notes, and snippets.

@pjcras
Last active January 23, 2020 23:04
Show Gist options
  • Save pjcras/22eaa1d1738ef33cfd7d667d422fde51 to your computer and use it in GitHub Desktop.
Save pjcras/22eaa1d1738ef33cfd7d667d422fde51 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const newHereStartProjectFlow = {
initial: "whatToDo",
states: {
whatToDo: {
on: {
NEXT: "selectType"
}
},
selectType: {
on: {
SELECTED: "viewChecklist",
CANCEL: "selectType"
}
},
viewChecklist: {
on: {
NEXT: "basicProjectInfo",
CANCEL: "selectType"
}
},
basicProjectInfo: {
on: {
NEXT: "addUserPermission"
}
},
addUserPermission: {
on: {
HELP_ME: "showHelpVideo",
I_KNOW: "projectDetails"
}
},
showHelpVideo: {
on: {
NEXT: "projectDetails"
}
},
projectDetails: {
on: {
NEXT: "successConfirmation"
}
},
successConfirmation:{}
},
on:{
NEXT:'deviceSetup'
}
}
const deviceSetupFlow = {
initial: 'downloadImagePage',
states: {
downloadImagePage :{}
},
on: {
NEXT : 'connectDevice'
}
}
const connectDeviceFlow = {
initial: 'diagramToConnectPI',
states: {
diagramToConnectPI : {
on : {
NEXT : 'diagramToSetupSensor'
}
},
diagramToSetupSensor : {},
},
on: {
NEXT : 'activateDevice'
}
}
const activateDeviceFlow = {
initial: 'enterActivationCode',
states: {
enterActivationCode : {
on : {
NEXT : 'confirmation'
}
},
confirmation : {}
},
on: {
DONE : 'welcome',
ADD_MORE : 'connectDevice.diagramToConnectPI'
}
}
const wizardMachine = Machine({
key: "wizard",
initial: "welcome",
states: {
welcome: {
on: {
NEW_HERE: "newHereStartProject",
START: "newHereStartProject.projectDetails"
}
},
newHereStartProject: {
...newHereStartProjectFlow
}
,
deviceSetup: {
...deviceSetupFlow
},
connectDevice: {
...connectDeviceFlow
},
activateDevice: {
...activateDeviceFlow
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment