Commit 0b8282ba authored by YavorGrancharov's avatar YavorGrancharov
Browse files

fix: view carrier info and deliveries error

parent 0cd54217
Loading
Loading
Loading
Loading
+89 −93
Original line number Diff line number Diff line
@@ -19,14 +19,14 @@ import _ from 'lodash';
import { LocalDataSource } from 'ng2-smart-table';
import { Subject, Observable } from 'rxjs/Rx';
import { TranslateService } from '@ngx-translate/core';
import { forkJoin, Subscription } from 'rxjs';
import { forkJoin, Subscription, of } from 'rxjs';
import { CreatedComponent } from '../../../../@shared/render-component/created/created.component';
import { CarriersService } from '@app/@core/data/carriers.service';
import { GeoLocationOrdersService } from '@app/@core/data/geo-location-orders.service';
import GeoLocation from '@modules/server.common/entities/GeoLocation';
import { StoreOrderComponent } from '@app/@shared/render-component/carrier-orders-table/store-order.component';
import { UserOrderComponent } from '@app/@shared/render-component/carrier-orders-table/user-order-component';
import { takeUntil } from 'rxjs/operators';
import { takeUntil, catchError } from 'rxjs/operators';

const perPage = 3;
let searchCustomer: boolean;
@@ -58,6 +58,7 @@ export class CarrierOrdersComponent
	private _isWork: boolean;
	private dataCount: number;
	private $locationOrders: Subscription;
	subscription: Subscription;

	public carrierOnlineStatus = CarrierStatus.Online;

@@ -95,16 +96,16 @@ export class CarrierOrdersComponent
		this.loadSmartTableTranslates();
		this.smartTableChange();

		CarrierOrdersComponent.$customerSearch
			.pipe(takeUntil(this.ngDestroy$))
			.subscribe(async (searchText: string) => {
		this.subscription = CarrierOrdersComponent.$customerSearch.subscribe(
			async (searchText: string) => {
				await this.loadDataCount({
					byRegex: [{ key: 'user.firstName', value: searchText }],
				});
				await this.loadSmartTableData(1, {
					byRegex: [{ key: 'user.firstName', value: searchText }],
				});
			});
			}
		);
	}

	ngOnChanges() {
@@ -170,9 +171,8 @@ export class CarrierOrdersComponent
	}

	async smartTableChange() {
		this.sourceSmartTable
		this.subscription = this.sourceSmartTable
			.onChanged()
			.pipe(takeUntil(this.ngDestroy$))
			.subscribe(async (event) => {
				if (event.action === 'page') {
					const page = event.paging.page;
@@ -225,16 +225,14 @@ export class CarrierOrdersComponent
		const getTranslate = (name: string): Observable<string | any> =>
			this._translateService.get(columnTitlePrefix + name);

		forkJoin(
		this.subscription = forkJoin(
			this._translateService.get('Id'),
			getTranslate('WAREHOUSE'),
			getTranslate('CUSTOMER'),
			getTranslate('WAREHOUSE_STATUS'),
			getTranslate('CARRIER_STATUS'),
			getTranslate('CREATED')
		)
			.pipe(takeUntil(this.ngDestroy$))
			.subscribe(
		).subscribe(
			([
				id,
				warehouse,
@@ -261,10 +259,7 @@ export class CarrierOrdersComponent
								cell?: string,
								search?: string
							): boolean {
									if (
										!searchCustomer &&
										oldSearch !== search
									) {
								if (!searchCustomer && oldSearch !== search) {
									oldSearch = search;

									searchCustomer = true;
@@ -285,9 +280,9 @@ export class CarrierOrdersComponent
							type: 'string',
							valuePrepareFunction: (_, order: Order) => {
								let warehouseStat = 'BAD_STATUS';
									getTranslate(order.warehouseStatusText)
										.pipe(takeUntil(this.ngDestroy$))
										.subscribe((y) => {
								getTranslate(
									order.warehouseStatusText
								).subscribe((y) => {
									warehouseStat = y;
								});

@@ -299,11 +294,11 @@ export class CarrierOrdersComponent
							type: 'string',
							valuePrepareFunction: (_, order: Order) => {
								let carrierStat = 'No Status';
									getTranslate(order.carrierStatusText)
										.pipe(takeUntil(this.ngDestroy$))
										.subscribe((y) => {
								getTranslate(order.carrierStatusText).subscribe(
									(y) => {
										carrierStat = y;
										});
									}
								);

								return carrierStat;
							},
@@ -364,7 +359,6 @@ export class CarrierOrdersComponent
				},
				searchObj
			)
			.pipe(takeUntil(this.ngDestroy$))
			.subscribe(async (ordersForWork: Order[]) => {
				const currentOrder = await this.carriersService.getCarrierCurrentOrder(
					this.selectedCarrier.id
@@ -388,5 +382,7 @@ export class CarrierOrdersComponent
	ngOnDestroy() {
		this.ngDestroy$.next();
		this.ngDestroy$.complete();
		this.subscription.unsubscribe();
		this.$locationOrders.unsubscribe();
	}
}