Received the array below from a service which contains roles of a logged in user: roles = ['MM_VIEW', EM_VIEW]
I have a specific requirement where I need to check if the user has any of these roles - MM_VIEW, MM_EDIT, MM_DELETE. Based on this, I need to execute certain logic.
I am considering whether to create an enum or use direct OR conditions like the one shown below:
if (user.roles.includes('MM_VIEW') || user.roles.includes('MM_EDIT') || user.roles.includes('MM_DELETE')) {
this.appImgPIIError.emit(true);
} else {
this.appImgPIIError.emit(false);
}
While this solution works, I am not entirely comfortable with hard coding values in my component. Any suggestions would be greatly appreciated. Thank you.