Hi,
@ahmadnasriya @jonatandor35
I have number input field, radio button selection (1 of 3), picture upload and submit button.
Im trying to get current user info, double check that he is existing in that database and then upload information. Radio button inserts data, but number input field and picture is not. In database it states that “Input fields does not match” even tho they match. Can someone help me? Maybe this code approach is in general to complicated?
var userID, userEmail
$w.onReady(function () { getUserInfo() });
export function button3_click(event) {check_User()}
function check_User (parameter) { console.log("Checking....")
wixData.query("FishUploads")
.eq("_owner" ,userID)
.find()
.then( (results) => {
if(results.items.length > 0) {console.log("User is Found")
console.log(userID)
console.log(userEmail)
let toInsert = {
"title": userEmail,
"fishUpload": $w('#input1').value,
"fishBreed": $w('#radioGroup1').value,
"fishPicture": $w('#uploadButton1').startUpload(),
};
wixData.insert("FishUploads", toInsert)
.then( (res) => {
console.log(res.items)
console.log("New data saved")
$w('#text30').show();
$w('#button3').disable()
$w('#input1').value = ""
$w('#uploadButton1').value = ""
} )
} else {console.log("User does not exists")
$w('#text136').show();
$w('#repeater1').hide();
}
} )
.catch( (err) => {
let errorMsg = err;
} );
}
function getUserInfo (parameter) {
let user = wixUsers.currentUser;
userID = user.id; // "r5cme-6fem-485j-djre-4844c49"
let isLoggedIn = user.loggedIn; // true
user.getEmail()
.then( (email) => {
userEmail = email; // "user@something.com"
} );
console.log("User loaded.")
}
export function close_click(event) {
$w('#repeater1').hide()