Skip to content

Instantly share code, notes, and snippets.

@BurningDog

BurningDog/machine.js

Last active Jul 13, 2020
Embed
What would you like to do?
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const fetchMachine = Machine({
id: "Say Thanks",
states: {
"View message": {
id: "View message",
states: {},
on: {
"Customer app link": "#Voucher logic",
"SMS link": "#Voucher logic",
},
},
"Voucher logic": {
id: "Voucher logic",
states: {
"Has this voucher been claimed before?": {
id: "Has this voucher been claimed before?",
states: {},
on: {
No: "#Is this a single product voucher?",
Yes: "#View used voucher",
},
},
"View used voucher": {
id: "View used voucher",
states: {},
},
"Is this a single product voucher?": {
id: "Is this a single product voucher?",
states: {},
on: {
No: "#Multiple product voucher",
Yes: "#Redeem",
},
},
},
initial: "Has this voucher been claimed before?",
on: {},
},
"Multiple product voucher": {
id: "Multiple product voucher",
states: {
"View category": {
id: "View category",
states: {},
on: {
"TV & Media": "#View product",
"Transport & Travel": "#View product",
help: "#Reward help",
},
},
"View product": {
id: "View product",
states: {},
on: {
"3 month subscription - R400": "#View selected product",
"Go back": "#View category",
"R200 voucher": "#View selected product",
help: "#Product help",
},
},
Help: {
id: "Help",
states: {
"Reward help": {
id: "Reward help",
states: {},
on: {
"Go back": "#View category",
},
},
"Product help": {
id: "Product help",
states: {},
on: {
"Go back": "#View product",
},
},
},
initial: "Reward help",
on: {},
},
},
initial: "View category",
on: {},
},
Redeem: {
id: "Redeem",
states: {
"View selected product": {
id: "View selected product",
states: {},
on: {
"Go back multiple product": "#View product",
Redeem: "#Confirm product",
},
},
"Confirm product": {
id: "Confirm product",
states: {},
on: {
Confirm: "#Voucher code",
"Go back": "#View selected product",
},
},
},
initial: "View selected product",
on: {},
},
Voucher: {
id: "Voucher",
states: {
"Voucher code": {
id: "Voucher code",
states: {},
on: {
"Email me this voucher": "#Enter email",
},
},
"Enter email": {
id: "Enter email",
states: {},
on: {
"Go back": "#Voucher code",
Send: "#View confirmation",
},
},
"View confirmation": {
id: "View confirmation",
states: {},
},
},
initial: "Voucher code",
on: {},
},
},
initial: "View message",
on: {},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.