Is there a more user-friendly way to retrieve different data based on the type in my Angular component?
I'm considering separating the component into two: one for phone and one for email. However, I'm concerned about duplicating most of the logic.
let getContactInfo;
let hasContactInfo;
if(type === 'email') {
getContactInfo = (profile) => profile.getEmail();
hasContactInfo = (profile) => profile.hasEmail();
} else if(type === 'phone') {
getContactInfo = (profile) => profile.getPhone();
hasContactInfo = (profile) => profile.hasPhone();
}