Good day. I have a scenario where components are being shown depending on the condition, I am looking for a clear way ang optimized way to do this. I have a service below that will check 3 conditions like if user exists in the same account , user exists in other account and user does not exists on any account.
if user exists with other account show div 1 and hide div 2 and div 3. If user does not exists on any account show div 2 and hide div 1 and div 3. If user exists in the same account then hide all div.
The showing and hiding of div show always trigger as long as getStarted function is called. Any idea guys ? Thank you.
#let us say I have 3 divs
<div class="1">
</div>
<div class="2">
</div>
<div class="3">
</div>
getStarted() {
if (this.userService) {
this.userService.checkUserEmail(this.accountId,email).subscribe(
(res: any) => {
if (res.isSuccess === false) {
console.log("user already exists on this account")
} else if (res.isSuccess === true) {
console.log("user exists on another account")
} else {
console.log("User does not exist on any accounts")
}
},
(err: any) => {
this.notificationService.showError('Something went wrong, Try again later.');
}
);
} else {
this.notificationService.showError('Something went wrong, Try again later.');
}
}