Created
February 16, 2023 18:13
-
-
Save shanwixcode/14f126e53f759d8ef7882ecdba0e889f 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
import {verify, verify_code} from 'backend/twilio.jsw'; | |
import wixLocation from 'wix-location'; | |
import {currentMember} from 'wix-members'; | |
let me; | |
$w.onReady(function () { | |
currentMember.getMember() | |
.then( (member) => { | |
me = member._id; | |
}); | |
}); | |
let last_used_num; | |
export function verify_click(event) { | |
if($w("#cc").valid && $w("#num").valid) { | |
$w("#verify").disable(); | |
let full_num = `${$w("#cc").value}${$w("#num").value}`; | |
last_used_num = full_num; | |
verify(full_num) | |
.then( (res) => { | |
if(res.sid) { | |
$w("#group1").hide(); | |
$w("#group2").show(); | |
} | |
}); | |
} | |
} | |
export function verifyFinal_click(event) { | |
$w("#verifyFinal").disable(); | |
verify_code(last_used_num, $w("#code").value, me).then( (res) => { | |
if(res.status === 'approved') { | |
setTimeout(() => { | |
wixLocation.to('/account/my-rewards'); | |
}, 1000); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment