import { Component, OnInit } from '@angular/core';
import { ModalDialogParams, RouterExtensions } from '@nativescript/angular';
import { SortParams, formattedSortDirection } from '~/pages/event/types/EventSorting';
import { Picker } from '~/pages/event/util';


@Component({
    selector: 'SortModalComponent',
    moduleId: module.id,
    templateUrl: './sort-modal.component.html',
})
export class SortModalComponent implements OnInit {

    sortParams: SortParams;
    formattedSortDirection: Array<Picker> = formattedSortDirection;
    formattedSortByKeys: Array<Picker>;
    constructor(
        private routerExtensions: RouterExtensions,
        private params: ModalDialogParams,

    ) {
    }
    ngOnInit(): void {
        const { sortParams, formattedSortByKeys } = this.params.context;
        this.sortParams = sortParams;
        this.formattedSortByKeys = formattedSortByKeys
    }
    close() {
        this.params.closeCallback();
    }

    submit() {

        this.params.closeCallback({
            ...this.sortParams,
        });
    }

    onBackButton(): void {
        this.routerExtensions.back();
    }
}