|
@@ -1,9 +1,12 @@
|
|
|
-import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
|
|
|
|
|
|
|
+import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
|
|
|
import { FormGroup } from '@angular/forms';
|
|
import { FormGroup } from '@angular/forms';
|
|
|
import { ActivatedRoute, Router } from '@angular/router';
|
|
import { ActivatedRoute, Router } from '@angular/router';
|
|
|
|
|
+import { _ } from 'src/app/core/providers/i18n/mark-for-extraction';
|
|
|
|
|
|
|
|
import { BaseDetailComponent } from '../../../common/base-detail.component';
|
|
import { BaseDetailComponent } from '../../../common/base-detail.component';
|
|
|
import { Order, OrderWithLines } from '../../../common/generated-types';
|
|
import { Order, OrderWithLines } from '../../../common/generated-types';
|
|
|
|
|
+import { NotificationService } from '../../../core/providers/notification/notification.service';
|
|
|
|
|
+import { DataService } from '../../../data/providers/data.service';
|
|
|
import { ServerConfigService } from '../../../data/server-config';
|
|
import { ServerConfigService } from '../../../data/server-config';
|
|
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
@@ -15,7 +18,14 @@ import { ServerConfigService } from '../../../data/server-config';
|
|
|
export class OrderDetailComponent extends BaseDetailComponent<OrderWithLines.Fragment>
|
|
export class OrderDetailComponent extends BaseDetailComponent<OrderWithLines.Fragment>
|
|
|
implements OnInit, OnDestroy {
|
|
implements OnInit, OnDestroy {
|
|
|
detailForm = new FormGroup({});
|
|
detailForm = new FormGroup({});
|
|
|
- constructor(router: Router, route: ActivatedRoute, serverConfigService: ServerConfigService) {
|
|
|
|
|
|
|
+ constructor(
|
|
|
|
|
+ router: Router,
|
|
|
|
|
+ route: ActivatedRoute,
|
|
|
|
|
+ serverConfigService: ServerConfigService,
|
|
|
|
|
+ private changeDetector: ChangeDetectorRef,
|
|
|
|
|
+ private dataService: DataService,
|
|
|
|
|
+ private notificationService: NotificationService,
|
|
|
|
|
+ ) {
|
|
|
super(route, router, serverConfigService);
|
|
super(route, router, serverConfigService);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -38,6 +48,20 @@ export class OrderDetailComponent extends BaseDetailComponent<OrderWithLines.Fra
|
|
|
return Object.entries(payment.metadata);
|
|
return Object.entries(payment.metadata);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ settlePayment(payment: OrderWithLines.Payments) {
|
|
|
|
|
+ this.dataService.order.settlePayment(payment.id).subscribe(({ settlePayment }) => {
|
|
|
|
|
+ if (settlePayment) {
|
|
|
|
|
+ if (settlePayment.state === 'Settled') {
|
|
|
|
|
+ this.notificationService.success(_('order.settle-payment-success'));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.notificationService.error(_('order.settle-payment-error'));
|
|
|
|
|
+ }
|
|
|
|
|
+ payment.state = settlePayment.state;
|
|
|
|
|
+ this.changeDetector.markForCheck();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
protected setFormValues(entity: Order.Fragment): void {
|
|
protected setFormValues(entity: Order.Fragment): void {
|
|
|
// empty
|
|
// empty
|
|
|
}
|
|
}
|