Last active
December 19, 2019 10:55
-
-
Save omofolarin/8f57134c66982bc85287a09376676125 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 submitPhone = (whatsappNo) => { | |
return true; | |
} | |
const toggleMachine = Machine({ | |
context: { | |
error: null, | |
isVerified: false, | |
phoneSubmitStatus: null | |
}, | |
id: 'whatsAppVerifyModal', | |
initial: 'enterPhone', | |
states: { | |
enterPhone: { | |
initial: 'idle', | |
states: { | |
idle: { | |
on: { SUMIT: 'submit' } | |
}, | |
error:{}, | |
loading:{}, | |
submit:{ | |
on: { start: 'loading'}, | |
invoke: { | |
id: 'submitWhatsAppNo', | |
onDone: { | |
actions: assign({ | |
error: null, | |
phoneSubmitStatus: 'successful' | |
}), | |
on: { type: 'TOGGLE_VERIFY_PHONE' } | |
}, | |
onError: { | |
actions: assign({ phoneSubmitStatus: 'failed', error: (context, event) => event.data }), | |
target: 'error' | |
}, | |
src: (context, event) => { | |
return submitPhone(event.whatsappNo); | |
} | |
} | |
} | |
} | |
}, | |
verifyPhone: { | |
} | |
}, | |
on: { | |
TOGGLE_PHONE_ENTRY: { target: '.enterPhone', internal:false }, | |
TOGGLE_VERIFY_PHONE: { target: '.verifyPhone', internal: false } | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment