Skip to content

Instantly share code, notes, and snippets.

@shanwixcode
Created February 16, 2023 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shanwixcode/14f126e53f759d8ef7882ecdba0e889f to your computer and use it in GitHub Desktop.
Save shanwixcode/14f126e53f759d8ef7882ecdba0e889f to your computer and use it in GitHub Desktop.
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