
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { GenEventDetailOutput } from '~/pages/event/entities/gen-event-detail.types';
import * as dialogs from "@nativescript/core/ui/dialogs";
import { GenEventStateEnum } from '~/pages/event/state-mgmt/gen/gen-event-detail.state';

@Component({
    selector: 'GenEventStateDetail',
    moduleId: module.id,
    templateUrl: './gen-event-state-detail.component.html',
})
export class GenEventStateDetailComponent {
    @Input()
    eventDetail: GenEventDetailOutput;
    @Input()
    isLoading: boolean = true;

    @Output()
    onUpdateEventState = new EventEmitter();
    closeEvent() {
        const options = {
            title: "Uzavřít akci",
            message: `Opravdu chcete akci ${this.eventDetail.DisplayName} uzavřít?`,
            okButtonText: "Ano",
            cancelButtonText: "Ne"
        };
        dialogs.confirm(options).then((result: boolean) => {
            if (result) {
                this.onUpdateEventState.emit({ eventId: this.eventDetail.ID, currentStateId: this.eventDetail.ID_EventGeneralState })
            };
        });
    }

    get closable() {
        return this.eventDetail.ID_EventGeneralState !== GenEventStateEnum.CLOSED;
    }

}