Hide/Show member pages based on User role

They are both old and use an old version of Velo API.
You can do:

import { currentMember, authentication } from 'wix-members';
$w.onReady(() => {
if(authentication.loggedIn()){getRoles();}
authentication.onLogin(getRoles);
})
function getRoles(){
 currentMember.getRoles()
 .then(roles => {
  roles = roles.map(e => e.title);
  if(roles.includes('Role A')){
   $w('#element1').show();
   $w('#element2').hide();
  } else if(roles.includes('Role B')){
   $w('#element2').show();
   $w('#element1').hide()
  }
 })
}

EDITED