Last active
July 20, 2022 19:37
-
-
Save ryanflorence/065962a600fcbc76d0968fec75e0b57a 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
const fetchMachine = Machine({ | |
id: 'fetch', | |
initial: 'home', | |
states: { | |
home: { | |
on: { | |
LOGIN: { | |
target: 'dashboard', | |
actions: 'recordLoginTime' | |
}, | |
VIEW_COURSE: 'courseMarketingPage', | |
SIGN_UP_FOR_NEWSLETTER: 'home' | |
} | |
}, | |
dashboard: { | |
on: { | |
START_COURSE: 'course', | |
VIEW_COURSE: 'courseMarketingPage', | |
VIEW_ACCOUNT: 'account' | |
} | |
}, | |
courseMarketingPage: { | |
on: { | |
ADD_TO_CART: 'cart', | |
PREVIEW_CHAPTER: 'chapterPreview', | |
VIEW_OTHER_COURSE: 'courseMarketingPage' | |
} | |
}, | |
cart: { | |
on: { | |
CHECKOUT: 'checkout' | |
} | |
}, | |
checkout: { | |
on: { | |
PURCHASE: { | |
target: 'dashboard', | |
actions: 'enrollUser' | |
} | |
} | |
}, | |
course: { | |
entry: ['markCourseStarted', 'markLastViewedCourse'], | |
on: { | |
START_CHAPTER: 'chapter' | |
} | |
}, | |
chapterPreview: { | |
on: { | |
ADD_TO_CART: 'cart', | |
BACK: 'courseMarketingPage' | |
} | |
}, | |
chapter: { | |
entry: ['markChapterViewed', 'markMostRecentViewed'], | |
on: { | |
NEXT_CHAPTER: { | |
target: 'chapter', | |
actions: 'markChapterComplete' | |
}, | |
PREV_CHAPTER: 'chapter', | |
FINISH_COURSE: { | |
target: 'finishCourse', | |
actions: ['markChapterComplete', 'markCourseComplete'] | |
} | |
} | |
}, | |
finishCourse: { | |
on: { | |
NEXT_COURSE: 'course', | |
UPSELL: 'courseMarketingPage', | |
END: 'dashboard' | |
} | |
}, | |
account: { | |
on: { | |
LOG_OUT: 'home', | |
GET_REFUND: { | |
target: 'account', | |
cond: 'under 30 days', | |
actions: 'refundTheirMoney' | |
}, | |
EMAIL_SUPPORT: 'account' | |
} | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment