import { Component, Injector, OnInit, ViewChild, ViewEncapsulation, Input, ViewChildren } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { AppConsts } from '@shared/AppConsts';
import { appModuleAnimation } from '@shared/animations/routerTransition';
import { AppComponentBase } from '@shared/common/app-component-base';
import { OrderServiceProxy, OrderListDto, ControllerOrderPackagesListServiceProxy, ControllerOrderPackagesListDto } from '@shared/service-proxies/service-proxies';

import * as moment from 'moment';
import { LazyLoadEvent } from 'primeng/components/common/lazyloadevent';
import { Paginator } from 'primeng/components/paginator/paginator';
import { Table } from 'primeng/components/table/table';
import { HttpClient } from '@angular/common/http';
import { finalize } from 'rxjs/operators';

@Component({
    templateUrl: './order-packages-detail.component.html',
    encapsulation: ViewEncapsulation.None,
    animations: [appModuleAnimation()],
    providers: [ControllerOrderPackagesListServiceProxy]
})

export class ControllerOrderPackageDetailComponent extends AppComponentBase  implements OnInit{
    @ViewChild('dataTable', {static: true}) dataTable: Table;
    @ViewChild('paginator', {static: true}) paginator: Paginator;
    @Input() filters: {
        locationFilter : number;
        startDate: Date;
        endDate: Date
    } = < any > {};
    filterText: string;

    orderPackageId : number;

    orderPackage: ControllerOrderPackagesListDto = new ControllerOrderPackagesListDto();


  constructor(
        injector: Injector,
        private id:ActivatedRoute,
        private _controllerOrderPackageAppService: ControllerOrderPackagesListServiceProxy
        
    ) {
        super(injector);
    }

    ngOnInit(): void {
    this.id.paramMap.subscribe(params => {
            this.orderPackageId = Number(params.get('id'));
        });
        
    }

    // getOrderPackageDetail(): void{
    //     this._controllerOrderPackageAppService
    //         .getControllerOrderPackageDetails(
    //             this.orderPackageId
    //         ).subscribe(result => {
    //                 this.orderPackageId=result.
    //                 console.log(result)
    //                 this.spinnerService.hide();
    //             });
    // }

    // getOrderPackage(): void {
    //     this._controllerOrderPackageAppService
    //     .getControllerOrderPackageDetails(
    //         this.orderPackageId )   
    //     .pipe(finalize(() => this.spinnerService.hide() ))
    //     .subscribe(result => {
            
    //         this.spinnerService.hide();
    //         // console.log(result.items)
    //     });
    // }
  
    // getOrder(event: LazyLoadEvent): void
    // {
 
    //     if (this.primengTableHelper.shouldResetPaging(event)) {
    //         this.paginator.changePage(0);
    //         return;
    //     }
    //     this.filters.startDate = new Date(this.filters.startDate.toString());
    //     this.filters.endDate = new Date(this.filters.endDate.toString());
    //     let startDate = moment(moment(this.filters.startDate).format('YYYY-MM-DD HH:mm:ss'));
    //     let endDate = moment(moment(this.filters.endDate).format('YYYY-MM-DD HH:mm:ss'));

    //     let startDateA = startDate['_i'].split(' ');
    //     startDateA = startDateA[0] + ' ' + '00:00:00';

    //     let endDateA = endDate['_i'].split(' ');
    //     endDateA = endDateA[0] + ' ' + '23:59:59';
        
        
    //      this.spinnerService.show();
         
    //      console.log(this.filters.locationFilter);

    //      this._orderAppService.getOrderList(
    //         undefined,
    //         this.filterText,
    //         undefined,
    //         this.filters.locationFilter,
    //         moment.utc(moment(startDateA).toISOString()),
    //         this.primengTableHelper.getSorting(this.dataTable),
    //         this.primengTableHelper.getMaxResultCount(this.paginator, event),
    //         this.primengTableHelper.getSkipCount(this.paginator, event)
    //     ).pipe(finalize(() => this.spinnerService.hide())).subscribe(result => {
    //         this.primengTableHelper.totalRecordsCount = result.totalCount;
    //         this.primengTableHelper.records = result.items;
    //         console.log(result.items);
    //         this.spinnerService.hide();
    //     });

       
    // }

    
}