Last active
April 18, 2020 00:40
-
-
Save hosmelq/e94329abf9741d1101334a73cd41787c to your computer and use it in GitHub Desktop.
Revisions
-
hosmelq revised this gist
Apr 18, 2020 . 1 changed file with 20 additions and 13 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 @@ -119,20 +119,21 @@ Machine( initial: `initializing`, context: { state: null, checks2: {}, checks: { emergencyContact: { message: null, state: 'PENDING', }, picture: { message: null, state: 'PENDING', }, vehicleInformation: { message: null, state: 'PENDING', }, }, }, states: { initializing: { @@ -170,6 +171,12 @@ Machine( ...ctx.checks[key], ref: spawn(checkMachine.withContext(ctx.checks[key])), })); }, checks2: (ctx) => { return { ...ctx.checks2, emergencyContact: spawn(emergencyContactMachine, `emergencyContact`) } } }) }, -
hosmelq revised this gist
Apr 18, 2020 . 1 changed file with 62 additions and 0 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,6 +10,68 @@ const CourierState = { REJECTED: `REJECTED`, } // const emergencyContactMachine = Machine( { id: `emergencyContact`, initial: `unknown`, context: { message: null, state: `PENDING`, }, states: { unknown: { on: { '': [ {cond: `isPending`, target: `pending`}, {cond: `isVerified`, target: `verified`}, ], }, }, pending: { on: { SUBMIT: `submitting`, }, }, submitting: { invoke: { id: `update-information`, src: `updateInformation`, onDone: `verified`, onError: { target: `pending`, actions: `handleGraphQLErrors`, }, }, }, verified: { entry: `updateInformationSuccess`, type: `final`, }, }, }, { guards: { isPending: (ctx) => { return ctx.state === CourierOnboardingVerificationsItemState.PENDING }, isVerified: (ctx) => { return ctx.state === CourierOnboardingVerificationsItemState.VERIFIED }, }, } ) // const checkMachine = Machine( { id: `check`, -
hosmelq revised this gist
Apr 17, 2020 . No changes.There are no files selected for viewing
-
hosmelq revised this gist
Apr 17, 2020 . 1 changed file with 24 additions and 11 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 @@ -14,17 +14,17 @@ const checkMachine = Machine( { id: `check`, initial: `unknown`, context: { message: null, state: null, }, states: { unknown: { on: { '': [ {cond: `isInRevision`, target: `inRevision`}, {cond: `isPending`, target: `pending`}, {cond: `isVerified`, target: `verified`}, ], }, }, @@ -56,8 +56,21 @@ Machine( id: `onboard`, initial: `initializing`, context: { state: null, checks: { emergencyContact: { message: null, state: 'PENDING', }, picture: { message: null, state: 'PENDING', }, vehicleInformation: { message: null, state: 'PENDING', }, }, }, states: { initializing: { @@ -91,9 +104,9 @@ Machine( actions: { initializeChecks: assign({ checks: (ctx) => { return Object.keys(ctx.checks).map(key => ({ ...ctx.checks[key], ref: spawn(checkMachine.withContext(ctx.checks[key])), })); } }) -
hosmelq created this gist
Apr 17, 2020 .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,105 @@ const CourierOnboardingVerificationsItemState = { IN_REVISION: `IN_REVISION`, PENDING: `PENDING`, VERIFIED: `VERIFIED`, } const CourierState = { ACTIVE: `ACTIVE`, BLOCKED: `BLOCKED`, PENDING: `PENDING`, REJECTED: `REJECTED`, } const checkMachine = Machine( { id: `check`, initial: `unknown`, states: { unknown: { on: { '': [ { target: `completed`, cond: (ctx) => ctx.completed, }, { target: `pending`, }, ], }, }, inRevision: {}, pending: {}, verified: {}, }, }, { guards: { isInRevision: (ctx) => { return ctx.state === CourierOnboardingVerificationsItemState.IN_REVISION }, isPending: (ctx) => { return ctx.state === CourierOnboardingVerificationsItemState.PENDING }, isVerified: (ctx) => { return ctx.state === CourierOnboardingVerificationsItemState.VERIFIED }, }, } ) Machine( { id: `onboard`, initial: `initializing`, context: { checks: [], state: null, }, states: { initializing: { entry: `initializeChecks`, on: { '': `unknown`, }, }, initializeChecks: {}, unknown: { on: { '': [ { cond: `isActive`, target: `active`, }, ], }, }, active: { meta: { title: `Activa`, }, }, }, }, { actions: { initializeChecks: assign({ checks: (ctx) => { return ctx.checks.map(check => ({ ...check, ref: spawn(checkMachine.withContext(check)), })); } }) }, guards: { isActive: (ctx) => ctx.state === CourierState.ACTIVE, }, } )