Right now the code below works but in order to work I had to add an extra field(Team name) to the form. I would like to access this field without having to add it to the form and land in the specific dynamic page.
import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';
$w.onReady(function () {
$w("#forgotPassword").onClick((event) => {
//wixWindow.lightbox.close()
wixUsers.promptForgotPassword()
.then(() => {
//
})
.catch((err) => {
let errorMsg = err; //"The user closed the forgot password dialog"
});
});
});
export function submit_click_1(event) {
let email = $w("#email").value;
let password = $w("#password").value;
let team = $w("#teamName").value;
wixUsers.login(email, password)
.then(() => {
console.log("User is logged in");
wixLocation.to("/form/" + team);
})
.catch((err) => {
console.log(err);
$w("#errorMessage").expand();
});
}
import wixData from 'wix-data';// at the top of the code
//...your code.....
export function submit_click_1(event) {
let email = $w("#email").value;
let password = $w("#password").value;
Promise.all([
wixData.query("COLLECTION NAME")
eq("email", email)
.distinct("team"),
wixUsers.login(email, password)
])
.then(r => {
let retrievedTeams = r[0].items;
let team = retrievedTeams[0];
wixLocation.to("/form/" + team);
})
})
//...the rest of the code