I have a page: Edit Your Registrations that has a button for uploading photos. This button loads a Lightbox called Upload Registry Photos that contains a Cloudinary Upload Widget. When the user closes the widget it sends me an email notification using sendgrid. All this is working fine. What I am trying to do is add the uploading user’s email to the message.
For the calling page: Edit Your Registrations code is as follows:
import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;
import {local, session} from ‘wix-storage’;
$w.onReady( function () {
let user = wixUsers.currentUser;
let userEmail;
let userId = user.id;
user.getEmail()
.then( (email) => {
userEmail = String(email);
$w(‘#userEmail’).text = userEmail;
$w(“#dataset1”).setFilter(wixData.filter()
.eq(“email”,userEmail)
).then(() => {
$w(“#image21”).hide();
$w(“#repeater1”).show();
session.setItem(userEmail);
console.log(userEmail) <========== CORRECTLY DISPLAYS EMAIL
});
} );
});
In the Lightbox: I have this code:
import wixData from ‘wix-data’;
import wixWindow from ‘wix-window’;
import wixLocation from ‘wix-location’;
import {sendEmail, sendEmailWithRecipient} from ‘backend/email’;
import {local, session} from ‘wix-storage’;
import {lightbox} from ‘wix-window’;
$w.onReady( function () {
//TODO: write your page related code here…
let replyto = ‘#text113’;
let regitem = lightbox.getContext();
replyto = session.getItem(“userEmail”); // “value”
console.log(replyto); <==============LOGS “undefined”
});
export function closeButton_click(event, $w) {
const subject = Photos Uploaded To Cloudinary
;
const body = New Photos Just Added By \rEmail: replyto
sendEmail(subject, body)
.then(response => console.log(response));
}
What am I missing here?
Thanks
JD