Created
April 20, 2020 07:24
-
-
Save shanwixcode/7d700119e0e94aa6354b4b97955a317d 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
function signUpMember(response, cus, lastFour, brand, sourceData, referrer, donationValue) { | |
wixUsers.register($w("#email").value, $w("#password").value, { | |
"contactInfo": { | |
"firstName": $w("#fName").value, | |
"lastName": $w("#lName").value | |
} | |
}) | |
.then( (result) => { | |
$w("#processorText").text = 'Thank you for your patience, We are almost done'; | |
updateStageOne(response, cus, lastFour, brand, sourceData, referrer, donationValue); | |
}) | |
.catch( (err) => { | |
handleAPIFailure(response, cus, lastFour, brand, err, sourceData, referrer, donationValue); | |
}); | |
} | |
async function updateStageOne(response, cus, lastFour, brand, sourceData, referrer, donationValue) { | |
let email = $w('#email').value; | |
let newEmail = email.toLowerCase(); | |
let data = { | |
customerEmail: newEmail | |
}; | |
await wixData.insert('customerList', data); //this happens but without a owner ID | |
insertMember(response, cus, lastFour, brand, sourceData, referrer, donationValue); | |
} | |
//-----------------------------------------------------------Continue With Sign Up-------------------------------------------------------// | |
function insertMember(response, cus, lastFour, brand, sourceData, referrer, donationValue) { | |
let alpha = $w("#fName").value.charAt(0); | |
let lowerAlpha = alpha.toLowerCase(); | |
wixData.query('alternateLogos') | |
.eq('alphabet', lowerAlpha) | |
.find() | |
.then( (results) => { | |
if(results.length > 0) { | |
let Item = results.items[0]; | |
let profile = Item.logo; | |
confirmInsertSuccess(response, cus, lastFour, brand, profile, sourceData, referrer, donationValue); | |
} else { | |
let profile = $w("#generic").src; | |
confirmInsertSuccess(response, cus, lastFour, brand, profile, sourceData, referrer, donationValue); | |
} | |
}); | |
} | |
function confirmInsertSuccess(response, cus, lastFour, brand, profile, sourceData, referrer, donationValue) { | |
let date = Math.floor(Date.now() / 1000); | |
$w("#processorText").text = 'Redirecting to your dashboard'; | |
let email = $w('#email').value; | |
let newEmail = email.toLowerCase(); | |
let data = { | |
firstName: $w("#fName").value, | |
lastName: $w("#lName").value, | |
emailId: newEmail, | |
customerId: cus, | |
subscriptionId: response.id, | |
lastFour: String(lastFour), | |
cardType: brand, | |
subscriptionStatus: 'ACTIVE', | |
profilePicture: profile, | |
source: sourceData, | |
street: $w("#address").value, | |
city: $w("#city").value, | |
postal: $w("#postal").value, | |
state: $w("#state").value, | |
country: $w("#country").value, | |
totalDonated: Number(donationValue), | |
unixCreated: Number(date), | |
referralStatus: 'PENDING', | |
referrer: referrer, | |
monthlyDonation: Number(finalAmountTwo), | |
lastPaid: Number(date), | |
device: String(device), | |
siteReferrer: String(siteReference) | |
}; | |
wixData.insert('payingMembers', data) //this does not happen | |
.then( (result) => { | |
let item = result; | |
wixLocation.to(`/my-dashboard/${item._id}`); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment