|
|
@@ -2,24 +2,25 @@ 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 { BaseDetailComponent, HistoryEntry } from '@vendure/admin-ui/core';
|
|
|
import {
|
|
|
AdjustmentType,
|
|
|
+ BaseDetailComponent,
|
|
|
CustomFieldConfig,
|
|
|
+ DataService,
|
|
|
+ EditNoteDialogComponent,
|
|
|
GetOrderHistory,
|
|
|
+ HistoryEntry,
|
|
|
+ ModalService,
|
|
|
+ NotificationService,
|
|
|
Order,
|
|
|
OrderDetail,
|
|
|
+ ServerConfigService,
|
|
|
SortOrder,
|
|
|
} from '@vendure/admin-ui/core';
|
|
|
-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 { EMPTY, Observable, of, Subject } from 'rxjs';
|
|
|
-import { map, startWith, switchMap, take } from 'rxjs/operators';
|
|
|
+import { startWith, switchMap, take } from 'rxjs/operators';
|
|
|
|
|
|
-import { EditNoteDialogComponent } from '../../../../core/src/shared/components/edit-note-dialog/edit-note-dialog.component';
|
|
|
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';
|
|
|
@@ -73,7 +74,7 @@ export class OrderDetailComponent extends BaseDetailComponent<OrderDetail.Fragme
|
|
|
createdAt: SortOrder.DESC,
|
|
|
},
|
|
|
})
|
|
|
- .mapStream((data) => data.order?.history.items);
|
|
|
+ .mapStream(data => data.order?.history.items);
|
|
|
}),
|
|
|
);
|
|
|
}
|
|
|
@@ -87,7 +88,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[] {
|
|
|
@@ -100,7 +101,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;
|
|
|
}
|
|
|
@@ -111,8 +112,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) {
|
|
|
@@ -133,7 +134,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: {
|
|
|
@@ -141,16 +142,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'));
|
|
|
}
|
|
|
@@ -174,7 +175,7 @@ export class OrderDetailComponent extends BaseDetailComponent<OrderDetail.Fragme
|
|
|
},
|
|
|
})
|
|
|
.pipe(
|
|
|
- switchMap((transactionId) => {
|
|
|
+ switchMap(transactionId => {
|
|
|
if (transactionId) {
|
|
|
return this.dataService.order.settleRefund(
|
|
|
{
|
|
|
@@ -189,7 +190,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'));
|
|
|
}
|
|
|
@@ -204,8 +205,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(_('common.notify-create-success'), {
|
|
|
entity: 'Note',
|
|
|
});
|
|
|
@@ -223,7 +224,7 @@ export class OrderDetailComponent extends BaseDetailComponent<OrderDetail.Fragme
|
|
|
},
|
|
|
})
|
|
|
.pipe(
|
|
|
- switchMap((result) => {
|
|
|
+ switchMap(result => {
|
|
|
if (result) {
|
|
|
return this.dataService.order.updateOrderNote({
|
|
|
noteId: entry.id,
|
|
|
@@ -235,7 +236,7 @@ export class OrderDetailComponent extends BaseDetailComponent<OrderDetail.Fragme
|
|
|
}
|
|
|
}),
|
|
|
)
|
|
|
- .subscribe((result) => {
|
|
|
+ .subscribe(result => {
|
|
|
this.fetchHistory.next();
|
|
|
this.notificationService.success(_('common.notify-update-success'), {
|
|
|
entity: 'Note',
|
|
|
@@ -253,7 +254,7 @@ export class OrderDetailComponent extends BaseDetailComponent<OrderDetail.Fragme
|
|
|
{ type: 'danger', label: _('common.delete'), returnValue: true },
|
|
|
],
|
|
|
})
|
|
|
- .pipe(switchMap((res) => (res ? this.dataService.order.deleteOrderNote(entry.id) : EMPTY)))
|
|
|
+ .pipe(switchMap(res => (res ? this.dataService.order.deleteOrderNote(entry.id) : EMPTY)))
|
|
|
.subscribe(() => {
|
|
|
this.fetchHistory.next();
|
|
|
this.notificationService.success(_('common.notify-delete-success'), {
|
|
|
@@ -271,16 +272,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'));
|
|
|
}
|
|
|
@@ -296,10 +297,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,
|
|
|
@@ -315,9 +316,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'));
|
|
|
}
|