import { ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
import { CoreModule, GetLatestOrdersDocument, SharedModule, SortOrder, } from '@vendure/admin-ui/core';
import { gql } from 'apollo-angular';
import * as i0 from "@angular/core";
import * as i1 from "@vendure/admin-ui/core";
import * as i2 from "@clr/angular";
import * as i3 from "@angular/router";
import * as i4 from "@angular/common";
import * as i5 from "@ngx-translate/core";
const GET_LATEST_ORDERS = gql `
    query GetLatestOrders($options: OrderListOptions) {
        orders(options: $options) {
            items {
                id
                createdAt
                updatedAt
                type
                orderPlacedAt
                code
                state
                total
                totalWithTax
                currencyCode
                customer {
                    id
                    firstName
                    lastName
                }
            }
        }
    }
`;
export class LatestOrdersWidgetComponent {
    constructor(dataService) {
        this.dataService = dataService;
    }
    ngOnInit() {
        this.latestOrders$ = this.dataService
            .query(GetLatestOrdersDocument, {
            options: {
                take: 10,
                filter: {
                    active: { eq: false },
                    state: { notIn: ['Cancelled', 'Draft'] },
                },
                sort: {
                    orderPlacedAt: SortOrder.DESC,
                },
            },
        })
            .refetchOnChannelChange()
            .mapStream(data => data.orders.items);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.2", ngImport: i0, type: LatestOrdersWidgetComponent, deps: [{ token: i1.DataService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.2", type: LatestOrdersWidgetComponent, selector: "vdr-latest-orders-widget", ngImport: i0, template: "<vdr-data-table-2 [items]=\"latestOrders$ | async\" id=\"latest-orders-widget-list\">\n    <vdr-dt2-column [heading]=\"'common.code' | translate\" id=\"code\">\n        <ng-template let-order=\"item\">\n            <a class=\"button-ghost\" [routerLink]=\"['/orders/', order.id]\"\n                ><span>{{ order.code }}</span>\n                <clr-icon shape=\"arrow right\"></clr-icon>\n            </a>\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-column [heading]=\"'order.state' | translate\" id=\"state\" [hiddenByDefault]=\"true\">\n        <ng-template let-order=\"item\">\n            <vdr-order-state-label [state]=\"order.state\"></vdr-order-state-label>\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-column [heading]=\"'customer.customer' | translate\" id=\"customer\" [hiddenByDefault]=\"true\">\n        <ng-template let-order=\"item\">\n            <vdr-customer-label [customer]=\"order.customer\"></vdr-customer-label>\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-column [heading]=\"'order.total' | translate\" id=\"total\">\n        <ng-template let-order=\"item\">\n            {{ order.totalWithTax | localeCurrency : order.currencyCode }}\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-column [heading]=\"'order.placed-at' | translate\" id=\"placed-at\">\n        <ng-template let-order=\"item\">\n            {{ order.orderPlacedAt | timeAgo }}\n        </ng-template>\n    </vdr-dt2-column>\n</vdr-data-table-2>\n", styles: ["vdr-data-table ::ng-deep table{margin-top:0}vdr-order-state-label{display:inline-block;margin-top:2px}\n"], dependencies: [{ kind: "directive", type: i2.ClrIconCustomTag, selector: "clr-icon" }, { kind: "directive", type: i3.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "component", type: i1.CustomerLabelComponent, selector: "vdr-customer-label", inputs: ["customer"] }, { kind: "component", type: i1.OrderStateLabelComponent, selector: "vdr-order-state-label", inputs: ["state"] }, { kind: "component", type: i1.DataTable2Component, selector: "vdr-data-table-2", inputs: ["id", "items", "itemsPerPage", "currentPage", "totalItems", "emptyStateLabel", "filters", "activeIndex"], outputs: ["pageChange", "itemsPerPageChange"] }, { kind: "component", type: i1.DataTable2ColumnComponent, selector: "vdr-dt2-column", inputs: ["id", "expand", "heading", "align", "sort", "optional", "hiddenByDefault", "orderable"], exportAs: ["row"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }, { kind: "pipe", type: i5.TranslatePipe, name: "translate" }, { kind: "pipe", type: i1.TimeAgoPipe, name: "timeAgo" }, { kind: "pipe", type: i1.LocaleCurrencyPipe, name: "localeCurrency" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.2", ngImport: i0, type: LatestOrdersWidgetComponent, decorators: [{
            type: Component,
            args: [{ selector: 'vdr-latest-orders-widget', changeDetection: ChangeDetectionStrategy.OnPush, template: "<vdr-data-table-2 [items]=\"latestOrders$ | async\" id=\"latest-orders-widget-list\">\n    <vdr-dt2-column [heading]=\"'common.code' | translate\" id=\"code\">\n        <ng-template let-order=\"item\">\n            <a class=\"button-ghost\" [routerLink]=\"['/orders/', order.id]\"\n                ><span>{{ order.code }}</span>\n                <clr-icon shape=\"arrow right\"></clr-icon>\n            </a>\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-column [heading]=\"'order.state' | translate\" id=\"state\" [hiddenByDefault]=\"true\">\n        <ng-template let-order=\"item\">\n            <vdr-order-state-label [state]=\"order.state\"></vdr-order-state-label>\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-column [heading]=\"'customer.customer' | translate\" id=\"customer\" [hiddenByDefault]=\"true\">\n        <ng-template let-order=\"item\">\n            <vdr-customer-label [customer]=\"order.customer\"></vdr-customer-label>\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-column [heading]=\"'order.total' | translate\" id=\"total\">\n        <ng-template let-order=\"item\">\n            {{ order.totalWithTax | localeCurrency : order.currencyCode }}\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-column [heading]=\"'order.placed-at' | translate\" id=\"placed-at\">\n        <ng-template let-order=\"item\">\n            {{ order.orderPlacedAt | timeAgo }}\n        </ng-template>\n    </vdr-dt2-column>\n</vdr-data-table-2>\n", styles: ["vdr-data-table ::ng-deep table{margin-top:0}vdr-order-state-label{display:inline-block;margin-top:2px}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.DataService }]; } });
export class LatestOrdersWidgetModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.2", ngImport: i0, type: LatestOrdersWidgetModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.2", ngImport: i0, type: LatestOrdersWidgetModule, declarations: [LatestOrdersWidgetComponent], imports: [CoreModule, SharedModule] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.2", ngImport: i0, type: LatestOrdersWidgetModule, imports: [CoreModule, SharedModule] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.2", ngImport: i0, type: LatestOrdersWidgetModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [CoreModule, SharedModule],
                    declarations: [LatestOrdersWidgetComponent],
                }]
        }] });
//# sourceMappingURL=data:application/json;base64, 