Last active
July 28, 2021 07:34
-
-
Save tmbtech/59fee9e84e2f8bab21a526a0cc08da1a 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 fetchMachine = Machine( | |
{ | |
id: 'isi-builder', | |
initial: 'start', | |
context: { | |
brands: ['botox', 'kybella'], | |
}, | |
states: { | |
start: { | |
on: { | |
'': [ | |
{ target: 'containsBotox', cond: 'containsBotox' }, | |
{ | |
target: 'singleSafetyAndPrescribingInfo', | |
cond: 'hasKybellaOrLatisse', | |
}, | |
{ target: 'importantSafetyInformationOnly' }, | |
], | |
}, | |
}, | |
containsBotox: { | |
on: { | |
'': [ | |
{ target: 'botoxOnly', cond: 'hasOnlyOneCondition' }, | |
{ | |
target: 'botoxSafetyAndPrescribingInfo', | |
cond: 'hasKybellaOrLatisse', | |
}, | |
{ target: 'botoxOnlyImportantSafetyInformationOnly' }, | |
], | |
}, | |
}, | |
singleSafetyAndPrescribingInfo: {}, | |
importantSafetyInformationOnly: {}, | |
doesNotContainBotox: {}, | |
hasOnlyOneCondition: {}, | |
botoxOnly: {}, | |
botoxSafetyAndPrescribingInfo: {}, | |
botoxOnlyImportantSafetyInformationOnly:{} | |
}, | |
}, | |
{ | |
guards: { | |
doesNotContainBotox: (context) => { | |
return !context.brands.includes('botox'); | |
}, | |
containsBotox: (context) => { | |
return context.brands.includes('botox'); | |
}, | |
hasOnlyOneCondition: (context) => { | |
return context.brands.length === 1; | |
}, | |
hasKybellaOrLatisse: (context) => { | |
return context.brands.some( | |
(brand) => brand === 'kybella' || brand === 'latisse' | |
); | |
}, | |
}, | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment