Skip to content

Instantly share code, notes, and snippets.

@aditya2337
Last active July 12, 2021 11:08
Show Gist options
  • Save aditya2337/12d23d5712830c85bbd46c33bd66926c to your computer and use it in GitHub Desktop.
Save aditya2337/12d23d5712830c85bbd46c33bd66926c 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 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