Last active
July 12, 2021 11:08
-
-
Save aditya2337/12d23d5712830c85bbd46c33bd66926c 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const shipperBookingMachine = Machine({ | |
id: 'Booking flow', | |
initial: 'shipper', | |
context: { | |
retries: 0 | |
}, | |
states: { | |
shipper: { | |
on: { | |
CREATE_BOOKING: 'logexOrigin' | |
} | |
}, | |
logexOrigin: { | |
on: { | |
PERFORM_SANITY_CHECK: 'sanityCheck', | |
} | |
}, | |
sanityCheck: { | |
on: { | |
SUCCESS: 'logexDestination', | |
REJECT: 'failure' | |
} | |
}, | |
logexDestination: { | |
on: { | |
BOOK_TRANSPORT: 'consigneeTransportVerification' | |
} | |
}, | |
consigneeTransportVerification: { | |
on: { | |
REQUIRED: 'consigneeConfirmForwarder', | |
NOT_REQUIRED: 'formaliseBooking' | |
} | |
}, | |
// consignee: { | |
// on: { | |
// BOOK_TRANSPORT: 'consigneeConfirmForwarder' | |
// } | |
// }, | |
consigneeConfirmForwarder: { | |
on: { | |
CONFIRMED: 'formaliseBooking', | |
REJECT: 'notifyShipper' | |
} | |
}, | |
formaliseBooking: { | |
type: 'final' | |
}, | |
notifyShipper: { | |
type: 'final' | |
}, | |
failure: { | |
on: { | |
RETRY: { | |
target: 'logexOrigin', | |
actions: assign({ | |
retries: (context, event) => context.retries + 1 | |
}) | |
} | |
} | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment