Commit cb759eb5 authored by Valentin's avatar Valentin
Browse files

feat: shopmobile search products/stores fix

parent df53d28d
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -12,7 +12,10 @@
	<ion-list class="brand-dark">
		<div class="products-container">
			<h5
				*ngIf="searchResultProducts?.length === 0"
				*ngIf="
					searchResultProducts.length === 0 &&
					searchResultMerchants.length === 0
				"
				class="not-found-text p-3"
			>
				Empty List
@@ -30,11 +33,11 @@
				<ion-label>{{ merchant.name }} </ion-label>
			</ion-item>

			<div class="center">
			<div class="center" *ngIf="searchResultMerchants.length">
				<ion-button
					color="tertiary"
					size="small"
					(click)="loadMerchants()"
					(click)="loadMoreMerchants()"
					>View More</ion-button
				>
			</div>
@@ -84,11 +87,11 @@
				</ion-row>
			</ion-card>

			<div class="center">
			<div class="center" *ngIf="searchResultProducts.length">
				<ion-button
					color="tertiary"
					size="small"
					(click)="loadProducts()"
					(click)="loadMoreProducts()"
					>View More</ion-button
				>
			</div>
+32 −0
Original line number Diff line number Diff line
@@ -55,6 +55,14 @@ export class SearchProductsComponent implements OnInit {
	}

	async loadMerchants() {
		const location = this.getOrdersGeoObj.loc;
		const merchants = await this.merchantsService.getMerchantsBuyName(
			this.searchInput,
			{ loc: location }
		);
		this.searchResultMerchants = merchants.slice(0, 5);
	}
	async loadMoreMerchants() {
		const location = this.getOrdersGeoObj.loc;
		const merchants = await this.merchantsService.getMerchantsBuyName(
			this.searchInput,
@@ -73,6 +81,30 @@ export class SearchProductsComponent implements OnInit {
			this.store.deliveryType === DeliveryType.Delivery;
		const isTakeaway = this.store.deliveryType === DeliveryType.Takeaway;

		await this.geoLocationProductsService
			.geoLocationProductsByPaging(
				this.getOrdersGeoObj,
				{
					limit: this.loadingOrdersLimit,
					skip: 0,
				},
				{
					isDeliveryRequired,
					isTakeaway,
				},
				this.searchInput
			)
			.pipe(first())
			.subscribe((products) => {
				this.searchResultProducts = products;
				// products.map((pr) => this.searchResultProducts.push(pr));
			});
	}
	async loadMoreProducts() {
		const isDeliveryRequired =
			this.store.deliveryType === DeliveryType.Delivery;
		const isTakeaway = this.store.deliveryType === DeliveryType.Takeaway;

		await this.geoLocationProductsService
			.geoLocationProductsByPaging(
				this.getOrdersGeoObj,