Created
May 10, 2022 02:38
-
-
Save joegaudet/311d6b8deef4f065bceae9f87252ce27 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( | |
{ | |
initial: 'intro', | |
context: { | |
title: '', | |
ctaTitle: '', | |
}, | |
states: { | |
intro: { | |
on: { | |
CLOSE: 'closing', | |
CTA_CLICKED: 'configureDefault' | |
}, | |
onEntry: assign({ | |
title: 'New feature: driver tipping', | |
ctaTitle: 'Yes, setup my default tipping amounts', | |
}) | |
}, | |
configureDefault: { | |
on: { | |
CLOSE: 'closing', | |
CTA_CLICKED: 'saveAndApplyDefault' | |
}, | |
onEntry: assign({ | |
title: 'Set your default tip', | |
ctaTitle: 'Save my default tip', | |
}) | |
}, | |
saveAndApplyDefault: { | |
invoke: { | |
src: async ({modal}) => { | |
await modal.userSession.client.save(); | |
await modal.userSession.client.applyDefaultTip(); | |
}, | |
onDone: {target: 'closing'}, | |
}, | |
onEntry: assign({title: 'Setting your default tip'}), | |
}, | |
closing: { | |
invoke: { | |
src: ({modal}) => modal.userSession.user.storeValues({hasDismissedFirstTimeTippingModal: true}), | |
onDone: {target: 'closed'} | |
} | |
}, | |
closed: {}, | |
}, | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment