Last active
November 6, 2019 14:30
-
-
Save 11111000000/a50c251fbaff3529c66bd157ff08cdd0 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 fetchMachine = Machine({ | |
id: 'sliza', | |
type: 'parallel', | |
initial: 'closed', | |
context: { | |
auth: true, | |
error: false, | |
mlm: false, | |
attributes: { | |
'site_mlm': false | |
} | |
}, | |
states: { | |
bar: { | |
initial: 'closed', | |
states: { | |
opened: { | |
'SLIZA.ACCOUNT_BAR.HIDE': 'closed' | |
}, | |
closed: { | |
'SLIZA.ACCOUNT_BAR.SHOW': 'opened' | |
} | |
} | |
}, | |
window: { | |
initial: 'closed', | |
states: { | |
opened: { | |
'SLIZA.WIDGET.CLOSE': 'closed' | |
}, | |
closed: { | |
'SLIZA.WIDGET.OPEN': 'opened' | |
} | |
} | |
}, | |
auth: { | |
initial: 'unauthorized', | |
states: { | |
authorized: { | |
'SLIZA.AUTH.LOGOUT': 'unauthorized' | |
}, | |
unauthorized: { | |
on: { | |
'SLIZA.AUTH.COMPLETE': { target: 'authorized'}, | |
'SLIZA.AUTH.FAIL': { actions: assign({ error: (context, action) => action.error })} | |
} | |
} | |
} | |
}, | |
widget: { | |
initial: 'idle', | |
states: { | |
idle: { | |
on: { | |
'SLIZA.WIDGET.OPEN': [ | |
{ cond: (context, event) => (context.error == 'siteNotInCatalogue'), target: 'site_not_in_catalogue' }, | |
{ cond: (context, event) => (context.error == 'siteNotPayed'), target: 'site_not_payed' }, | |
{ cond: (context, event) => (!context.auth), target: 'auth' }, | |
{ cond: (context, event) => (context.attributes.teaser), target: 'teaser' }, | |
{ cond: (context, event) => (context.attributes.site_mlm), target: 'show_start', actions: assign({ mlm: true }) }, | |
{ cond: (context, event) => (context.type == 'pro'), target: 'show_start' }, | |
{ cond: (context, event) => (context.type == 'none'), target: 'show_soon' }, | |
{ cond: (context, event) => true, target: 'show_start' } | |
] | |
} | |
}, | |
auth: { | |
}, | |
auth_failed: { | |
}, | |
site_unknown: { | |
}, | |
site_not_in_catalogue: { | |
}, | |
teaser: { | |
on: { | |
'SLIZA.WIDGET.APPLY': 'onboarding' | |
} | |
}, | |
no_goods: { | |
on: { | |
'SLIZA.WIDGET.RESTART': 'show_start' | |
} | |
}, | |
onboarding: { | |
on: { | |
'SLIZA.WIDGET.APPLY': 'show_start' | |
} | |
}, | |
site_under_development: { | |
on: { | |
} | |
}, | |
template_not_payed: { | |
on: { | |
} | |
}, | |
show_soon: { | |
on: { | |
'SLIZA.WIDGET.APPLY': 'onboarding' | |
} | |
}, | |
show_start: { | |
on: { | |
'SLIZA.WIDGET.STEP1.START': 'start_loading' | |
} | |
}, | |
start_loading: { | |
on: { | |
'SLIZA.WIDGET.LOADING.FINISHED': 'step2', | |
'SLIZA.WIDGET.LOADING.FAILED': 'loading_error' | |
} | |
}, | |
loading_error: { | |
on: { | |
} | |
}, | |
step2: { | |
on: { | |
'SLIZA.WIDGET.STEP2.START': 'step3', | |
'SLIZA.WIDGET.STEP2.NO_PRODUCTS': 'step2_no_products', | |
'SLIZA.TECH_ERROR': [{cond: (context => !!context.debug), target: 'tech_error_with_debug'}, | |
{cond: (context => !context.debug), target: 'tech_error'}] | |
} | |
}, | |
step2_no_products: { | |
on: { | |
'SLIZA.WIDGET.BACK_TO_STEP2': 'step2' | |
} | |
}, | |
step3: { | |
on: { | |
'SLIZA.WIDGET.STEP3.SAVE': 'save_upload', | |
'SLIZA.WIDGET.STEP3.BACK': 'step2', | |
} | |
}, | |
tech_error: { | |
}, | |
tech_error_with_debug: { | |
}, | |
// step2_no_products: { | |
// 'SLIZA.WIDGET.CLOSE': 'closed' | |
// }, | |
save_upload: { | |
on: { | |
'SLIZA.WIDGET.BACK_TO_STEP3': 'step3' | |
} | |
}, | |
site_not_payed: { | |
on: { | |
'SLIZA.WIDGET.PAY': 'tariffs' | |
} | |
}, | |
tariffs: { | |
on: { | |
} | |
} | |
} | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment