sign up and login

for months velo team has failed to solve this problem of mine… your help is hghly appreciated…i need the menu to expand when registered and collapse when the logout button is clicked…below is the final code that velo team has given me but unfortunately it doesnt work


import { authentication } from ‘wix-members’ ;
import { currentMember } from ‘wix-members’
import wixLocation from ‘wix-location’ ;
$w . onReady ( async () => {
authentication . onLogin ( async ( member ) => {
const loggedInMember = await member . getMember ();
const memberId = loggedInMember . _id ;
console . log ( Member ${ memberId } logged in : , loggedInMember );
const isLoggedIn = authentication . loggedIn ()
await currentMember . getMember (). then ( member => {
console . log ( typeof ( member ))
console . log ( member )
if ( isLoggedIn ) {
//when logged in /registered
$w ( “#horizontalMenu1” ). expand ()
$w ( “#button8” ). expand ()
$w ( “#button10” ). collapse ()
} else {
//when logout button is clicked
$w ( “#horizontalMenu1” ). collapse ()
$w ( “#button8” ). collapse ()
$w ( “#button10” ). expand ()
}
})
})
$w ( “#button8” ). onClick ( logoutAndRedirect );
});
//logout
function logoutAndRedirect ( event ) {
Promise . all ([ wixLocation . to ( ‘/’ ), authentication . logout ()]);
}