Skip to content

Instantly share code, notes, and snippets.

@davidlav
Last active January 31, 2020 22:58
Show Gist options
  • Save davidlav/24e7e532eda52e2448571b5fd0fa118c to your computer and use it in GitHub Desktop.
Save davidlav/24e7e532eda52e2448571b5fd0fa118c to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
Machine({
id: 'registrationStateMachine',
initial: 'newRegistrationForm',
context: {
certified: false,
},
states: {
newRegistrationForm: {
on: {
REGISTRATION_FORM_SUBMITTED: {
target: 'awaitingSponsorApproval',
actions: 'sendComplianceCertificationForm',
},
},
},
awaitingSponsorApproval: {
entry: 'emailSponsor',
on: {
SPONSOR_DISAPPROVES: {
target: 'newRegistrationCanceled',
},
SPONSOR_APPROVES: 'awaitingSysopsApproval',
},
},
awaitingSysopsApproval: {
entry: 'emailSysops',
on: {
SYSOPS_DISAPPROVES: {
target: 'newRegistrationCanceled',
},
SYSOPS_APPROVES: 'awaitingCertification',
},
},
awaitingCertification: {
on: {
'': {
target: 'generateIPAAccount',
cond: 'certified'
}
}
},
newRegistrationCanceled: {
type: 'final',
},
generateIPAAccount: {
type: 'final',
entry: [
'emailNewUserInfo',
'send2FASMS',
],
},
},
on: {
COMPLIANCE_CERTIFIED: {
actions: assign({
certified: ctx => ctx.certified = true
})
}
}
}, {
guards: {
certified: ctx => ctx.certified === true
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment