All files / app/elements/marketing-trip-card marketing-trip-card.component.ts

96.61% Statements 57/59
100% Branches 13/13
80% Functions 4/5
96.61% Lines 57/59

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 601x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 7x 7x 7x 7x 7x 2x 2x 2x 2x 2x 2x 7x 7x 7x 7x 7x 7x 7x 7x 7x 2x 2x 7x 5x 5x     5x 5x 1x 1x 5x 5x 2x 2x 5x  
import { NgOptimizedImage, NgStyle } from '@angular/common';
import { Component, Input, OnInit, inject, input, output } from '@angular/core';
import { UrlService } from '@services/url.service';
 
@Component({
	selector: 'grt-marketing-trip-card',
	templateUrl: './marketing-trip-card.component.html',
	styleUrl: './marketing-trip-card.component.scss',
	imports: [NgStyle, NgOptimizedImage],
})
export class MarketingTripCardComponent implements OnInit {
	urlService = inject(UrlService);
 
	@Input() trip!: any;
	readonly mainPage = input.required<boolean>();
	readonly showMap = output<any>();
	countries = '';
	hover = false;
	showMoreCountries = false;
	showMoreDestinations = false;
	destinations = '';
 
	ngOnInit() {
		const cities = this.trip?.['cities'] || [];
 
		this.countries =
			cities && cities.length
				? cities
						.filter(
							(city: any, index: number, self: any[]) =>
								index === self.findIndex((c) => c['country-name'] === city['country-name']),
						)
						.map((city: any) => city['country-name'])
						.join(', ')
				: '';
 
		this.showMoreCountries = this.countries.length > 25;
 
		const destinationNames = cities.map((city: any) => city.name);
		this.destinations = destinationNames.join(', ');
		this.showMoreDestinations = this.destinations.length > 25;
 
		if (this.trip) {
			this.trip['img-url'] = this.urlService.getNewUrl(this.trip['img-url']);
		}
	}
 
	replaceUrl(url: string) {
		return url.replace(/https:\/\/res-(?:[1-5]\.|)\bcloudinary.com\/gorealtravel\/image\/upload\//g, '');
	}
 
	details() {
		this.showMap.emit(this.trip);
	}
 
	setHover(bool: boolean) {
		this.hover = bool;
	}
}