Unverified Commit 11249406 authored by Ruslan Konviser's avatar Ruslan Konviser Committed by GitHub
Browse files

Merge pull request #1211 from ever-co/fix/#1206-webshop-orders-not-updating

fix: orders and status not updating immediately
parents 42af42e6 61ccc20a
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
import { Component, Input, OnInit } from '@angular/core';
import { Component, Input, OnInit, NgZone } from '@angular/core';
import Order from '@modules/server.common/entities/Order';
import {
	animate,
@@ -64,7 +64,8 @@ export class OrderComponent implements OnInit {
		private readonly carrierRouter: CarrierRouter,
		private readonly _productLocalesService: ProductLocalesService,
		private translateService: TranslateService,
		private dialog: MatDialog
		private dialog: MatDialog,
		private readonly ngZone: NgZone
	) {}

	openDialog(): void {
@@ -119,6 +120,7 @@ export class OrderComponent implements OnInit {
			.get(this.order.warehouseId, false)
			.pipe(first())
			.subscribe((store) => {
				this.ngZone.run(() => {
					this.warehouse = store;

					this.orderCancelationCheck(
@@ -126,6 +128,7 @@ export class OrderComponent implements OnInit {
						this.order
					);
				});
			});

		if (this.order.carrierId) {
			this.carrierRouter
+14 −4
Original line number Diff line number Diff line
import { Component } from '@angular/core';
import { Component, NgZone } from '@angular/core';
import { UserOrdersRouter } from '@modules/client.common.angular2/routers/user-orders-router.service';
import Order from '@modules/server.common/entities/Order';
import { Store } from 'app/services/store';

@Component({
	selector: 'orders-container',
	template: '<orders *ngIf="orders " [orders]="orders"></orders>',
	template: `
		<orders *ngIf="orders" [orders]="orders"></orders>
		<div
			*ngIf="!orders.length"
			style="text-align:center; font-size:28px;margin:20px 0"
		>
			There is no orders ...
		</div>
	`,
})
export class OrdersContainerComponent {
	// TODO: add correct type of orders variable!
@@ -15,13 +23,15 @@ export class OrdersContainerComponent {

	constructor(
		private readonly userOrdersRouter: UserOrdersRouter,
		private readonly ngZone: NgZone,
		private readonly store: Store
	) {
		const userId = store.userId;
		// During testing: this.userOrdersRouter.getOrderedProducts('23');
		this.userOrdersRouter.get(userId).subscribe((res) => {
			this.ngZone.run(() => {
				this.orders = res.filter((r) => !r.isCancelled);
			res = res.filter((r) => !r.isCancelled);
			});
		});
	}
}