import { Component, OnInit, Input } from '@angular/core';
import { NGXLogger } from 'ngx-logger';
import { StatusBulkInfo, StatusInfo } from '@ucap-webmessenger/protocol-status';
import { StatusCode, PresenceType } from '@ucap-webmessenger/core';

@Component({
  selector: 'ucap-profile-my-profile-widget',
  templateUrl: './my-profile-widget.component.html',
  styleUrls: ['./my-profile-widget.component.scss']
})
export class MyProfileWidgetComponent implements OnInit {
  @Input()
  profileImageRoot: string;
  @Input()
  profileImageFile: string;
  @Input()
  presence: StatusBulkInfo | StatusInfo;

  PresenceType = PresenceType;

  constructor(private logger: NGXLogger) {}

  ngOnInit() {}

  getPresence(type: PresenceType): string {
    let status: string;
    let rtnClass = '';
    switch (type) {
      case PresenceType.PC:
        status = !!this.presence ? this.presence.pcStatus : undefined;
        break;
      case PresenceType.MOBILE:
        status = !!this.presence ? this.presence.mobileStatus : undefined;
        break;
    }

    if (!!status) {
      switch (status) {
        case StatusCode.OnLine:
          rtnClass = type + 'On';
          break;
        case StatusCode.Away:
          rtnClass = type + 'Out';
          break;
        case StatusCode.Busy:
          rtnClass = type + 'Other';
          break;
        default:
          rtnClass = type + 'Off';
          break;
      }
    }

    return rtnClass;
  }
}
