Skip to content

Commit

Permalink
Handle FE issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ndkhanh-axonivy committed Jul 23, 2024
1 parent ccfbec8 commit 6f36d4e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>();
isShowBtnMore: Signal<boolean> = computed(() => {
if (
Expand All @@ -58,30 +58,11 @@ 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();
} else {
this.appModalService.openShowFeedbacksDialog();
}
}

private removeQueryParam(): void {
this.router.navigate([], {
queryParams: { showPopup: null },
queryParamsHandling: 'merge'
});
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HttpClient } from '@angular/common/http';
import { HttpClient, HttpContext } from '@angular/common/http';
import {
computed,
inject,
Expand All @@ -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'
Expand All @@ -29,7 +30,7 @@ export class ProductStarRatingService {
fetchData(productId: string = this.productDetailService.productId()): void {
const requestURL = `api/feedback/product/${productId}/rating`;
this.http
.get<StarRatingCounting[]>(requestURL)
.get<StarRatingCounting[]>(requestURL, {context: new HttpContext().set(SkipLoading, true)})
.pipe(
tap(data => {
this.sortByStar(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 } = {
Expand Down Expand Up @@ -203,10 +215,6 @@ export class ProductDetailComponent {
}
}

ngAfterViewInit(): void {
this.checkMediaSize();
}

@HostListener('window:resize', ['$event'])
onResize() {
this.checkMediaSize();
Expand All @@ -233,4 +241,11 @@ export class ProductDetailComponent {
receiveInstallationCountData(data: number) {
this.installationCount = data;
}

private removeQueryParam(): void {
this.router.navigate([], {
queryParams: { showPopup: null },
queryParamsHandling: 'merge'
});
}
}

0 comments on commit 6f36d4e

Please sign in to comment.