import { isNullOrUndefined } from 'util';
import { Features } from './user.model';

export class CustomerFeatures {
  online: boolean;
  guest: boolean;
  card: boolean;
  employee: boolean;

  constructor(features: Features[]) {
    if (features && features.length > 0) {
      this.online = !isNullOrUndefined(features.find((feature) => feature.key === 'onlineshop'));
      this.guest = !isNullOrUndefined(features.find((feature) => feature.key === 'guestaccount'));
      this.card = !isNullOrUndefined(features.find((feature) => feature.key === 'p4mUser'));
      this.employee = !isNullOrUndefined(features.find((feature) => feature.key === 'staff'));
    } else {
      this.online = false;
      this.guest = false;
      this.card = false;
      this.employee = false;
    }
  }
}
