Hi i´m trying to do a client dashboard
i have followed the article
but i´m having some trouble
the profile page are not finding the correct dynamic page for the id
i ve got 2 dynamic page
one for the table query results - where it showns my customers page
another dynamic page is for update all these customers informations , that is going to be showned in the table results.
but i´m not having sucess to do the second one - profile page to update all these infos.
here is my website
lupeweb.com
here is my codes
import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;
$w.onReady( () => {
if(wixUsers.currentUser.loggedIn) {
$w(“#loginButton”).label = “Logout”;
$w(“#profileButton”).show();
}
else {
$w(“#loginButton”).label = “Login”;
$w(“#profileButton”).hide();
}
} );
export function loginButton_click_1(event) {
// user is logged in
if(wixUsers.currentUser.loggedIn) {
// log the user out
wixUsers.logout()
.then( () => {
// update buttons accordingly
$w(“#loginButton”).label = “Login”;
$w(“#profileButton”).hide();
} );
}
// user is logged out
else {
let userId;
let userEmail;
// prompt the user to log in
wixUsers.promptLogin( {"mode": "login"} )
.then( (user) => {
userId = user.id;
return user.getEmail();
} )
.then( (email) => {
// check if there is an item for the user in the collection
userEmail = email;
return wixData.query("database_trade")
.eq("_id", userId)
.find();
} )
.then( (results) => {
// if an item for the user is not found
if (results.items.length === 0) {
// create an item
const toInsert = {
"_id": userId,
"email": userEmail
};
// add the item to the collection
wixData.insert("database_trade", toInsert)
.catch( (err) => {
console.log(err);
} );
}
// update buttons accordingly
$w("#loginButton").label = "Logout";
$w("#profileButton").show();
} )
.catch( (err) => {
console.log(err);
} );
}
}
export function profileButton_click(event, $w) {
wixLocation.to(/database-trade/Update/${wixUsers.currentUser.id}
);
}
the profile page is appearing but is not with the correct information on it
the query is not having the correct id result
how can i solve these
tks
for these registered email
the correct database ID is : 795177f6-92e3-414e-92c2-beb8c5e0a83a
and the query in the codes are having these id result: 8fce7765-01e1-4bcb-af39-bafe68a02afe
i don´t know where i´m doing wrong
the wrong page
this is the correct that need to be shown