import wixData from 'wix-data';
import wixLocation from 'wix-location';
import {session} from 'wix-storage';
$w.onReady(function () {
let newName = session.getItem("newName2")
$w("#text10").text = newName
})
export function input1_viewportEnter(event) {
$w("#input1").focus()
}
export function button1_click(event) {
session.setItem("duplicateEmailAddress","No");
$w("#text13").hide();
var newEmailAddress = $w("#input1").value
if (newEmailAddress === "") {
$w("#text13").text = "Please enter your email address"
$w("#text13").show();
return;
}
wixData.query("User-Accounts-Practice-3")
.find()
.then((results => {
let items = results.items;
let totalCount = results.totalCount;
for (let i = 0;i <= totalCount;i++) {
let currentAddressBeingChecked = (items[i].emailAddress)
if (currentAddressBeingChecked === newEmailAddress) {
$w("#text13").text = "An account with this email address already exists";
$w("#text13").show();
session.setItem("duplicateEmailAddress","Yes");
console.log(session.getItem("duplicateEmailAddress"));
break
}
}
console.log("WHY DO I NEVER SEE THIS UNLESS THE EMAIL ADDRESS ENTERED IS A DUPLICATE? - IF THE ADDRESS IS DUPLICATE I DO SEE IT")
seeIfDuplicateAddress()
}))
}
function seeIfDuplicateAddress() {
let abc = session.getItem("duplicateEmailAddress");
console.log(abc);
if (abc === "No") {
console.log("ADDRESS IS NOT A DUPLICATE - N.B. I NEVER SEE THIS");
}
else
{
console.log("ADDRESS IS A DUPLICATE")
}
}
export function page1_click(event) {
$w("#input1").focus()
}
top of page
Important forum update
This forum is migrating to one unified Wix community forum starting July 26th, and will be read-only during the process.
Wishlist Page is the official platform for requesting new features. You can vote, comment, and track the status of the requested features.
bottom of page
Before the following line:
if (currentAddressBeingChecked === newEmailAddress) {
you could insert the following code:
console.log("currentAddressBeingChecked =" + currentAddressBeingChecked); console.log("newEmailAddress =" + newEmailAddress); console.log("currentAddressBeingChecked === newEmailAddress =" + currentAddressBeingChecked === newEmailAddress);
That might yield insights that could help answer your question.