Last active
July 12, 2023 15:34
-
-
Save cunneen/7ec38b80014d2200422c2c4964ad8e2a 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const addStudentMachine = Machine({ | |
id: 'addStudent', | |
initial: 'initial', | |
context: { | |
retries: 0 | |
}, | |
states: { | |
initial: { | |
on: { | |
USI_ENTERED: 'findUSIMatch', | |
DOB_ENTERED: 'findFuzzyMatch' | |
} | |
}, | |
findUSIMatch: { | |
on: { | |
USI_MATCH_FOUND: 'confirmAddExistingStudent', | |
USI_MATCH_NOT_FOUND: 'notifyUSIMatchNotFound' | |
} | |
}, | |
notifyUSIMatchNotFound: { | |
on: { | |
OK: 'initial' | |
} | |
}, | |
findFuzzyMatch: { | |
on: { | |
FUZZY_MATCH_FOUND: 'presentFuzzyMatch', | |
FUZZY_MATCH_NOT_FOUND: 'notifyNoFuzzyMatchFound' | |
} | |
}, | |
presentFuzzyMatch: { | |
on: { | |
REJECT_SUGGESTIONS: 'addNewOrTryAgain', | |
SELECT_STUDENT: | |
'confirmAddExistingStudent' | |
} | |
}, | |
addNewOrTryAgain: { | |
on: { | |
ADD_NEW: 'newStudent', | |
TRY_AGAIN: 'initial' | |
} | |
}, | |
notifyNoFuzzyMatchFound: { | |
on: { | |
OK: 'addNewOrTryAgain' | |
} | |
}, | |
confirmAddExistingStudent: { | |
type: 'final' | |
}, | |
newStudent: { | |
type: 'final' | |
}, | |
failure: { | |
type: 'final' | |
}, | |
dismissed: { | |
type: 'final' | |
} | |
}, | |
on: { | |
CANCEL: 'initial', | |
CLOSE: 'dismissed', | |
ERROR: 'failure' | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment