Created
September 11, 2019 12:39
-
-
Save lifedraft/bc1358de7b62b4e2a13fd107c6bc2e48 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
| // Available variables: | |
| // - Machine | |
| // - interpret | |
| // - assign | |
| // - send | |
| // - sendParent | |
| // - spawn | |
| // - raise | |
| // - actions | |
| // - XState (all XState exports) | |
| const fetchMachine = Machine({ | |
| "id": "addToCartStateMachine", | |
| "initial": "pdp", | |
| "states": { | |
| "pdp": { | |
| "type": "atomic", | |
| "on": { | |
| "ADD_TO_CART_HOME": "cartProductRulesHome", | |
| "ADD_TO_CART_INFLIGHT": "cartProductRulesInflight" | |
| } | |
| }, | |
| "cartProductRulesHome": { | |
| "on": { | |
| "DOMESTIC_OR_INFLIGHT": "modalInflightOrDomestic", | |
| "DOMESTIC_OR_INTERNATIONAL": "modalInternationalOrDomestic", | |
| "ADD_DOMESTIC": "addToCartDomestic", | |
| "ADD_INTERNATIONAL": "addToCartInternational" | |
| } | |
| }, | |
| "cartProductRulesInflight": { | |
| "on": { | |
| "SEARCH_FLIGHT": "searchForBookingAndSelectFlight", | |
| "ADD_INFLIGHT": "addToCartInflight" | |
| } | |
| }, | |
| "addToCartInflight": { | |
| "on": { | |
| "SUCCESS": "modalSuccess", | |
| "LEAD_TIME_FAIL": "modalLeadTimeError", | |
| "MIN_MILES_FAIL": "modalMinMilesError", | |
| "OUT_OF_STOCK": "modalOutOfStockError", | |
| "BOOKING_DATA_MISSING": "searchForBookingAndSelectFlight", | |
| "FAIL": "pdp" | |
| } | |
| }, | |
| "addToCartDomestic": { | |
| "on": { | |
| "TRAVEL_EXCLUSIVE_BOOKING": "modalTravelExclusiveBooking", | |
| "SUCCESS": "modalSuccess", | |
| "MIN_MILES_FAIL": "modalMinMilesError", | |
| "VALID_FLIGHT_FOR_BOOKING_FAIL": "modalValidBookingCodeOldFlightsError", | |
| "MAX_QUANTITY_EXCEEDED_FAIL": "modalMaximumQuantityExceededError", | |
| "OUT_OF_STOCK": "modalOutOfStockError", | |
| "BOOKING_DATA_MISSING": "modalFail", | |
| "FAIL": "pdp" | |
| } | |
| }, | |
| "addToCartInternational": { | |
| "on": { | |
| "TRAVEL_EXCLUSIVE_BOOKING": "modalTravelExclusiveBooking", | |
| "MIN_MILES_FAIL": "modalMinMilesError", | |
| "MAX_QUANTITY_EXCEEDED_FAIL": "modalMaximumQuantityExceededError", | |
| "OUT_OF_STOCK": "modalOutOfStockError", | |
| "VALID_FLIGHT_FOR_BOOKING_FAIL": "modalValidBookingCodeOldFlightsError", | |
| "BOOKING_DATA_MISSING": "modalFail", | |
| "SUCCESS": "modalSuccess", | |
| "FAIL": "pdp" | |
| } | |
| }, | |
| "modalInternationalOrDomestic": { | |
| "on": { | |
| "EXIT": "pdp", | |
| "DOMESTIC_CART": "addToCartDomestic", | |
| "INTERNATIONAL_CART": "addToCartInternational", | |
| "VALID_FLIGHT_FOR_BOOKING_FAIL": "modalValidBookingCodeOldFlightsError" | |
| } | |
| }, | |
| "modalSuccess": { | |
| "on": { | |
| "EXIT": "pdp", | |
| "TO_CART": "gotoCart" | |
| } | |
| }, | |
| "modalMaximumQuantityExceededError": { | |
| "on": { | |
| "EXIT": "pdp" | |
| } | |
| }, | |
| "modalOutOfStockError": { | |
| "on": { | |
| "EXIT": "pdp" | |
| } | |
| }, | |
| "modalLeadTimeError": { | |
| "on": { | |
| "SEARCH_FLIGHT": "searchForBookingAndSelectFlight", | |
| "EXIT": "pdp" | |
| } | |
| }, | |
| "modalMinMilesError": { | |
| "on": { | |
| "EXIT": "pdp" | |
| } | |
| }, | |
| "modalValidBookingCodeOldFlightsError": { | |
| "on": { | |
| "BACK": "modalTravelExclusiveBooking", | |
| "modalTravelExclusiveBooking": "modalTravelExclusiveBooking", | |
| "TRAVEL_EXCLUSIVE_BOOKING": "modalTravelExclusiveBooking", | |
| "EXIT": "pdp" | |
| } | |
| }, | |
| "modalInflightOrDomestic": { | |
| "on": { | |
| "GO_TO_INFLIGHT": "cartProductRulesInflight", | |
| "ADD_DOMESTIC": "addToCartDomestic", | |
| "EXIT": "pdp" | |
| } | |
| }, | |
| "modalTravelExclusiveBooking": { | |
| "on": { | |
| "SHOW_INVALID_BOOKING": "modalInvalidTravelExclusiveBookingDetails", | |
| "SHOW_BOOKING_INFORMATION": "modalBookingInformation", | |
| "ADD_DOMESTIC": "addToCartDomestic", | |
| "ADD_INTERNATIONAL": "addToCartInternational", | |
| "VALID_FLIGHT_FOR_BOOKING_FAIL": "modalValidBookingCodeOldFlightsError", | |
| "EXIT": "pdp" | |
| } | |
| }, | |
| "modalBookingInformation": { | |
| "on": { | |
| "BACK": "modalTravelExclusiveBooking", | |
| "SEARCH_FLIGHT": "modalTravelExclusiveBooking", | |
| "EXIT": "pdp" | |
| } | |
| }, | |
| "modalInvalidTravelExclusiveBookingDetails": { | |
| "on": { | |
| "SEARCH_FLIGHT": "modalTravelExclusiveBooking", | |
| "BACK": "modalTravelExclusiveBooking", | |
| "EXIT": "pdp" | |
| } | |
| }, | |
| "modalFail": { | |
| "on": { | |
| "EXIT": "pdp" | |
| } | |
| }, | |
| "searchForBookingAndSelectFlight": { | |
| "type": "compound", | |
| "initial": "modalFlightSearch", | |
| "on": { | |
| "EXIT": "pdp" | |
| }, | |
| "states": { | |
| "modalFlightSearch": { | |
| "on": { | |
| "SHOW_RESULTS": "modalFlightSelection", | |
| "SHOW_INVALID_BOOKING": "modalInvalidBookingDetails", | |
| "SHOW_NO_RESULTS": "modalNoValidFlight", | |
| "SHOW_BOOKING_INFORMATION": "modalBookingInformation" | |
| } | |
| }, | |
| "modalFlightSelection": { | |
| "on": { | |
| "FLIGHT_SELECT": "flightSelected", | |
| "BACK": "modalFlightSearch", | |
| "PREORDER_ELIGIBILITY_INFORMATION": "modalFlightEligibilityFromFlightSelection" | |
| } | |
| }, | |
| "modalFlightEligibilityFromFlightSelection": { | |
| "on": { | |
| "BACK": "modalFlightSelection", | |
| "SEARCH_FLIGHT": "modalFlightSearch" | |
| } | |
| }, | |
| "modalFlightEligibilityFromInvalidBooking": { | |
| "on": { | |
| "BACK": "modalInvalidBookingDetails", | |
| "SEARCH_FLIGHT": "modalFlightSearch" | |
| } | |
| }, | |
| "modalBookingInformation": { | |
| "on": { | |
| "BACK": "modalFlightSearch", | |
| "SEARCH_FLIGHT": "modalFlightSearch" | |
| } | |
| }, | |
| "modalPreOrderInformation": { | |
| "on": { | |
| "BACK": "modalFlightSearch" | |
| } | |
| }, | |
| "modalInvalidBookingDetails": { | |
| "on": { | |
| "PREORDER_ELIGIBILITY_INFORMATION": "modalFlightEligibilityFromInvalidBooking", | |
| "SEARCH_FLIGHT": "modalFlightSearch", | |
| "BACK": "modalFlightSearch" | |
| } | |
| }, | |
| "modalNoValidFlight": { | |
| "on": { | |
| "PREORDER_ELIGIBILITY_INFORMATION": "modalFlightEligibilityFromInvalidBooking", | |
| "SEARCH_FLIGHT": "modalFlightSearch", | |
| "BACK": "modalFlightSearch" | |
| } | |
| }, | |
| "flightSelected": { | |
| "type": "final" | |
| } | |
| }, | |
| "onDone": "addToCartInflight" | |
| }, | |
| "gotoCart": { | |
| "type": "final" | |
| } | |
| } | |
| } | |
| ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment