Last active
April 29, 2020 20:00
-
-
Save jesusgoku/b47bd8ca666b4ebee2fd1baa663b9e0a 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 increaseDeliveryIntents = assign({ | |
deliveryIntents: (context) => context.deliveryIntents + 1, | |
}); | |
Machine({ | |
id: 'orders', | |
initial: 'PENDING', | |
context: { | |
deliveryIntents: 0, | |
}, | |
states: { | |
PENDING: { | |
on: { | |
RECEIVE: 'REQUEST_RECEIVE', | |
}, | |
}, | |
REQUEST_RECEIVE: { | |
on: { | |
ERP_PROCESS: 'ORDER_ERP_PROCCESING', | |
}, | |
}, | |
ORDER_ERP_PROCCESING: { // ¿Lo copiaste bien? es PROCESSING | |
on: { | |
CONFIRM: 'ORDER_CONFIRMED', | |
ERP_FAILED: 'ORDER_ERP_FAILED', | |
}, | |
}, | |
ORDER_ERP_FAILED: { | |
type: 'final' | |
}, | |
ORDER_CONFIRMED: { | |
on: { | |
IN_PRODUCTION: 'ORDER_IN_PRODUCTION', | |
CANCEL: 'ORDER_CANCELED', | |
}, | |
}, | |
ORDER_IN_PRODUCTION: { | |
on: { | |
READY_FOR_DELIVERY: 'ORDER_READY_FOR_DELIVERY', | |
CONFIRM: 'ORDER_CONFIRMED', | |
CANCEL: 'ORDER_CANCELED', | |
}, | |
}, | |
ORDER_READY_FOR_DELIVERY: { | |
on: { | |
DELIVERY: { | |
target: 'ORDER_DELIVERY', | |
actions: 'increaseDeliveryIntents', | |
}, | |
DELIVERED: 'ORDER_DELIVERED', | |
IN_PRODUCTION: 'ORDER_IN_PRODUCTION', | |
CANCEL: 'ORDER_CANCELED', | |
} | |
}, | |
ORDER_DELIVERY: { | |
on: { | |
DELIVERED: 'ORDER_DELIVERED', | |
RETURN: 'ORDER_RETURNED', | |
CANCEL: 'ORDER_CANCELED', | |
}, | |
}, | |
ORDER_DELIVERED: { | |
on: { | |
RETURN: 'ORDER_RETURNED', | |
CANCEL: 'ORDER_CANCELED', | |
}, | |
}, | |
ORDER_RETURNED: { | |
on: { | |
DELIVERY: { | |
target: 'ORDER_DELIVERY', | |
actions: 'increaseDeliveryIntents', | |
}, | |
CANCEL: 'ORDER_CANCELED', | |
}, | |
}, | |
ORDER_CANCELED: { | |
type: 'final', | |
}, | |
}, | |
}, { actions: { increaseDeliveryIntents } }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment