All files / app/pages/review-page review-page.component.ts

83.33% Statements 100/120
85.71% Branches 6/7
55.55% Functions 5/9
83.33% Lines 100/120

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 1211x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x                     1x 1x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 5x 5x 5x 5x 5x 5x 1x 1x 1x     1x 1x             1x  
import { NgStyle, isPlatformBrowser } from '@angular/common';
import { Component, ElementRef, HostListener, OnInit, PLATFORM_ID, ViewChild, inject } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { Meta, Title } from '@angular/platform-browser';
import { firstOptions, secondOptions, wizardCardData } from '@constants/wizard-card.constants';
import { FooterElementComponent } from '@elements/footer-element/footer-element.component';
import { HeaderElementComponent } from '@elements/header-element/header-element.component';
import { TrustboxComponent } from '@elements/trustbox/trustbox.component';
import { WizardCardComponent } from '@elements/wizard-card/wizard-card.component';
import { AnalyticsIntegrationService } from '@services/analyticsIntegration.service';
import { MetaTagService } from '@services/meta-tag.service';
import { BsModalRef, ModalDirective, ModalModule } from 'ngx-bootstrap/modal';
import { CarouselModule, OwlOptions } from 'ngx-owl-carousel-o';
import comments from '../../../assets/comments.json';
@Component({
	selector: 'grt-review-page',
	templateUrl: './review-page.component.html',
	styleUrls: ['./review-page.component.scss'],
	imports: [
		HeaderElementComponent,
		TrustboxComponent,
		ReactiveFormsModule,
		FormsModule,
		ModalModule,
		FooterElementComponent,
		NgStyle,
		WizardCardComponent,
		CarouselModule,
	],
})
export class ReviewPageComponent implements OnInit {
	private titleService = inject(Title);
	private meta = inject(Meta);
	private analyticsIntegrationService = inject(AnalyticsIntegrationService);
	private metaTag = inject(MetaTagService);
 
	modalRef?: BsModalRef;
	showSticky: boolean = false;
	@ViewChild('sticky', { static: true }) menuElement: ElementRef | any;
	staticModal: any;
	rotate = true;
	isShowAll = false;
	currentPage = 1;
	data: any = [];
	isModalShown = false;
	@ViewChild('autoShownModal', { static: false })
	autoShownModal?: ModalDirective | any;
	snippets!: any[];
	isBrowser: any;
	elementPosition: any;
	mobile = true;
 
	firstOptions: OwlOptions = firstOptions;
	secondOptions: OwlOptions = secondOptions;
	wizardCardData = wizardCardData;
 
	@HostListener('window:scroll', ['$event'])
	handleScroll() {
		if (this.isBrowser) {
			this.elementPosition = this.menuElement.nativeElement.offsetTop;
			const windowScroll = window.pageYOffset;
			if (windowScroll >= this.elementPosition + 100) {
				this.showSticky = true;
			} else {
				this.showSticky = false;
			}
		}
	}
 
	constructor() {
		const platformId = inject(PLATFORM_ID);
 
		this.isBrowser = isPlatformBrowser(platformId);
		this.titleService.setTitle('Customer Reviews - Go Real Travel');
		this.metaTag.removeMetaTags();
		this.meta.addTags(
			this.metaTag.getMetaTags(
				'Customer Reviews - Go Real Travel',
				'Discover the real stories behind Go Real Travel trips! Explore genuine customer reviews, testimonials, and travel tales. Your next journey begins with trusted insights.',
			),
		);
	}
 
	showModal(): void {
		this.isModalShown = true;
	}
 
	hideModal(): void {
		this.autoShownModal.hide();
	}
 
	onHidden(): void {
		this.isModalShown = false;
	}
 
	setData(name: string): void {
		this.data = this.snippets.filter((item) => item.name === name);
	}
 
	ngOnInit() {
		if (this.isBrowser) {
			this.analyticsIntegrationService.loadScript();
		}
		this.snippets = this.isShowAll ? comments : comments.slice(0, 8);
		this.mobile = document.body.offsetWidth <= 1023;
	}
 
	@HostListener('window:resize', ['$event'])
	onResize(): void {
		this.mobile = document.body.offsetWidth <= 1023;
	}
 
	toggleShowAll() {
		this.isShowAll = !this.isShowAll;
		this.snippets = this.isShowAll ? comments : comments.slice(0, 8);
		if (this.isBrowser && !this.isShowAll) {
			window.scrollTo({ top: 0, behavior: 'smooth' });
		}
	}
}