From 6f36d4e87e83ddbe148790cb14f700123e5d49f0 Mon Sep 17 00:00:00 2001 From: Khanh Nguyen Date: Tue, 23 Jul 2024 19:33:28 +0700 Subject: [PATCH] Handle FE issue --- .../product-detail-feedback.component.ts | 21 +---------------- .../product-star-rating.service.ts | 5 ++-- .../product-detail.component.ts | 23 +++++++++++++++---- 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/marketplace-ui/src/app/modules/product/product-detail/product-detail-feedback/product-detail-feedback.component.ts b/marketplace-ui/src/app/modules/product/product-detail/product-detail-feedback/product-detail-feedback.component.ts index ebc5c5872..5f6c3f2dc 100644 --- a/marketplace-ui/src/app/modules/product/product-detail/product-detail-feedback/product-detail-feedback.component.ts +++ b/marketplace-ui/src/app/modules/product/product-detail/product-detail-feedback/product-detail-feedback.component.ts @@ -31,7 +31,7 @@ const MAX_ELEMENTS = 6; templateUrl: './product-detail-feedback.component.html', styleUrls: ['./product-detail-feedback.component.scss'] }) -export class ProductDetailFeedbackComponent implements OnInit, AfterViewInit { +export class ProductDetailFeedbackComponent implements OnInit { isMobileMode = input(); isShowBtnMore: Signal = computed(() => { if ( @@ -58,18 +58,6 @@ export class ProductDetailFeedbackComponent implements OnInit, AfterViewInit { this.productStarRatingService.fetchData(); } - ngAfterViewInit(): void { - this.route.queryParams.subscribe(params => { - this.showPopup = params['showPopup'] === 'true'; - if (this.showPopup && this.authService.getToken()) { - this.appModalService.openAddFeedbackDialog().then( - () => this.removeQueryParam(), - () => this.removeQueryParam() - ); - } - }); - } - openShowFeedbacksDialog(): void { if (this.isMobileMode()) { this.productFeedbackService.loadMoreFeedbacks(); @@ -77,11 +65,4 @@ export class ProductDetailFeedbackComponent implements OnInit, AfterViewInit { this.appModalService.openShowFeedbacksDialog(); } } - - private removeQueryParam(): void { - this.router.navigate([], { - queryParams: { showPopup: null }, - queryParamsHandling: 'merge' - }); - } } diff --git a/marketplace-ui/src/app/modules/product/product-detail/product-detail-feedback/product-star-rating-panel/product-star-rating.service.ts b/marketplace-ui/src/app/modules/product/product-detail/product-detail-feedback/product-star-rating-panel/product-star-rating.service.ts index 9f4345c61..c8af47d13 100644 --- a/marketplace-ui/src/app/modules/product/product-detail/product-detail-feedback/product-star-rating-panel/product-star-rating.service.ts +++ b/marketplace-ui/src/app/modules/product/product-detail/product-detail-feedback/product-star-rating-panel/product-star-rating.service.ts @@ -1,4 +1,4 @@ -import { HttpClient } from '@angular/common/http'; +import { HttpClient, HttpContext } from '@angular/common/http'; import { computed, inject, @@ -10,6 +10,7 @@ import { import { tap } from 'rxjs'; import { StarRatingCounting } from '../../../../../shared/models/star-rating-counting.model'; import { ProductDetailService } from '../../product-detail.service'; +import { SkipLoading } from '../../../../../core/interceptors/api.interceptor'; @Injectable({ providedIn: 'root' @@ -29,7 +30,7 @@ export class ProductStarRatingService { fetchData(productId: string = this.productDetailService.productId()): void { const requestURL = `api/feedback/product/${productId}/rating`; this.http - .get(requestURL) + .get(requestURL, {context: new HttpContext().set(SkipLoading, true)}) .pipe( tap(data => { this.sortByStar(data); diff --git a/marketplace-ui/src/app/modules/product/product-detail/product-detail.component.ts b/marketplace-ui/src/app/modules/product/product-detail/product-detail.component.ts index 482a93e1d..b40b2f615 100644 --- a/marketplace-ui/src/app/modules/product/product-detail/product-detail.component.ts +++ b/marketplace-ui/src/app/modules/product/product-detail/product-detail.component.ts @@ -128,6 +128,18 @@ export class ProductDetailComponent { this.updateDropdownSelection(); } + ngAfterViewInit(): void { + this.checkMediaSize(); + this.route.queryParams.subscribe(params => { + this.showPopup = params['showPopup'] === 'true'; + if (this.showPopup && this.authService.getToken()) { + this.appModalService.openAddFeedbackDialog().then( + () => this.removeQueryParam() + ); + } + }); + } + getContent(value: string): boolean { const content = this.productModuleContent(); const conditions: { [key: string]: boolean } = { @@ -203,10 +215,6 @@ export class ProductDetailComponent { } } - ngAfterViewInit(): void { - this.checkMediaSize(); - } - @HostListener('window:resize', ['$event']) onResize() { this.checkMediaSize(); @@ -233,4 +241,11 @@ export class ProductDetailComponent { receiveInstallationCountData(data: number) { this.installationCount = data; } + + private removeQueryParam(): void { + this.router.navigate([], { + queryParams: { showPopup: null }, + queryParamsHandling: 'merge' + }); + } }