logged in user read and write page

@givemeawhisky
Thanks so i think it will work

I think i know where now that this isn’t working, the initial collection just isn’t saving as it was before. I am not seeing any logs in the console as should be happening and was happening. I think i’ll need to raise a ticket because the code is long on this page

import {local} from ‘wix-storage’;
import wixLocation from “wix-location”;
import wixData from ‘wix-data’;

export function button22_click(event) {
$w(‘#columnStrip12’).collapse();
$w(‘#columnStrip8’).expand();
}

export function dropdown4_change(event) {
$w(‘#button25’).expand();
}
export function button25_click(event) {
$w(‘#columnStrip8’).collapse();
$w(‘#columnStrip1’).expand();
}

export function button24_click(event) {
$w(‘#columnStrip1’).collapse();
$w(‘#columnStrip9’).expand();
}

export function vectorImage3_click(event) {
$w(‘#box9’).expand();
$w(‘#vectorImage2’).expand();
}

export function vectorImage2_click(event) {
$w(‘#box9’).collapse();
}

export function dropdown1_change(event) {
$w(‘#button23’).expand();
}
export function button23_click(event) {
$w(‘#columnStrip9’).collapse();
$w(‘#columnStrip11’).expand();
}

//photo upload code
export function uploadButton4_change(event) {
$w(‘#button19’).expand();
$w(‘#text80’).hide();
$w(‘#text96’).expand();
}

export function button19_click(event) {
if ($w(“#uploadButton4”).value.length > 0) {
$w(“#text96”).text = Uploading ${$w("#uploadButton4").value[0].name};
$w(‘#image44’).show();
$w(“#uploadButton4”).startUpload()
.then( (uploadedFile) => {
let toInsert =
{“photo”:
uploadedFile.url };
$w(“#text96”).text = “Upload successful”;
$w(‘#text96’).collapse();
$w(‘#image44’).hide();
$w(‘#text96’).expand();
$w(“#uploadButton4”).disable();
$w(‘#button21’).show();
$w(“#image46”).src = uploadedFile.url;

wixData.insert(“TextData”, toInsert)
.then( (results) => {
let item = results; //see item below

} )
. catch ( (err) => {
let errorMsg = err;
} );

  }) 
  . **catch** ( (uploadError) => { 
    $w("#text96").text = "File upload error"; 

  }); 

}
else {
$w(“#text96”).text = “Please choose a file to upload.”;
}

$w(‘#button19’).hide();

}

export function button1_click(event) {
$w(‘#columnStrip11’).collapse();
$w(‘#columnStrip10’).expand();
}

//change element IDs and Field Keys as necessary for you’re specific setup
export function button21_click(event) {

$w(‘#button21’).onClick( function () {

console.log(‘i am slow, give me a few more seconds to fetch the image URL’);
$w(“#uploadButton4”).startUpload()
.then( (imageUploaded) => {

let imageURL = imageUploaded.url

      console.log(imageURL); 

let toInsert = {

// consider also uploading the registered users ID or Email Address so that you can identify who uploaded the information

“relationship”: $w(‘#dropdown6’).value,
“field”: $w(‘#dropdown4’).value,
“firstName”: $w(‘#input1’).value,
“lastName”: $w(‘#input2’).value,
“dateOfBirth”: $w(‘#input3’).value,
“dateOfDeath”: $w(‘#input4’).value,
“nickName”: $w(‘#input5’).value,
“createdBy”: $w(‘#input6’).value,
“composureAssistant”: $w(‘#dropdown1’).value,
“post”: $w(‘#richTextBox1’).value,
“photo”: imageURL

}; 


            wixData.insert("TextData", toInsert)  
                .then((results) => { 

                    console.log("user input saved to database"); 


              }) 

}) 
}) 

wixLocation.to(“/memberpersonalisereview”);
console.log(“/memberpersonalisereview”);

}

Thanks
Adam