Skip to content

Instantly share code, notes, and snippets.

@seanaguinaga
Created November 25, 2019 23:34
Show Gist options
  • Save seanaguinaga/df8d97fabc52ca0f458363126390d031 to your computer and use it in GitHub Desktop.
Save seanaguinaga/df8d97fabc52ca0f458363126390d031 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const StandardConsentFormState = Machine(
{
id: "standardConsentMachine",
initial: "unviewed",
// context: {
// viewed: false,
// signed: false,
// signature: null,
// renderedPDF: null,
// sent: false,
// delivered: false,
// error: null
// },
//@ts-ignore
states: {
unviewed: {
on: {
FORMVIEWED: {
target: "viewed",
actions: "focusSignatureInput"
}
}
},
viewed: {
on: {
FIELDFILLED: {
target: "signed",
actions: "enableSignButton"
}
}
},
signed: {
on: {
FORMSIGNED: {
target: "rendering"
}
}
},
rendering: {
onEntry: "renderConsentFormWithSignature",
on: {
FORMRENDERED: {
target: "rendersuccess"
},
FORMRENDERFAILED: {
target: "renderfailure"
}
}
},
rendersuccess: {
onEntry: "sendPDFToTrueVault",
on: {
FORMSENT: {
target: "sending"
}
}
},
renderfailure: {
on: {
RETRYRENDER: {
target: "rendering"
}
}
},
sending: {
on: {
FORMNOTDELIVERED: {
actions: "deliveryError",
target: "sendfailure"
},
FORMDELIVERED: {
target: "sendsuccess"
}
}
},
sendfailure: {
on: {
RETRYSEND: {
target: "sending"
}
}
},
sendsuccess: {
onEntry: "markCompleted"
}
}
},
{
actions: {}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment