I have this code. I want it so when a user is logged out
#Videoplayer1 is hiden, #text113 shows and #text104 only shows 40 characters.
When a user logs in I want the video player to show, #text113 to hide and #text104 to be the full text description. for some reason its not working.
// API Reference: https://www.wix.com/velo/reference/api-overview/introduction
// “Hello, World!” Example: https://learn-code.wix.com/en/article/1-hello-world
import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';
export function repeater1_itemReady($item1, itemData1, index1) {
if (wixUsers.currentUser.loggedIn) {
wixUsers.currentUser.getPricingPlans()
.then((pricingPlans) => {
if (pricingPlans.length > 0) {
$item1("#videoPlayer1").show();
$item1("#text113").hide();
if (itemData1.url !== "") {
$item1("#videoPlayer1").src = itemData1.url;
}
} else {
$item1("#videoPlayer1").hide();
$item1("#text113").show();
let paragraph = itemData1.description;
var shortText = paragraph.slice(0, 50);
$item1("#text104").text = shortText + ' ...';
}
let currentPlan = pricingPlans[pricingPlans.length - 1];
let planName = currentPlan.name;
let qprice = currentPlan.price;
//let benefits = currentPlan.benefits;
//let sdate = currentPlan.startDate;
let eDate = currentPlan.expiryDate;
});
wixData.query("Favourite")
.eq("userId", wixUsers.currentUser.id)
.find()
.then((results) => {
if (results.items.length > 0) {
let firstItem = results.items[0]; //see item below
results.items.forEach(function (item, i) {
let classid = item.classId;
//console.log("Class=> "+classid);
$w("#repeater1").forEachItem(($item, itemData, index) => {
let currentText = $item("#classID").text;
if (currentText === classid) {
$item("#btnfavourite").style.backgroundColor = "red";
}
});
});
} else {
// handle case where no matching items found
}
})
.catch((err) => {
let errorMsg = err;
$w("#favMsg").text = "" + errorMsg + "";
$w("#favMsg").expand();
});
} else {
$item1("#videoPlayer1").hide();
$item1("#text113").show();
let paragraph = itemData1.description;
var shortText = paragraph.slice(0, 50);
$item1("#text104").text = shortText + ' ...';
}
}