Last active
April 17, 2020 23:34
-
-
Save hosmelq/35aa7097f368ad8926761f5b3a944026 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
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