Last active
March 1, 2022 17:56
-
-
Save andieromero/dfa1b8104b9a46f20600524f97767bcf to your computer and use it in GitHub Desktop.
Revisions
-
andieromero revised this gist
Mar 1, 2022 . 1 changed file with 461 additions and 183 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -10,235 +10,513 @@ // - actions // - XState (all XState exports) const investorOnboardingMachine = Machine( { id: 'onboarding', // schema: { // context: {} as InvestorOnboardingState, // events: {} as InvestorOnboardingEvents, // actions: {} as InvestorOnboardingActions, // services: {} as any, // }, // Initialize context // context: { // events: [], // steps: { // [Flow.ACCREDITATION]: ACCREDITATION_STEPS, // [Flow.INVESTMENT]: ACCREDITATION_STEPS, // }, // flow: Flow.ACCREDITATION, // }, initial: 'idle', states: { idle: { on: { BROWSE: { target: 'browsing', }, CAPTURE_INTEREST: { target: 'intro_accreditation', actions: ['onCaptureInterest'], // invoke: 'getCurrentStep', }, }, exit: ['saveToSessionStorage'], }, browsing: { on: { CAPTURE_INTEREST: { target: 'intro_accreditation', actions: ['saveToSessionStorage'], }, }, }, intro_accreditation: { on: { SUBMIT_INTRO_ACCREDITATION: { target: 'identification', actions: ['saveToSessionStorage'], }, }, }, identification: { on: { SUBMIT_IDENTIFICATION: [ { target: 'accreditation', // cond: () => { // // check condition // return true; // }, }, { target: 'passport_submitted', // cond: () => { // // check condition // }, }, ], }, }, accreditation: { on: { SET_ACCREDITATION_INDIVIDUAL: { target: 'accreditation_individual', // cond: () => { // }, }, SET_ACCREDITATION_FIRM_OR_FUND: { target: 'accreditation_firm_or_fund', // cond: () => { // }, }, SET_ACCREDITATION_TRUST: { target: 'accreditation_trust', // cond: () => { // }, }, }, }, accreditation_individual: { on: { SUBMIT_ACCREDITATION_INDIVIDUAL: { target: 'verification_individual', }, PASSPORT_SUBMITTED: { target: 'passport_submitted', }, }, }, accreditation_firm_or_fund: { on: { SUBMIT_ACCREDITATION_FIRM_OR_FUND: { target: 'verification_firm_or_fund', }, PASSPORT_SUBMITTED: { target: 'passport_submitted', }, }, }, accreditation_trust: { on: { SUBMIT_ACCREDITATION_TRUST: { target: 'verification_trust', }, PASSPORT_SUBMITTED: { target: 'passport_submitted', }, }, }, verification_individual: { on: { SUBMIT_VERIFICATION_INDIVIDUAL: { target: 'passport_submitted', }, }, }, verification_firm_or_fund: { on: { SUBMIT_VERIFICATION_FIRM_OR_FUND: { target: 'beneficial_ownership', // cond: () => {} }, }, }, verification_trust: { on: { SUBMIT_VERIFICATION_TRUST: { target: 'passport_submitted', }, }, }, beneficial_ownership: { on: { SUBMIT_BENEFICIAL_OWNERSHIP: { target: 'authorized_signatories', }, }, }, authorized_signatories: { on: { SUBMIT_AUTHORIZED_SIGNATORIES: { target: 'passport_submitted', }, }, }, passport_submitted: { on: { SUBMIT_PASSPORT_SUBMITTED: [ { target: 'tearsheet', // cond: () => {}, }, // { // target: 'SUBSCRIBE_FLOW', // // cond: () => {}, // }, // { // target: 'CREATE_PROVENANCE_WALLET', // type: 'final', // // cond: () => {} // }, ], }, }, tearsheet: { on: { TEARSHEET_INVEST: { target: 'commitment_amount', }, }, }, // INVESTMENT FLOW commitment_amount: { on: { SUBMIT_COMMITMENT: { target: 'eligibility_questions', // cond: () => { // // this is dynamic? // } }, }, }, eligibility_questions: { on: { SUBMIT_ELIGIBILITY_QUESTIONS: { target: 'closing_docs', // cond: () => { // // this is dynamic? // } }, }, }, closing_docs: { on: { SUBMIT_CLOSING_DOCS: { target: 'tax_forms', // cond: () => { // // this is dynamic? // } }, }, }, tax_forms: { on: { SUBMIT_TAX_FORMS: { target: 'security_questions_and_2fa', // cond: () => { // // this is dynamic? // } }, }, }, security_questions_and_2fa: { on: { SECURITY_QUESTIONS_AND_2FA_SUBMIT: { target: 'funding', // cond: () => { // // this is dynamic? // } }, }, }, funding: { on: { ADDED_FUNDS: { target: 'funds_added', }, }, }, funds_added: { type: 'final', }, }, }, { actions: { onCaptureInterest: assign({ flow: (context) => Flow.ACCREDITATION, }), // TODO fix event saveToSessionStorage: assign({ steps: (context, event) => { console.log('sending event', event); // Typing in the assign function doesn't work. const { completesSteps } = Events[event.type]; console.log(completesSteps); if (completesSteps) { completesSteps.forEach((step) => { console.log('completing for ', step, event); }); // useSessionStorage(INVESTOR_ONBOARDING_SESSION_STORAGE_KEY, JSON.stringify(context)); // const storeStep = { // isCompleted: true, // isCurrentStep: true, // // stepType: (Events[Object.keys(event)[0]] as InvestorOnboardingEvent).stepType, // } as Step; return { ...context.steps }; } return { ...context.steps }; }, }), }, // services: { // getCurrentStep: (context, event) => { // console.log('get current step service... ', context, event); // }, // }, } ); // const fetchMachine = Machine({ // id: 'fetch', // initial: 'idle', // context: { // retries: 0 // }, // actions: { // }, // states: { // idle: { // on: { // BROWSE: { // target: 'browsing', // }, // CAPTURE_INTEREST: { // target: 'intro_accreditation', // actions: assign({ // steps: (context) => { // console.log(context) // return context; // }, // }), // }, // }, // }, // browsing: { // on: { // CAPTURE_INTEREST: { // target: 'intro_accreditation', // }, // }, // }, // intro_accreditation: { // on: { // SUBMIT_INTRO_ACCREDITATION: 'identification', // }, // }, // identification: { // on: { // SUBMIT_IDENTIFICATION: [ // { // target: 'accreditation', // // cond: () => { // // // check condition // // return true; // // }, // }, // { // target: 'passport_submitted', // // cond: () => { // // // check condition // // }, // }, // ], // }, // }, // accreditation: { // on: { // SET_ACCREDITATION_INDIVIDUAL: { // target: 'accreditation_individual', // // cond: () => { // // }, // }, // SET_ACCREDITATION_FIRM_OR_FUND: { // target: 'accreditation_firm_or_fund', // // cond: () => { // // }, // }, // SET_ACCREDITATION_TRUST: { // target: 'accreditation_trust', // // cond: () => { // // }, // }, // }, // }, // accreditation_individual: { // on: { // SUBMIT_ACCREDITATION_INDIVIDUAL: { // target: 'verification_individual', // }, // PASSPORT_SUBMITTED: { // target: 'passport_submitted', // }, // }, // }, // accreditation_firm_or_fund: { // on: { // SUBMIT_ACCREDITATION_FIRM_OR_FUND: { // target: 'verification_firm_or_fund', // }, // PASSPORT_SUBMITTED: { // target: 'passport_submitted', // }, // }, // }, // accreditation_trust: { // on: { // SUBMIT_ACCREDITATION_TRUST: { // target: 'verification_trust', // }, // PASSPORT_SUBMITTED: { // target: 'passport_submitted', // }, // }, // }, // verification_individual: { // on: { // SUBMIT_VERIFICATION_INDIVIDUAL: { // target: 'passport_submitted', // }, // }, // }, // verification_firm_or_fund: { // on: { // SUBMIT_VERIFICATION_FIRM_OR_FUND: { // target: 'beneficial_ownership', // // cond: () => {} // }, // }, // }, // verification_trust: { // on: { // SUBMIT_VERIFICATION_TRUST: { // target: 'passport_submitted', // }, // }, // }, // beneficial_ownership: { // on: { // SUBMIT_BENEFICIAL_OWNERSHIP: { // target: 'authorized_signatories', // }, // }, // }, // authorized_signatories: { // on: { // SUBMIT_AUTHORIZED_SIGNATORIES: { // target: 'passport_submitted', // }, // }, // }, // passport_submitted: { // on: { // SUBMIT_PASSPORT_SUBMITTED: [ // { // target: 'tearsheet', // // cond: () => {}, // }, // // { // // target: 'SUBSCRIBE_FLOW', // // // cond: () => {}, // // }, // // { // // target: 'CREATE_PROVENANCE_WALLET', // // type: 'final', // // // cond: () => {} // // }, // ], // }, // }, // tearsheet: { // on: { // TEARSHEET_INVEST: { // target: 'commitment_amount', // }, // }, // }, // // INVESTMENT FLOW // commitment_amount: { // on: { // SUBMIT_COMMITMENT: { // target: 'eligibility_questions', // // cond: () => { // // // this is dynamic? // // } // }, // }, // }, // eligibility_questions: { // on: { // SUBMIT_ELIGIBILITY_QUESTIONS: { // target: 'closing_docs', // // cond: () => { // // // this is dynamic? // // } // }, // }, // }, // closing_docs: { // on: { // SUBMIT_CLOSING_DOCS: { // target: 'tax_forms', // // cond: () => { // // // this is dynamic? // // } // }, // }, // }, // tax_forms: { // on: { // SUBMIT_TAX_FORMS: { // target: 'security_questions_and_2fa', // // cond: () => { // // // this is dynamic? // // } // }, // }, // }, // security_questions_and_2fa: { // on: { // SECURITY_QUESTIONS_AND_2FA_SUBMIT: { // target: 'funding', // // cond: () => { // // // this is dynamic? // // } // }, // }, // }, // funding: { // on: { // ADDED_FUNDS: { // target: 'funds_added', // }, // }, // }, // funds_added: { // type: 'final', // }, // }, // });
-
andieromero revised this gist
Feb 24, 2022 . 1 changed file with 18 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -15,16 +15,32 @@ initial: 'idle', context: { retries: 0 }, actions: { }, states: { idle: { on: { BROWSE: { target: 'browsing', }, CAPTURE_INTEREST: { target: 'intro_accreditation', actions: assign({ steps: (context) => { console.log(context) return context; }, }), }, }, }, browsing: { on: { CAPTURE_INTEREST: { target: 'intro_accreditation', }, }, }, intro_accreditation: { -
andieromero revised this gist
Feb 24, 2022 . 1 changed file with 121 additions and 20 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -70,12 +70,77 @@ }, }, }, accreditation_individual: { on: { SUBMIT_ACCREDITATION_INDIVIDUAL: { target: 'verification_individual', }, PASSPORT_SUBMITTED: { target: 'passport_submitted', }, }, }, accreditation_firm_or_fund: { on: { SUBMIT_ACCREDITATION_FIRM_OR_FUND: { target: 'verification_firm_or_fund', }, PASSPORT_SUBMITTED: { target: 'passport_submitted', }, }, }, accreditation_trust: { on: { SUBMIT_ACCREDITATION_TRUST: { target: 'verification_trust', }, PASSPORT_SUBMITTED: { target: 'passport_submitted', }, }, }, verification_individual: { on: { SUBMIT_VERIFICATION_INDIVIDUAL: { target: 'passport_submitted', }, }, }, verification_firm_or_fund: { on: { SUBMIT_VERIFICATION_FIRM_OR_FUND: { target: 'beneficial_ownership', // cond: () => {} }, }, }, verification_trust: { on: { SUBMIT_VERIFICATION_TRUST: { target: 'passport_submitted', }, }, }, beneficial_ownership: { on: { SUBMIT_BENEFICIAL_OWNERSHIP: { target: 'authorized_signatories', }, }, }, authorized_signatories: { on: { SUBMIT_AUTHORIZED_SIGNATORIES: { target: 'passport_submitted', }, }, }, passport_submitted: { on: { SUBMIT_PASSPORT_SUBMITTED: [ { target: 'tearsheet', // cond: () => {}, }, // { @@ -90,36 +155,72 @@ ], }, }, tearsheet: { on: { TEARSHEET_INVEST: { target: 'commitment_amount', }, }, }, // INVESTMENT FLOW commitment_amount: { on: { SUBMIT_COMMITMENT: { target: 'eligibility_questions', // cond: () => { // // this is dynamic? // } }, }, }, eligibility_questions: { on: { SUBMIT_ELIGIBILITY_QUESTIONS: { target: 'closing_docs', // cond: () => { // // this is dynamic? // } }, }, }, closing_docs: { on: { SUBMIT_CLOSING_DOCS: { target: 'tax_forms', // cond: () => { // // this is dynamic? // } }, }, }, tax_forms: { on: { SUBMIT_TAX_FORMS: { target: 'security_questions_and_2fa', // cond: () => { // // this is dynamic? // } }, }, }, security_questions_and_2fa: { on: { SECURITY_QUESTIONS_AND_2FA_SUBMIT: { target: 'funding', // cond: () => { // // this is dynamic? // } }, }, }, funding: { on: { ADDED_FUNDS: { target: 'funds_added', }, }, }, funds_added: { type: 'final', }, }, -
andieromero revised this gist
Feb 24, 2022 . 1 changed file with 99 additions and 40 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -17,52 +17,111 @@ retries: 0 }, states: { idle: { on: { BROWSE: 'browsing', }, }, browsing: { on: { CAPTURE_INTEREST: 'intro_accreditation', }, }, intro_accreditation: { on: { SUBMIT_INTRO_ACCREDITATION: 'identification', }, }, identification: { on: { SUBMIT_IDENTIFICATION: [ { target: 'accreditation', // cond: () => { // // check condition // return true; // }, }, { target: 'passport_submitted', // cond: () => { // // check condition // }, }, ], }, }, accreditation: { on: { SET_ACCREDITATION_INDIVIDUAL: { target: 'accreditation_individual', // cond: () => { // }, }, SET_ACCREDITATION_FIRM_OR_FUND: { target: 'accreditation_firm_or_fund', // cond: () => { // }, }, SET_ACCREDITATION_TRUST: { target: 'accreditation_trust', // cond: () => { // }, }, }, }, passport_submitted: { on: { SUBMIT_PASSPORT_SUBMITTED: [ { target: 'final', // target: 'TEARSHEET', // cond: () => {}, }, // { // target: 'SUBSCRIBE_FLOW', // // cond: () => {}, // }, // { // target: 'CREATE_PROVENANCE_WALLET', // type: 'final', // // cond: () => {} // }, ], }, }, accreditation_individual: { on: { SUBMIT_ACCREDITATION_INDIVIDUAL: { // target: 'verification_individual', target: 'final', }, }, }, accreditation_firm_or_fund: { on: { SUBMIT_ACCREDITATION_FIRM_OR_FUND: { // target: 'verification_firm_or_fund', target: 'final', }, }, }, accreditation_trust: { on: { SUBMIT_ACCREDITATION_TRUST: { // target: 'verification_trust', target: 'final', }, }, }, // verification_individual: { // on: { // SUBMIT // } // }, final: { type: 'final', }, }, });
-
andieromero revised this gist
Feb 24, 2022 . 1 changed file with 14 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -49,7 +49,20 @@ } ] } }, acreditation: { on: { SET_ACCREDITATION_INDIVIDUAL: { target: 'accreditation_individual' }, SET_ACCREDITATION_FIRM_OR_FUND: { target: 'accreditation_firm_or_fund' }, SET_ACCREDITATION_TRUST: { target: 'accreditation_trust' }, } }, } });
-
andieromero revised this gist
Feb 24, 2022 . 1 changed file with 19 additions and 9 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -27,17 +27,27 @@ CAPTURE_INTEREST: 'intro_accreditation' } }, intro_accreditation: { on: { SUBMIT_INTRO_ACCREDITATION: 'identification' } }, identification: { on: { SUBMIT_IDENTIFICATION: [ { target: 'accreditation', cond: () => { // check condition } }, { target: 'passport_submitted', cond: () => { // check condition } } ] } } } -
andieromero revised this gist
Feb 22, 2022 . 1 changed file with 3 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -19,13 +19,12 @@ states: { idle: { on: { BROWSE: 'browsing' } }, browsing: { on: { CAPTURE_INTEREST: 'intro_accreditation' } }, success: { -
andieromero created this gist
Feb 17, 2022 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ // Available variables: // - Machine // - interpret // - assign // - send // - sendParent // - spawn // - raise // - actions // - XState (all XState exports) const fetchMachine = Machine({ id: 'fetch', initial: 'idle', context: { retries: 0 }, states: { idle: { on: { FETCH: 'loading' } }, loading: { on: { RESOLVE: 'success', REJECT: 'failure' } }, success: { type: 'final' }, failure: { on: { RETRY: { target: 'loading', actions: assign({ retries: (context, event) => context.retries + 1 }) } } } } });