import { Component, EventEmitter, Input, Output } from '@angular/core';
import { deleteIcon, editIcon } from '~/constants/icons';
import { TeamMember } from '~/pages/event/containers/gen/gen-event-update-leader-modal/gen-event-update-leader-modal.component';

@Component({
    selector: 'LeaderTable',
    moduleId: module.id,
    templateUrl: './leader-table.component.html',
    styleUrls: ['../../../event.scss']
})
export class LeaderTableComponent {
    getMembers() {
        return this.showEmpty ? this.members : this.members.filter(m => m.memberName);
    }

    @Input() members: TeamMember[]

    @Input() title: string;
    @Output() onDelete = new EventEmitter<TeamMember>();
    @Output() onUpdate = new EventEmitter<TeamMember>();
    @Input() showEmpty: boolean = true;
    deleteIcon = deleteIcon;
    editIcon = editIcon;

    isEmpty() {
        return this.members.every(m => !m.memberName);
    }
}
