Last active
October 27, 2022 22:27
-
-
Save denisborovikov/c80c00515e1a88d7d3cb43af95b73294 to your computer and use it in GitHub Desktop.
This file contains 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
const getUserProfile = useAPIGetUserProfile({ enabled: false }) | |
const createCognitoPinMutation = useAPICreateCognitoPin() | |
const verifyCognitoPinMutation = useAPIVerifyCognitoPin() | |
const tokenizeCardPinMutation = useAPITokenizePin() | |
const setCardPinMutation = useAPISetCardPin() | |
const [state, send] = useMachine(createPinMachine, { | |
services: { | |
async createCognitoPin(context) { | |
return await createCognitoPinMutation.mutateAsync(context.pin) | |
}, | |
async verifyCognitoPin(context) { | |
return await verifyCognitoPinMutation.mutateAsync(context.pin) | |
}, | |
async tokenizeCardPin(context) { | |
return await Promise.all([ | |
tokenizeCardPinMutation.mutateAsync({pin: context.pin}), | |
getUserProfile.refetch({ throwOnError: true }), | |
]) | |
}, | |
async updateCardPin(context) { | |
setCardPinMutation.mutateAsync({ | |
cardId: context.cardId, | |
tokenizedPin: context.tokenizedPin, | |
}) | |
}, | |
}, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment