|
|
@@ -2,10 +2,6 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, OnIni
|
|
|
import { FormGroup } from '@angular/forms';
|
|
|
import { ActivatedRoute, Router } from '@angular/router';
|
|
|
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
|
|
-import { omit } from '@vendure/common/lib/omit';
|
|
|
-import { Observable, of, Subject } from 'rxjs';
|
|
|
-import { startWith, switchMap, take } from 'rxjs/operators';
|
|
|
-
|
|
|
import { BaseDetailComponent } from '@vendure/admin-ui/core';
|
|
|
import {
|
|
|
AdjustmentType,
|
|
|
@@ -19,6 +15,10 @@ import { NotificationService } from '@vendure/admin-ui/core';
|
|
|
import { DataService } from '@vendure/admin-ui/core';
|
|
|
import { ServerConfigService } from '@vendure/admin-ui/core';
|
|
|
import { ModalService } from '@vendure/admin-ui/core';
|
|
|
+import { omit } from '@vendure/common/lib/omit';
|
|
|
+import { Observable, of, Subject } from 'rxjs';
|
|
|
+import { startWith, switchMap, take } from 'rxjs/operators';
|
|
|
+
|
|
|
import { CancelOrderDialogComponent } from '../cancel-order-dialog/cancel-order-dialog.component';
|
|
|
import { FulfillOrderDialogComponent } from '../fulfill-order-dialog/fulfill-order-dialog.component';
|
|
|
import { RefundOrderDialogComponent } from '../refund-order-dialog/refund-order-dialog.component';
|
|
|
@@ -33,7 +33,7 @@ import { SettleRefundDialogComponent } from '../settle-refund-dialog/settle-refu
|
|
|
export class OrderDetailComponent extends BaseDetailComponent<OrderDetail.Fragment>
|
|
|
implements OnInit, OnDestroy {
|
|
|
detailForm = new FormGroup({});
|
|
|
- history$: Observable<GetOrderHistory.Items[] | null>;
|
|
|
+ history$: Observable<GetOrderHistory.Items[] | null | undefined>;
|
|
|
fetchHistory = new Subject<void>();
|
|
|
customFields: CustomFieldConfig[];
|
|
|
orderLineCustomFields: CustomFieldConfig[];
|
|
|
@@ -72,7 +72,7 @@ export class OrderDetailComponent extends BaseDetailComponent<OrderDetail.Fragme
|
|
|
createdAt: SortOrder.DESC,
|
|
|
},
|
|
|
})
|
|
|
- .mapStream(data => data.order && data.order.history.items);
|
|
|
+ .mapStream((data) => data.order && data.order.history.items);
|
|
|
}),
|
|
|
);
|
|
|
}
|
|
|
@@ -86,7 +86,7 @@ export class OrderDetailComponent extends BaseDetailComponent<OrderDetail.Fragme
|
|
|
}
|
|
|
|
|
|
getLinePromotions(line: OrderDetail.Lines) {
|
|
|
- return line.adjustments.filter(a => a.type === AdjustmentType.PROMOTION);
|
|
|
+ return line.adjustments.filter((a) => a.type === AdjustmentType.PROMOTION);
|
|
|
}
|
|
|
|
|
|
getPromotionLink(promotion: OrderDetail.Adjustments): any[] {
|
|
|
@@ -99,7 +99,7 @@ export class OrderDetailComponent extends BaseDetailComponent<OrderDetail.Fragme
|
|
|
promotionAdjustment: OrderDetail.Adjustments,
|
|
|
): string | undefined {
|
|
|
const id = promotionAdjustment.adjustmentSource.split(':')[1];
|
|
|
- const promotion = order.promotions.find(p => p.id === id);
|
|
|
+ const promotion = order.promotions.find((p) => p.id === id);
|
|
|
if (promotion) {
|
|
|
return promotion.couponCode || undefined;
|
|
|
}
|
|
|
@@ -110,8 +110,8 @@ export class OrderDetailComponent extends BaseDetailComponent<OrderDetail.Fragme
|
|
|
return [];
|
|
|
}
|
|
|
return Object.values(shippingAddress)
|
|
|
- .filter(val => val !== 'OrderAddress')
|
|
|
- .filter(line => !!line);
|
|
|
+ .filter((val) => val !== 'OrderAddress')
|
|
|
+ .filter((line) => !!line);
|
|
|
}
|
|
|
|
|
|
settlePayment(payment: OrderDetail.Payments) {
|
|
|
@@ -131,7 +131,7 @@ export class OrderDetailComponent extends BaseDetailComponent<OrderDetail.Fragme
|
|
|
this.entity$
|
|
|
.pipe(
|
|
|
take(1),
|
|
|
- switchMap(order => {
|
|
|
+ switchMap((order) => {
|
|
|
return this.modalService.fromComponent(FulfillOrderDialogComponent, {
|
|
|
size: 'xl',
|
|
|
locals: {
|
|
|
@@ -139,16 +139,16 @@ export class OrderDetailComponent extends BaseDetailComponent<OrderDetail.Fragme
|
|
|
},
|
|
|
});
|
|
|
}),
|
|
|
- switchMap(input => {
|
|
|
+ switchMap((input) => {
|
|
|
if (input) {
|
|
|
return this.dataService.order.createFullfillment(input);
|
|
|
} else {
|
|
|
return of(undefined);
|
|
|
}
|
|
|
}),
|
|
|
- switchMap(result => this.refetchOrder(result)),
|
|
|
+ switchMap((result) => this.refetchOrder(result)),
|
|
|
)
|
|
|
- .subscribe(result => {
|
|
|
+ .subscribe((result) => {
|
|
|
if (result) {
|
|
|
this.notificationService.success(_('order.create-fulfillment-success'));
|
|
|
}
|
|
|
@@ -172,7 +172,7 @@ export class OrderDetailComponent extends BaseDetailComponent<OrderDetail.Fragme
|
|
|
},
|
|
|
})
|
|
|
.pipe(
|
|
|
- switchMap(transactionId => {
|
|
|
+ switchMap((transactionId) => {
|
|
|
if (transactionId) {
|
|
|
return this.dataService.order.settleRefund(
|
|
|
{
|
|
|
@@ -187,7 +187,7 @@ export class OrderDetailComponent extends BaseDetailComponent<OrderDetail.Fragme
|
|
|
}),
|
|
|
// switchMap(result => this.refetchOrder(result)),
|
|
|
)
|
|
|
- .subscribe(result => {
|
|
|
+ .subscribe((result) => {
|
|
|
if (result) {
|
|
|
this.notificationService.success(_('order.settle-refund-success'));
|
|
|
}
|
|
|
@@ -202,8 +202,8 @@ export class OrderDetailComponent extends BaseDetailComponent<OrderDetail.Fragme
|
|
|
note,
|
|
|
isPublic,
|
|
|
})
|
|
|
- .pipe(switchMap(result => this.refetchOrder(result)))
|
|
|
- .subscribe(result => {
|
|
|
+ .pipe(switchMap((result) => this.refetchOrder(result)))
|
|
|
+ .subscribe((result) => {
|
|
|
this.notificationService.success(_('order.add-note-success'));
|
|
|
});
|
|
|
}
|
|
|
@@ -217,16 +217,16 @@ export class OrderDetailComponent extends BaseDetailComponent<OrderDetail.Fragme
|
|
|
},
|
|
|
})
|
|
|
.pipe(
|
|
|
- switchMap(input => {
|
|
|
+ switchMap((input) => {
|
|
|
if (input) {
|
|
|
return this.dataService.order.cancelOrder(input);
|
|
|
} else {
|
|
|
return of(undefined);
|
|
|
}
|
|
|
}),
|
|
|
- switchMap(result => this.refetchOrder(result)),
|
|
|
+ switchMap((result) => this.refetchOrder(result)),
|
|
|
)
|
|
|
- .subscribe(result => {
|
|
|
+ .subscribe((result) => {
|
|
|
if (result) {
|
|
|
this.notificationService.success(_('order.cancelled-order-success'));
|
|
|
}
|
|
|
@@ -242,10 +242,10 @@ export class OrderDetailComponent extends BaseDetailComponent<OrderDetail.Fragme
|
|
|
},
|
|
|
})
|
|
|
.pipe(
|
|
|
- switchMap(input => {
|
|
|
+ switchMap((input) => {
|
|
|
if (input) {
|
|
|
return this.dataService.order.refundOrder(omit(input, ['cancel'])).pipe(
|
|
|
- switchMap(result => {
|
|
|
+ switchMap((result) => {
|
|
|
if (input.cancel.length) {
|
|
|
return this.dataService.order.cancelOrder({
|
|
|
orderId: this.id,
|
|
|
@@ -261,9 +261,9 @@ export class OrderDetailComponent extends BaseDetailComponent<OrderDetail.Fragme
|
|
|
return of(undefined);
|
|
|
}
|
|
|
}),
|
|
|
- switchMap(result => this.refetchOrder(result)),
|
|
|
+ switchMap((result) => this.refetchOrder(result)),
|
|
|
)
|
|
|
- .subscribe(result => {
|
|
|
+ .subscribe((result) => {
|
|
|
if (result) {
|
|
|
this.notificationService.success(_('order.refund-order-success'));
|
|
|
}
|