Loading packages/shop-mobile-ionic/src/app/pages/+products/+searchProducts/searchProducts.component.html +18 −24 Original line number Diff line number Diff line Loading @@ -6,39 +6,29 @@ placeholder="Product or a shop name" animated debounce="500" (ionChange)="loadProducts()" (ionChange)="loadFullData()" ></ion-searchbar> <!-- <ion-list class="merchants-list"> <ion-list-header class="p-0 mb-1"> </ion-list-header> <div class="merchants-container"> <h5 *ngIf="searchResultMerchants?.length === 0" class="not-found-text"> ne e namereno <ion-list class="brand-dark"> <div class="products-container"> <h5 *ngIf="searchResultProducts?.length === 0" class="not-found-text p-3" > Empty List </h5> <ion-item color="medium" *ngFor="let merchant of searchResultMerchants" (click)="selectMerchant(merchant)" class="m-2" lines="none" class="m-2" > <ion-avatar slot="start"> <img src="{{ merchant.logo }}" /> <img [src]="merchant.logo" /> </ion-avatar> <ion-label>{{ merchant.name }} </ion-label> </ion-item> </div> </ion-list> --> <ion-list class="brand-dark"> <div class="products-container"> <h5 *ngIf="searchResultProducts?.length === 0" class="not-found-text p-3" > Empty List </h5> <ion-item *ngFor="let product of searchResultProducts" Loading @@ -46,7 +36,11 @@ class="m-2" > <ion-avatar slot="start"> <img src="{{ product.warehouseLogo }}" /> <img [src]=" product.warehouseProduct.product['images'][0].url " /> </ion-avatar> <ion-label >{{ product.warehouseProduct.product['title'][0].value }} Loading packages/shop-mobile-ionic/src/app/pages/+products/+searchProducts/searchProducts.component.ts +36 −68 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ import { ILocation } from '@modules/server.common/interfaces/IGeoLocation'; import GeoLocation from '@modules/server.common/entities/GeoLocation'; import RegistrationSystem from '@modules/server.common/enums/RegistrationSystem'; import ProductInfo from '@modules/server.common/entities/ProductInfo'; import DeliveryType from '@modules/server.common/enums/DeliveryType'; import { MerchantsService } from 'app/services/merchants/merchants.service'; import { Store } from 'app/services/store.service'; import { UserRouter } from '@modules/client.common.angular2/routers/user-router.service'; Loading @@ -22,9 +22,9 @@ import { GeoLocationProductsService } from 'app/services/geo-location/geo-locati styleUrls: ['./searchProducts.style.scss'], }) export class SearchProductsComponent implements OnInit { searchInput: string; searchResultMerchants: Warehouse[]; searchResultProducts: ProductInfo[]; searchInput: string = ''; searchResultMerchants: Warehouse[] = []; searchResultProducts: ProductInfo[] = []; getOrdersGeoObj: { loc: ILocation }; constructor( Loading @@ -36,77 +36,45 @@ export class SearchProductsComponent implements OnInit { private router: Router ) {} ngOnInit() { this.loadGeoLocationProducts(); this.loadFullData(); } async loadProducts() { await this.geoLocationProductsService .geoLocationProductsByPaging(this.getOrdersGeoObj, { skip: 0, limit: 100, }) .pipe(first()) .subscribe((products: ProductInfo[]) => { this.filterProducts(products); }); async loadFullData() { await this.loadGeoLocationProducts(); this.loadMerchants(); this.loadProducts(); console.log(this.searchResultProducts); } filterProducts(products: ProductInfo[]) { if (products) { const filteredProducts = products.filter((product) => { const title = product.warehouseProduct.product['title']; const result = title.filter((t) => t.value .toLowerCase() .includes(this.searchInput.toLowerCase()) async loadMerchants() { const location = this.getOrdersGeoObj.loc; const merchants = await this.merchantsService.getMerchantsBuyName( this.searchInput, { loc: location } ); if (result.length === 0) { return false; } return result; }); this.searchResultProducts = filteredProducts; // .filter(prod=>prod.warehouseProduct.isDeliveryRequired === !+this.store.deliveryType) // console.log(this.searchResultProducts) this.searchResultMerchants = merchants.slice(0, 5); } } // async loadSearchMerchants() { // const location = await this.getLocation(); // this.searchResultMerchants = await this.merchantsService.getMerchantsBuyName( // this.searchInput, // { loc: location } // ); // } // private async getLocation() { // let location: ILocation; // const isProductionEnv = environment.production; // if (this.store.userId && isProductionEnv) { // const user = await this.userRouter // .get(this.store.userId) // .pipe(first()) // .toPromise(); // location = { // type: 'Point', // coordinates: user.geoLocation.loc.coordinates, // }; // } else { // const findGeoLocation = await this.geoLocationService.getCurrentGeoLocation(); // location = { // type: 'Point', // coordinates: findGeoLocation.loc.coordinates, // }; // } async loadProducts() { const isDeliveryRequired = this.store.deliveryType === DeliveryType.Delivery; const isTakeaway = this.store.deliveryType === DeliveryType.Takeaway; // return location; // } await this.geoLocationProductsService .geoLocationProductsByPaging( this.getOrdersGeoObj, { limit: 20 }, { isDeliveryRequired, isTakeaway, }, this.searchInput ) .pipe(first()) .subscribe((products) => { this.searchResultProducts = products; }); } private async loadGeoLocationProducts() { let geoLocationForProducts: GeoLocation; Loading Loading
packages/shop-mobile-ionic/src/app/pages/+products/+searchProducts/searchProducts.component.html +18 −24 Original line number Diff line number Diff line Loading @@ -6,39 +6,29 @@ placeholder="Product or a shop name" animated debounce="500" (ionChange)="loadProducts()" (ionChange)="loadFullData()" ></ion-searchbar> <!-- <ion-list class="merchants-list"> <ion-list-header class="p-0 mb-1"> </ion-list-header> <div class="merchants-container"> <h5 *ngIf="searchResultMerchants?.length === 0" class="not-found-text"> ne e namereno <ion-list class="brand-dark"> <div class="products-container"> <h5 *ngIf="searchResultProducts?.length === 0" class="not-found-text p-3" > Empty List </h5> <ion-item color="medium" *ngFor="let merchant of searchResultMerchants" (click)="selectMerchant(merchant)" class="m-2" lines="none" class="m-2" > <ion-avatar slot="start"> <img src="{{ merchant.logo }}" /> <img [src]="merchant.logo" /> </ion-avatar> <ion-label>{{ merchant.name }} </ion-label> </ion-item> </div> </ion-list> --> <ion-list class="brand-dark"> <div class="products-container"> <h5 *ngIf="searchResultProducts?.length === 0" class="not-found-text p-3" > Empty List </h5> <ion-item *ngFor="let product of searchResultProducts" Loading @@ -46,7 +36,11 @@ class="m-2" > <ion-avatar slot="start"> <img src="{{ product.warehouseLogo }}" /> <img [src]=" product.warehouseProduct.product['images'][0].url " /> </ion-avatar> <ion-label >{{ product.warehouseProduct.product['title'][0].value }} Loading
packages/shop-mobile-ionic/src/app/pages/+products/+searchProducts/searchProducts.component.ts +36 −68 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ import { ILocation } from '@modules/server.common/interfaces/IGeoLocation'; import GeoLocation from '@modules/server.common/entities/GeoLocation'; import RegistrationSystem from '@modules/server.common/enums/RegistrationSystem'; import ProductInfo from '@modules/server.common/entities/ProductInfo'; import DeliveryType from '@modules/server.common/enums/DeliveryType'; import { MerchantsService } from 'app/services/merchants/merchants.service'; import { Store } from 'app/services/store.service'; import { UserRouter } from '@modules/client.common.angular2/routers/user-router.service'; Loading @@ -22,9 +22,9 @@ import { GeoLocationProductsService } from 'app/services/geo-location/geo-locati styleUrls: ['./searchProducts.style.scss'], }) export class SearchProductsComponent implements OnInit { searchInput: string; searchResultMerchants: Warehouse[]; searchResultProducts: ProductInfo[]; searchInput: string = ''; searchResultMerchants: Warehouse[] = []; searchResultProducts: ProductInfo[] = []; getOrdersGeoObj: { loc: ILocation }; constructor( Loading @@ -36,77 +36,45 @@ export class SearchProductsComponent implements OnInit { private router: Router ) {} ngOnInit() { this.loadGeoLocationProducts(); this.loadFullData(); } async loadProducts() { await this.geoLocationProductsService .geoLocationProductsByPaging(this.getOrdersGeoObj, { skip: 0, limit: 100, }) .pipe(first()) .subscribe((products: ProductInfo[]) => { this.filterProducts(products); }); async loadFullData() { await this.loadGeoLocationProducts(); this.loadMerchants(); this.loadProducts(); console.log(this.searchResultProducts); } filterProducts(products: ProductInfo[]) { if (products) { const filteredProducts = products.filter((product) => { const title = product.warehouseProduct.product['title']; const result = title.filter((t) => t.value .toLowerCase() .includes(this.searchInput.toLowerCase()) async loadMerchants() { const location = this.getOrdersGeoObj.loc; const merchants = await this.merchantsService.getMerchantsBuyName( this.searchInput, { loc: location } ); if (result.length === 0) { return false; } return result; }); this.searchResultProducts = filteredProducts; // .filter(prod=>prod.warehouseProduct.isDeliveryRequired === !+this.store.deliveryType) // console.log(this.searchResultProducts) this.searchResultMerchants = merchants.slice(0, 5); } } // async loadSearchMerchants() { // const location = await this.getLocation(); // this.searchResultMerchants = await this.merchantsService.getMerchantsBuyName( // this.searchInput, // { loc: location } // ); // } // private async getLocation() { // let location: ILocation; // const isProductionEnv = environment.production; // if (this.store.userId && isProductionEnv) { // const user = await this.userRouter // .get(this.store.userId) // .pipe(first()) // .toPromise(); // location = { // type: 'Point', // coordinates: user.geoLocation.loc.coordinates, // }; // } else { // const findGeoLocation = await this.geoLocationService.getCurrentGeoLocation(); // location = { // type: 'Point', // coordinates: findGeoLocation.loc.coordinates, // }; // } async loadProducts() { const isDeliveryRequired = this.store.deliveryType === DeliveryType.Delivery; const isTakeaway = this.store.deliveryType === DeliveryType.Takeaway; // return location; // } await this.geoLocationProductsService .geoLocationProductsByPaging( this.getOrdersGeoObj, { limit: 20 }, { isDeliveryRequired, isTakeaway, }, this.searchInput ) .pipe(first()) .subscribe((products) => { this.searchResultProducts = products; }); } private async loadGeoLocationProducts() { let geoLocationForProducts: GeoLocation; Loading