Last active
May 25, 2021 14:19
-
-
Save mergebandit/2070e85f609f6d434babaec4aaf04e9e 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const statusMachine = Machine( | |
{ | |
id: "status", | |
context: { | |
formCompletionState: { | |
picForm: true, | |
}, | |
pendingZdoEligibilityCheck: false, | |
onboardingGroup: "ZDO Merchant", | |
onboardingStatus: "REQUIRES_ATTENTION", | |
}, | |
type: "parallel", | |
states: { | |
apply: { | |
initial: "idle", | |
states: { | |
idle: { | |
after: { | |
"250": "done", | |
}, | |
}, | |
done: {}, | |
}, | |
}, | |
compliance: { | |
initial: "idle", | |
states: { | |
idle: { | |
after: { | |
"250": [ | |
{ | |
target: "reviewing", | |
cond: "inReview", | |
}, | |
{ | |
target: "requiresAttention", | |
cond: "requiresAttention", | |
}, | |
{ | |
target: "done", | |
cond: "readyToInstall", | |
}, | |
{ | |
target: "done", | |
cond: "complete", | |
}, | |
], | |
}, | |
}, | |
reviewing: {}, | |
requiresAttention: {}, | |
done: {}, | |
}, | |
}, | |
integration: { | |
initial: "idle", | |
states: { | |
idle: { | |
after: { | |
"250": [ | |
{ | |
target: "pendingZdoEligibility", | |
cond: "isZdoEligibilityInProgress", | |
}, | |
{ | |
target: "inProgress", | |
cond: "isZdoEligible", | |
}, | |
{ | |
target: "requiresAttention", | |
cond: "requiresAttention", | |
}, | |
{ | |
target: "inProgress", | |
cond: "readyToInstall", | |
}, | |
{ | |
target: "done", | |
cond: "complete", | |
}, | |
], | |
}, | |
}, | |
requiresAttention: {}, | |
pendingZdoEligibility: {}, | |
inProgress: {}, | |
done: {}, | |
}, | |
}, | |
messaging: { | |
id: "messaging", | |
initial: "idle", | |
states: { | |
idle: { | |
after: { | |
"250": [ | |
{ | |
target: "requiresAttention", | |
cond: "requiresAttention", | |
}, | |
{ | |
target: "inProgress", | |
cond: "complete", | |
}, | |
], | |
}, | |
}, | |
requiresAttention: {}, | |
inProgress: { | |
initial: "showMeHow", | |
states: { | |
showMeHow: { | |
on: { | |
DONE: "markAsDone", | |
}, | |
}, | |
markAsDone: { | |
on: { | |
DONE: { | |
target: ["#messaging.done", '#shopDirectory.inProgress'] | |
}, | |
}, | |
}, | |
}, | |
}, | |
done: { | |
}, | |
}, | |
}, | |
shopDirectory: { | |
id: 'shopDirectory', | |
initial: "idle", | |
states: { | |
idle: {}, | |
inProgress: { | |
on: { | |
DONE: 'done' | |
} | |
}, | |
done: {}, | |
}, | |
}, | |
}, | |
}, | |
{ | |
actions: { | |
setMessagingComplete: assign({ | |
messagingComplete: true, | |
}), | |
}, | |
guards: { | |
complete: ({ onboardingStatus }) => onboardingStatus === "COMPLETE", | |
inReview: ({ onboardingStatus }) => onboardingStatus === "IN_REVIEW", | |
isZdoEligibilityInProgress: ({ pendingZdoEligibilityCheck }) => | |
pendingZdoEligibilityCheck, | |
isZdoEligible: ({ onboardingGroup, onboardingStatus }) => | |
onboardingStatus === "IN_REVIEW" && | |
(onboardingGroup === "ZDO Merchant" || | |
onboardingGroup === "ZDO Pilot V1"), | |
picFormComplete: ({ formCompletionState }) => formCompletionState.picForm, | |
readyToInstall: ({ onboardingStatus }) => | |
onboardingStatus === "READY_TO_INSTALL", | |
requiresAttention: ({ onboardingStatus }) => | |
onboardingStatus === "REQUIRES_ATTENTION", | |
}, | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment