// 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: {} } });