Skip to content

Commit

Permalink
handle feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ntqdinh-axonivy committed Dec 19, 2024
1 parent 1b5e37a commit d6755f6
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 26 deletions.
10 changes: 1 addition & 9 deletions marketplace-ui/src/app/core/interceptors/api.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ import { ERROR_CODES, ERROR_PAGE_PATH } from '../../shared/constants/common.cons
export const REQUEST_BY = 'X-Requested-By';
export const IVY = 'marketplace-website';

/** SkipLoading: This option for exclude loading api
* @Example return httpClient.get('apiEndPoint', { context: new HttpContext().set(SkipLoading, true) })
*/
export const SkipLoading = new HttpContextToken<boolean>(() => false);

/** ForwardingError: This option for forwarding responce error to the caller
* @Example return httpClient.get('apiEndPoint', { context: new HttpContext().set(ForwardingError, true) })
*/
Expand Down Expand Up @@ -47,9 +42,6 @@ export const apiInterceptor: HttpInterceptorFn = (req, next) => {
headers: addIvyHeaders(req.headers)
});

if (!req.context.get(SkipLoading)) {
loadingService.showLoading(req.context.get(LoadingComponent));
}

if (req.context.get(ForwardingError)) {
return next(cloneReq);
Expand All @@ -65,7 +57,7 @@ export const apiInterceptor: HttpInterceptorFn = (req, next) => {
return EMPTY;
}),
finalize(() => {
if (!req.context.get(SkipLoading)) {
if (req.context.get(LoadingComponent)) {
loadingService.hideLoading(req.context.get(LoadingComponent));
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ import {
import { catchError, Observable, of, tap, throwError } from 'rxjs';
import { CookieService } from 'ngx-cookie-service';
import { AuthService } from '../../../../../auth/auth.service';
import {
ForwardingError,
SkipLoading
} from '../../../../../core/interceptors/api.interceptor';
import { ForwardingError } from '../../../../../core/interceptors/api.interceptor';
import { FeedbackApiResponse } from '../../../../../shared/models/apis/feedback-response.model';
import { Feedback } from '../../../../../shared/models/feedback.model';
import { ProductDetailService } from '../../product-detail.service';
Expand Down Expand Up @@ -64,9 +61,7 @@ export class ProductFeedbackService {
return this.http
.post<Feedback>(FEEDBACK_API_URL, feedback, {
headers,
context: new HttpContext()
.set(SkipLoading, true)
.set(ForwardingError, true)
context: new HttpContext().set(ForwardingError, true)
})
.pipe(
tap(() => {
Expand Down Expand Up @@ -100,7 +95,7 @@ export class ProductFeedbackService {
return this.http
.get<FeedbackApiResponse>(requestURL, {
params: requestParams,
context: new HttpContext().set(SkipLoading, true).set(ForwardingError, true)
context: new HttpContext().set(ForwardingError, true)
})
.pipe(
tap(response => {
Expand All @@ -126,9 +121,7 @@ export class ProductFeedbackService {
return this.http
.get<Feedback>(requestURL, {
params,
context: new HttpContext()
.set(SkipLoading, true)
.set(ForwardingError, true)
context: new HttpContext().set(ForwardingError, true)
})
.pipe(
tap(feedback => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
import { Observable, 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 Down Expand Up @@ -59,9 +58,7 @@ export class ProductStarRatingService {
getRatingObservable(id: string): Observable<StarRatingCounting[]> {
const requestURL = `api/feedback/product/${id}/rating`;
return this.http
.get<StarRatingCounting[]>(requestURL, {
context: new HttpContext().set(SkipLoading, true)
})
.get<StarRatingCounting[]>(requestURL, { context: new HttpContext() })
.pipe(
tap(data => {
this.sortByStar(data);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="container-fluid min-vh-100">
<div>
<app-loading-spinner
containerClasses="d-flex justify-content-center position-absolute align-items-center w-100 h-100 start-0 rounded overlay-background"
containerClasses="d-flex justify-content-center position-fixed align-items-center top-0 end-0 bottom-0 start-0 rounded overlay-background z-1"
[key]="LoadingComponentId.DETAIL_PAGE" />
</div>
<div
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@if (isLoading()) {
<div [className]="containerClasses">
<div [className]="containerClasses">
<div class="d-flex justify-content-center" data-title="dot-stretching">
<div class="stage">
<div class="dot-stretching"></div>
Expand Down

0 comments on commit d6755f6

Please sign in to comment.