Created
February 11, 2021 16:18
-
-
Save eliseumds/bea0004ed57dcfd20a8b7864ec55eae5 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or 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 machine = Machine({ | |
id: 'subscriptionFlow', | |
initial: 'pickingBrand', | |
context: { | |
value: 'pickingBrand', | |
}, | |
states: { | |
pickingBrand: { | |
on: { | |
PICK_BRAND: 'loadingBrand', | |
}, | |
}, | |
loadingBrand: { | |
entry: 'syncBrandSlugWithUrlParams', | |
invoke: { | |
src: 'loadBrand', | |
onDone: { | |
target: 'pickingPlan', | |
actions: assign({ brand: (context, event) => event.data }), | |
}, | |
onError: { | |
target: 'pickingBrand', | |
actions: assign({ loadBrandError: (context, event) => event.data }), | |
}, | |
}, | |
}, | |
pickingPlan: { | |
on: { | |
PICK_PLAN: 'pickingPayment', | |
}, | |
}, | |
pickingPayment: { | |
on: { | |
PICK_PAYMENT: 'viewingSummary', | |
}, | |
}, | |
viewingSummary: { | |
on: { | |
INITIATE_SUBSCRIPTION: 'initiatingSubscription', | |
}, | |
}, | |
initiatingSubscription: { | |
invoke: { | |
src: 'dispatchInitiateSubscription', | |
onDone: { | |
target: 'success', | |
}, | |
onError: { | |
target: 'failure', | |
actions: assign({ | |
initiateSubscriptionError: (context, event) => event.data, | |
}), | |
}, | |
}, | |
}, | |
failure: {}, | |
success: { | |
entry: 'redirectToBrandDashboard', | |
}, | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment