import {
  Component,
  OnInit,
  OnDestroy,
  ChangeDetectionStrategy,
  ChangeDetectorRef,
  Input,
  EventEmitter,
  Output
} from '@angular/core';
import { UserInfo } from '@ucap/protocol-sync';
import { UserInfoSS, UserInfoF, UserInfoDN } from '@ucap/protocol-query';

export type UserInfoTypes = UserInfo | UserInfoSS | UserInfoF | UserInfoDN;

@Component({
  selector: 'ucap-local-organization-profile-list-item',
  templateUrl: './profile-list-item.component.html',
  styleUrls: ['./profile-list-item.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class ProfileListItemComponent implements OnInit, OnDestroy {
  @Input()
  set userInfo(user: UserInfoTypes) {
    this._userInfo = user;
  }
  get userInfo(): UserInfoTypes {
    return this._userInfo;
  }
  _userInfo: UserInfoTypes;

  @Input()
  defaultProfileImage: string;

  @Input()
  profileImageRoot: string;

  @Input()
  checkable = false;

  @Output()
  checkUser = new EventEmitter<{
    isChecked: boolean;
    userInfo: UserInfoTypes;
  }>();

  constructor(private changeDetectorRef: ChangeDetectorRef) {}

  ngOnInit(): void {}

  ngOnDestroy(): void {}

  onClickProfileImage(event: Event, userInfo: UserInfoTypes): void {}

  onChangeCheck(
    value: boolean,
    userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN
  ) {
    this.checkUser.emit({
      isChecked: value,
      userInfo
    });
  }
}
