
import { Component, Input } from '@angular/core';
import * as utils from '@nativescript/core/utils/utils';
import { transitionOptions } from '~/constants/shared.constants';
import { SERVER_URL } from '~/constants/api.constants';
import { CongEventDetailOutput } from '~/pages/event/entities/cong-event-detail.types';
import { RouterExtensions } from '@nativescript/angular';
export const SKAUTIS_CONGRESS_EVENT_REGISTRATION_URL = `${SERVER_URL}Junak/OrganizationUnit/Registration/Detail.aspx`

@Component({
    selector: 'CongEventBaseDetail',
    moduleId: module.id,
    templateUrl: './cong-event-base-detail.component.html',
})
export class CongEventBaseDetailComponent {
    @Input()
    eventDetail: CongEventDetailOutput;
    @Input()
    isLoading: boolean;
    constructor(private routerExtensions: RouterExtensions,
    ) {
    }

    openRegistration() {
        const url = `${SKAUTIS_CONGRESS_EVENT_REGISTRATION_URL}?ID=${this.eventDetail.ID_UnitRegistration}&ID_Unit=${this.eventDetail.ID_Unit}?`
        utils.openUrl(url);
    }
    openUnit() {
        setTimeout(() => {
            this.routerExtensions.navigate(['unit', this.eventDetail.ID_Unit], { transition: transitionOptions });
        }, 10);
    }
}