Wix Badge Assign

import wixUsers from 'wix-users';

 

let user = wixUsers.currentUser;

 

$w.onReady(function () {

$w('#stripLoading').expand();

if (user.loggedIn) {

user.getRoles()

.then((roles) => {

 

if (roles.some(r => r.name === "Grade 1")) {

$w('#stripLoading').collapse();

$w('#stripG1').expand();

} else {

$w('#stripLoading').collapse();

$w('#stripNoOrders').expand();

}

 

if (roles.some(r => r.name === "Grade 2")) {

$w('#stripLoading').collapse();

$w('#stripG2').expand();

} else {

$w('#stripLoading').collapse();

$w('#stripNoOrders').expand();

}

});

}

})