Created
July 5, 2021 10:40
-
-
Save mattpocock/b15dd430c0234f05e59f3f194c7fde36 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 fetchMachine = Machine({ | |
initial: 'nothingSelected', | |
states: { | |
nothingSelected: { | |
on: { | |
CHOOSE_DEVELOPER: { | |
target: 'developerSelected', | |
actions: assign((context, event) => { | |
return { | |
developerId: event.developerId, | |
}; | |
}), | |
}, | |
}, | |
}, | |
developerSelected: { | |
initial: 'noProjectSelected', | |
on: { | |
CHOOSE_DEVELOPER: [ | |
{ | |
target: '.noProjectSelected', | |
actions: assign((context, event) => { | |
return { | |
developerId: event.developerId, | |
paymentPlanId: undefined, | |
projectId: undefined, | |
unitId: undefined, | |
}; | |
}), | |
}, | |
], | |
}, | |
states: { | |
noProjectSelected: { | |
on: { | |
CHOOSE_PROJECT: { | |
target: 'projectSelected', | |
actions: assign((context, event) => { | |
return { | |
projectId: event.projectId, | |
}; | |
}), | |
}, | |
}, | |
}, | |
projectSelected: { | |
on: { | |
CHOOSE_PROJECT: { | |
actions: assign((context, event) => { | |
return { | |
projectId: event.projectId, | |
paymentPlanId: undefined, | |
unitId: undefined, | |
}; | |
}), | |
}, | |
CHOOSE_PAYMENT_PLAN: { | |
actions: assign((context, event) => { | |
return { | |
paymentPlanId: event.paymentPlanId, | |
}; | |
}), | |
}, | |
CHOOSE_UNIT: { | |
actions: assign((context, event) => { | |
return { | |
unitId: event.unitId, | |
}; | |
}), | |
}, | |
}, | |
}, | |
}, | |
}, | |
}, | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment