Created
September 30, 2020 14:32
-
-
Save tcjr/aa7180840ed5d1781fd5318c3070ce77 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 importMachine = Machine({ | |
id: 'questionImport', | |
context: {}, | |
initial: 'select-file', | |
states: { | |
'select-file': { | |
// Shows the file select / drag & drop screen (FRAME 1, FRAME 15) | |
on: { | |
FILE_SELECTED: 'confirm-file' | |
} | |
}, | |
'confirm-file': { | |
// Necessary? Shows the filename with a load button (FRAME 3) | |
on: { | |
CONFIRM: 'parsing' | |
} | |
}, | |
parsing: { | |
// Shows "Validating headers..."/"Headers look great!" AND "Validating rows..." etc (FRAME 4, FRAME 5, FRAME 6) | |
on: { | |
VALID: 'preview', | |
INVALID: 'errored' | |
}, | |
entry: ['startParse'] | |
}, | |
preview: { | |
// Shows "Headers look great!" AND "Rows look great!" AND summary that should say "You loaded X questions" (FRAME 7) | |
on: { | |
UPLOAD: 'uploading', | |
RESTART: 'select-file' | |
} | |
}, | |
uploading: { | |
on: { | |
SUCCESS: 'done', | |
FAIL: 'errored' | |
}, | |
entry: ['startUpload'] | |
}, | |
errored: { | |
on: { | |
RESTART: 'select-file' | |
} | |
}, | |
done: {} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment