Last active
November 23, 2022 10:55
-
-
Save cadesalaberry/5333fb1939f271d1f2d94336623f18dd 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 inProgressStates = { | |
initial: 'in_progress', | |
states: { | |
in_progress: { | |
on: { | |
ADD_DOC_TO_REVIEW: { target: 'in_review' } | |
} | |
}, | |
in_review: { | |
on: { | |
ALL_DOC_APPROVED: { target: 'in_progress' } | |
} | |
} | |
} | |
}; | |
const fetchMachine = Machine({ | |
id: 'amt_status', | |
initial: 'idle', | |
context: { | |
retries: 0, | |
validationRequired: true | |
}, | |
states: { | |
idle: { | |
on: { | |
REQUEST: 'amt_request', | |
CREATE_AMT: 'to_plan', | |
} | |
}, | |
amt_request: { | |
on: { | |
AFFECT: 'to_plan', | |
REJECT_REQUEST: 'request_declined' | |
} | |
}, | |
to_plan: { | |
on: { | |
ADD_EVENT: 'in_progress' | |
} | |
}, | |
in_progress: { | |
on: { | |
DECLINE_AMT: 'amt_declined', | |
ALL_TASKS_FINISHED: 'should_approve_amt' | |
}, | |
...inProgressStates, | |
}, | |
should_approve_amt: { | |
on: { | |
APPROVAL_NEEDED: 'to_approve', | |
APPROVAL_NOT_NEEDED: 'amt_done' | |
} | |
}, | |
to_approve: { | |
on: { | |
APPROVE_AMT: 'amt_validated' | |
} | |
}, | |
request_declined: { | |
type: 'final' | |
}, | |
amt_declined: { | |
type: 'final' | |
}, | |
amt_validated: { | |
type: 'final' | |
}, | |
amt_done: { | |
type: 'final' | |
}, | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment