Skip to content

Instantly share code, notes, and snippets.

@ifyoumakeit
Created August 25, 2020 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ifyoumakeit/08a4a2dfdad6b6c1084f078b9c4dedb8 to your computer and use it in GitHub Desktop.
Save ifyoumakeit/08a4a2dfdad6b6c1084f078b9c4dedb8 to your computer and use it in GitHub Desktop.
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({
"key": "Checkout",
"states": {
"Inactive": {
"on": {
"checkout/USER_SUCCESS": "Configure and Review"
}
},
"Configure and Review": {
"id": "configure",
"onEntry": [
"fetchEstimate",
"fetchEstimateTags",
"fetchAdjustments",
"fetchPromo",
"fetchItems",
"fetchPayments",
"cleanupPayments",
"fetchCustomer",
"fetchEstimateAddresses",
"fetchPrescriptionRequests",
"fetchDiscountReasons",
"fetchSavedCreditCards"
],
"on": {
"checkout/PLACE_ORDER_SUCCESS": "#confirmation",
"checkout/FLOW_CANCEL": {
"Inactive": {
"actions": [
"returnToPOE"
]
}
},
"checkout/FLOW_TO_PAYMENT": {
"Payment": {}
},
"checkout/FLOW_TO_DISCOUNTS": "Discounts",
"checkout/FLOW_TO_SHIPPING": "Shipping",
"checkout/FLOW_TO_SHIPPING_METHOD": {
"#selectShippingMethod": {}
}
}
},
"Shipping": {
"states": {
"Shipping Configure": {
"on": {
"checkout/FLOW_CANCEL": "#configure",
"checkout/FLOW_SELECT_SHIPPING_TO_CUSTOMER": "Select Customer Address",
"checkout/FLOW_SELECT_SHIPPING_TO_STORE": "Select Store Address"
}
},
"Select Customer Address": {
"onEntry": [
"fetchEstimateAddresses"
],
"on": {
"checkout/FLOW_ADD_NEW_CUSTOMER_SHIPPING_ADDRESS": "Add New Customer Address",
"checkout/FLOW_CANCEL": "Shipping Configure",
"checkout/UPDATE_ESTIMATE_ADDRESS_SUCCESS": "Select Shipping Method",
"checkout/SAVE_ESTIMATE_ADDRESS_SUCCESS": "Select Shipping Method"
}
},
"Add New Customer Address": {
"on": {
"checkout/FLOW_CANCEL": "Select Customer Address",
"checkout/UPDATE_ESTIMATE_ADDRESS_SUCCESS": "Select Shipping Method",
"checkout/SAVE_ESTIMATE_ADDRESS_SUCCESS": "Select Shipping Method",
"checkout/UPDATE_ESTIMATE_ADDRESS_ERROR": "#error",
"checkout/SAVE_ESTIMATE_ADDRESS_ERROR": "#error"
}
},
"Select Store Address": {
"onEntry": [
"fetchFacilities",
"fetchNearbyFacilities"
],
"on": {
"checkout/FLOW_CANCEL": "Shipping Configure",
"checkout/SAVE_ESTIMATE_ADDRESS_SUCCESS": "Select Shipping Method"
}
},
"Select Shipping Method": {
"id": "selectShippingMethod",
"on": {
"checkout/FLOW_CANCEL": "Shipping Configure",
"checkout/FLOW_SELECT_SHIPPING_TO_CUSTOMER": "Select Customer Address",
"checkout/FLOW_SELECT_SHIPPING_TO_STORE": "Select Store Address",
"checkout/UPDATE_ESTIMATE_SUCCESS": "#configure",
"checkout/UPDATE_ESTIMATE_ERROR": "#error"
}
}
},
"initial": "Shipping Configure"
},
"Discounts": {
"states": {
"Discounts Configure": {
"on": {
"checkout/FLOW_CANCEL": "#configure",
"checkout/FLOW_SELECT_DISCOUNT_ADJUSTMENT": "Add Adjustement",
"checkout/FLOW_SELECT_DISCOUNT_PROMO": "Add Promo"
}
},
"Add Promo": {
"on": {
"checkout/FLOW_CANCEL": "Discounts Configure",
"checkout/DELETE_ESTIMATE_ADJUSTMENT_SUCCESS": "Discounts Configure",
"checkout/DELETE_ESTIMATE_ADJUSTMENT_ERROR": "#error",
"checkout/SAVE_ESTIMATE_PROMO_SUCCESS": {
"#configure": {
"actions": [
"fetchEstimate",
"fetchEstimateAdjustments",
"fetchPromo"
]
}
}
}
},
"Add Adjustement": {
"on": {
"checkout/FLOW_CANCEL": "Discounts Configure",
"checkout/DELETE_ESTIMATE_ADJUSTMENT_ERROR": "#error",
"checkout/SAVE_ESTIMATE_ADJUSTMENT_REQUEST": "Discount Validation"
}
},
"Discount Validation": {
"on": {
"checkout/SAVE_ESTIMATE_ADJUSTMENT_ERROR": "#error",
"checkout/SAVE_ESTIMATE_ADJUSTMENT_SUCCESS": {
"#configure": {
"actions": [
"fetchEstimate",
"fetchEstimateAdjustments"
]
}
}
}
}
},
"initial": "Discounts Configure"
},
"Payment": {
"states": {
"Payment Configure": {
"on": {
"checkout/FLOW_CANCEL": "#configure",
"checkout/SAVE_ESTIMATE_PAYMENT_REQUEST": "Create Payment Method",
"checkout/FLOW_TO_REVIEW": "#configure"
}
},
"Create Payment Method": {
"on": {
"checkout/SAVE_ESTIMATE_PAYMENT_ERROR": "#error",
"checkout/SAVE_ESTIMATE_PAYMENT_SUCCESS": "Refresh Estimate",
"checkout/FLOW_CANCEL": "Payment Configure"
}
},
"Refresh Estimate": {
"onEntry": [
"fetchEstimate"
],
"on": {
"checkout/FETCH_ESTIMATE_ERROR": "#error",
"checkout/FETCH_ESTIMATE_SUCCESS": "Payment Configure"
}
}
},
"initial": "Payment Configure"
},
"Confirmation": {
"id": "confirmation"
},
"Error": {
"id": "error",
"history": true
}
},
"initial": "Inactive"
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment