Commit 632d53e9 authored by RAHUL RATHORE's avatar RAHUL RATHORE
Browse files

fix: customer geo location filter & duplicate customer component

parent 2e74352b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ export class GeoLocationService {
			})
			.valueChanges.pipe(
				map((res) =>
					res.data.geoLocationProducts.filter(
					res.data.geoLocationProducts.filter(Boolean).filter(
						(p) => p.warehouseProduct.isProductAvailable === true
					)
				),
+2 −3
Original line number Diff line number Diff line
<toaster-container> </toaster-container>

<div *ngIf="user$ | async as user" class="row">
<div *ngIf="(user$ | async) as user" class="row">
	<div class="col-md-8">
		<nb-card>
			<nb-card-header class="row">
@@ -64,8 +64,7 @@
							'CUSTOMERS_VIEW.NEARBY_STORES' | translate
						}}"
					>
						<ea-customer-stores [currentUser]="selectedUser">
						</ea-customer-stores>
						<ea-customer-stores [currentUser]="selectedUser"></ea-customer-stores>
					</nb-tab>
				</nb-tabset>
			</nb-card-body>
+3 −7
Original line number Diff line number Diff line
@@ -8,9 +8,7 @@ import { HighlightModule } from 'ngx-highlightjs';
import { ThemeModule } from '../../../@theme';
import { CustomerComponent } from './customer.component';
import { CustomerInfoComponent } from './ea-customer-info/ea-customer-info.component';
import { CustomerProductsComponent } from './ea-customer-products/ea-customer-products/ea-customer-products.component';
// duplicate CustomerProductsComponent
import { CustomerProductsComponent as RootCustomerProductsComponent } from './ea-customer-products/ea-customer-products.component';
import { CustomerProductsComponent } from './ea-customer-products/ea-customer-products.component';
import { CustomerLocationComponent } from './ea-customer-location/ea-customer-location.component';
import { CustomerStoresComponent } from './ea-customer-stores/ea-customer-stores.component';
import { CustomerOrdersTableModule } from '../../../@shared/render-component/customer-orders-table/customer-orders-table.module';
@@ -64,10 +62,8 @@ const routes = [
		CustomerLocationComponent,
		CustomerInfoComponent,
		CustomerProductsComponent,
		RootCustomerProductsComponent,
		CustomerStoresComponent,
		CustomerMetricsComponent,
	],
	entryComponents: [],
		CustomerMetricsComponent
	]
})
export class CustomerModule {}
+0 −0

File moved.

+10 −23
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ import { ActivatedRoute } from '@angular/router';
import { LocalDataSource } from 'ng2-smart-table';
import Warehouse from '@modules/server.common/entities/Warehouse';
import { UserRouter } from '@modules/client.common.angular2/routers/user-router.service';
import { first, takeUntil } from 'rxjs/operators';
import { takeUntil } from 'rxjs/operators';
import { DomSanitizer } from '@angular/platform-browser';
import { WarehousesService } from '../../../../@core/data/warehouses.service';
import ProductInfo from '@modules/server.common/entities/ProductInfo';
@@ -12,21 +12,12 @@ import { StoreOrderProductsComponent } from '../../../../@shared/render-componen
import { OrderBtnOrderProductsComponent } from '../../../../@shared/render-component/customer-products-table/order-btn-order-products/order-btn-order-products.component';
import { GeoLocationService } from '../../../../@core/data/geo-location.service';
import { TranslateService } from '@ngx-translate/core';
import { forkJoin, Observable, Subject } from 'rxjs';
import { firstValueFrom, forkJoin, Observable, Subject } from 'rxjs';

@Component({
	selector: 'ea-customer-products',
	styleUrls: ['./ea-customer-products.scss'],
	template: `
		<nb-card>
			<nb-card-body>
				<ng2-smart-table
					[settings]="settingsSmartTable"
					[source]="sourceSmartTable"
				></ng2-smart-table>
			</nb-card-body>
		</nb-card>
	`,
	templateUrl: './ea-customer-products.component.html',
	styleUrls: ['./ea-customer-products.scss']
})
export class CustomerProductsComponent implements OnDestroy, OnInit {
	private ngDestroy$ = new Subject<void>();
@@ -51,15 +42,12 @@ export class CustomerProductsComponent implements OnDestroy, OnInit {
	) {
		this.params$ = this._router.params.subscribe(async (res) => {
			this.userId = res.id;
			const user = await this.userRouter
				.get(this.userId)
				.pipe(first())
				.toPromise();

			const user = await firstValueFrom(
				this.userRouter.get(this.userId)
			);
			if (user == null) {
				throw new Error(`User can't be found (id: ${this.userId})`);
			}

			this.availableProductsSubscription$ = this.geoLocationProductService
				.getGeoLocationProducts(user.geoLocation)
				.subscribe((products) => {
@@ -159,10 +147,9 @@ export class CustomerProductsComponent implements OnDestroy, OnInit {
	}

	private async _loadWarehouses() {
		this.warehouses = await this._warehousesService
			.getStores()
			.pipe(first())
			.toPromise();
		this.warehouses = await firstValueFrom(
			this._warehousesService.getStores()
		);
	}

	ngOnDestroy(): void {
Loading