Skip to content

Instantly share code, notes, and snippets.

@hosmelq
Last active April 17, 2020 23:34
Show Gist options
  • Save hosmelq/35aa7097f368ad8926761f5b3a944026 to your computer and use it in GitHub Desktop.
Save hosmelq/35aa7097f368ad8926761f5b3a944026 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const CourierOnboardingVerificationsItemState = {
IN_REVISION: `IN_REVISION`,
PENDING: `PENDING`,
VERIFIED: `VERIFIED`,
}
Machine(
{
id: `emergencyContact`,
initial: `unknown`,
context: {
message: null,
state: `PENDING`,
},
states: {
unknown: {
on: {
'': [
{cond: `isPending`, target: `pending`},
{cond: `isVerified`, target: `verified`},
],
},
},
pending: {
on: {
SUBMIT: `submitting`,
},
},
submitting: {
invoke: {
id: `update-information`,
src: `updateInformation`,
onDone: `verified`,
onError: {
target: `pending`,
actions: `handleGraphQLErrors`,
},
},
},
verified: {
entry: `updateInformationSuccess`,
type: `final`,
},
},
},
{
guards: {
isPending: (ctx) => {
return ctx.state === CourierOnboardingVerificationsItemState.PENDING
},
isVerified: (ctx) => {
return ctx.state === CourierOnboardingVerificationsItemState.VERIFIED
},
},
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment