import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { DEFAULT_CHANNEL_CODE } from '@vendure/common/lib/shared-constants';
import { GET_SELLER_ORDERS } from './seller-orders-card.graphql';
import * as i0 from "@angular/core";
import * as i1 from "@angular/router";
import * as i2 from "@vendure/admin-ui/core";
import * as i3 from "@clr/angular";
import * as i4 from "@angular/common";
import * as i5 from "@ngx-translate/core";
export class SellerOrdersCardComponent {
    constructor(router, dataService, channelService) {
        this.router = router;
        this.dataService = dataService;
        this.channelService = channelService;
    }
    ngOnInit() {
        this.sellerOrders$ = this.dataService
            .query(GET_SELLER_ORDERS, {
            orderId: this.orderId,
        })
            .mapSingle(({ order }) => order?.sellerOrders ?? []);
    }
    getSeller(order) {
        const sellerChannel = order.channels.find(channel => channel.code !== DEFAULT_CHANNEL_CODE);
        return sellerChannel?.seller;
    }
    navigateToSellerOrder(order) {
        this.router.navigate(['/orders', order.id]);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.2", ngImport: i0, type: SellerOrdersCardComponent, deps: [{ token: i1.Router }, { token: i2.DataService }, { token: i2.ChannelService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.2", type: SellerOrdersCardComponent, selector: "vdr-seller-orders-card", inputs: { orderId: "orderId" }, ngImport: i0, template: "<vdr-card [title]=\"'order.seller-orders' | translate\">\n    <div class=\"form-grid\">\n        <div *ngFor=\"let order of sellerOrders$ | async\">\n            <a [routerLink]=\"['seller-orders', order.id]\" class=\"button-ghost mb-1\"\n                >{{ order.code }} <clr-icon shape=\"arrow right\"></clr-icon\n            ></a>\n            <vdr-labeled-data [label]=\"'order.state' | translate\">\n                <vdr-order-state-label [state]=\"order.state\"></vdr-order-state-label>\n            </vdr-labeled-data>\n            <vdr-labeled-data *ngIf=\"getSeller(order) as seller\" [label]=\"'common.seller' | translate\">\n                {{ seller.name }}\n            </vdr-labeled-data>\n            <vdr-labeled-data *ngIf=\"getSeller(order) as seller\" [label]=\"'order.total' | translate\">\n                {{ order.totalWithTax | localeCurrency : order.currencyCode }}\n            </vdr-labeled-data>\n        </div>\n    </div>\n</vdr-card>\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "directive", type: i3.ClrIconCustomTag, selector: "clr-icon" }, { kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "component", type: i2.OrderStateLabelComponent, selector: "vdr-order-state-label", inputs: ["state"] }, { kind: "component", type: i2.LabeledDataComponent, selector: "vdr-labeled-data", inputs: ["label"] }, { kind: "component", type: i2.CardComponent, selector: "vdr-card", inputs: ["title", "paddingX"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }, { kind: "pipe", type: i5.TranslatePipe, name: "translate" }, { kind: "pipe", type: i2.LocaleCurrencyPipe, name: "localeCurrency" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.2", ngImport: i0, type: SellerOrdersCardComponent, decorators: [{
            type: Component,
            args: [{ selector: 'vdr-seller-orders-card', changeDetection: ChangeDetectionStrategy.OnPush, template: "<vdr-card [title]=\"'order.seller-orders' | translate\">\n    <div class=\"form-grid\">\n        <div *ngFor=\"let order of sellerOrders$ | async\">\n            <a [routerLink]=\"['seller-orders', order.id]\" class=\"button-ghost mb-1\"\n                >{{ order.code }} <clr-icon shape=\"arrow right\"></clr-icon\n            ></a>\n            <vdr-labeled-data [label]=\"'order.state' | translate\">\n                <vdr-order-state-label [state]=\"order.state\"></vdr-order-state-label>\n            </vdr-labeled-data>\n            <vdr-labeled-data *ngIf=\"getSeller(order) as seller\" [label]=\"'common.seller' | translate\">\n                {{ seller.name }}\n            </vdr-labeled-data>\n            <vdr-labeled-data *ngIf=\"getSeller(order) as seller\" [label]=\"'order.total' | translate\">\n                {{ order.totalWithTax | localeCurrency : order.currencyCode }}\n            </vdr-labeled-data>\n        </div>\n    </div>\n</vdr-card>\n", styles: [":host{display:block}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.Router }, { type: i2.DataService }, { type: i2.ChannelService }]; }, propDecorators: { orderId: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 