Better but still not in CODE-BLOCKS.
It should look like this one… clear and in CODE-BLOCKS.
import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';
let user = wixUsers.currentUser;
$w.onReady(function(){
if (user.loggedIn){getUserDetails()}
$w('#country').onChange(() => {
if ($w('#country').value === 'Programado') {
$w('#fecha').enable();
$w('#dropdownHora').enable();
}
else {
$w('#fecha').disable();
$w('#dropdownHora').disable();
}
});
});
async function getUserDetails() {
// Get the user email
let email = await user.getEmail().then((result)=>{return result})
// Now get the user full name
let name = await wixData.query('Members/PrivateMembersData')
.eq('_id', user.id)
.find()
.then((result) => {
return result.items[0].name;
});
// Set the fields' values based on the data we have
$w('#input1').value = name;
$w('#input3').value = email;
}
export function sendButton_click(){
let inputs = [$w("#input5"), $w("#input6"), $w("#input1"), $w("#input3"),
$w("#dropdown1"), $w("#country")];
inputs.forEach(e => e.required = true);
let toInsert = {
"nombre": $w("#input1").value,
"email": $w("#input3").value,
"inconveniente": $w("#dropdown1").value,
"anydeskId": $w("#input5").value,
"whatsApp": $w("#input6").value,
"tiempoDeSoporte": $w("#country").value,
"fecha": $w("#fecha").value,
"horaText": $w("#dropdownHora").value,
"estado": $w("#input7").value,
"comentario": $w("#textBox1").value,
"nuevoCampo": $w("#uploadButton1").value,
};
//..inside the sendButton.onClick event handler
if(inputs.every(e => e.valid)){
wixLocation.to("/thks-page");
}else {$w("#error").show();}
wixData.insert("soporte", toInsert)
.then(()=>{ })
.catch((err)=>{let errorMsg = err; console.log(errorMsg), $w("#error").show();});
}
Perhaps now you will get some answer from J.D.