Skip to content

Instantly share code, notes, and snippets.

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: 'wizard',
initial: 'start',
states: {
start: {
on: {
START: 'involvement',
CLOSE: 'thank_you',
},
},
involvement: {
on: {
I_WAS_INVOLVED: 'did_you_have_insurance',
I_WAS_NOT_INVOLVED: 'dispute',
},
},
did_you_have_insurance: {
on: {
I_HAD_INSURANCE: 'insurance_form',
I_DID_NOT_HAVE_INSURANCE: 'no_insurance',
},
},
insurance_form: {
on: {
INSURANCE_FORM_SUBMIT: 'insurance_form_followup',
},
},
insurance_form_followup: {
on: {
INSURANCE_FORM_FOLLOWUP_SUBMIT: 'insurance_form_followup_submit_message',
},
},
insurance_form_followup_submit_message: {
on: {
OK: 'thank_you',
},
},
no_insurance: {
on: {
IT_WAS_WORK_RELATED: 'work_related_employer_info_form',
NOT_WORK_RELATED: 'was_it_auto_or_property_related',
},
},
work_related_employer_info_form: {
on: {
WORK_RELATED_EMPLOYER_INFO_FORM_SUBMIT: 'work_related_employer_info_form_after_submit_message',
},
},
work_related_employer_info_form_after_submit_message: {
on: {
OK: 'thank_you',
},
},
was_it_auto_or_property_related: {
on: {
IT_WAS_AUTO_RELATED: 'auto',
IT_WAS_PROPERTY_RELATED: 'property',
NONE_OF_THE_ABOVE: 'thank_you',
},
},
auto: {
on: {
MY_LICENSE_OR_VEHICLE_REGISTRATION_WAS_REVOKED: 'auto_certified_claim_note_cubs',
MY_LICENSE_OR_VEHICLE_REGISTRATION_WAS_NOT_REVOKED: 'auto_final',
},
},
auto_certified_claim_note_cubs: {
on: {
CUBS_WAS_NOTED: 'auto_final',
},
},
auto_final: {
type: 'final',
},
property: {
on: {
PROPERTY_FORM_SUBMIT: 'pay_your_claim',
},
},
dispute: {
on: {
I_WANT_TO_DISPUTE_THIS: 'dispute_claim_form',
I_HAD_INSURANCE: 'insurance_form',
DO_NOT_DISPUTE: 'pay_your_claim',
},
},
dispute_claim_form: {
on: {
SUBMIT: 'dispute_claim_followup',
},
},
dispute_claim_followup: {
on: {
SUBMIT: 'dispute_claim_followup_after_submit',
},
},
dispute_claim_followup_after_submit: {
on: {
OK: 'thank_you',
},
},
pay_your_claim: {
type: 'final',
},
thank_you: {
type: 'final',
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment