All files / app/services customer-journey.service.ts

96.55% Statements 56/58
88.88% Branches 8/9
100% Functions 8/8
96.55% Lines 56/58

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 591x 1x 1x 1x 1x 1x 1x 39x 39x 39x 39x 39x 39x 39x 39x 1x 1x 1x 1x 1x 1x 39x 39x 1x 1x 1x 1x 1x 1x 39x 39x 1x 1x     1x 1x 1x 39x 39x 1x 1x 1x 1x 1x 39x 39x 1x 1x 39x 39x 52x 52x 39x 39x 1x 1x 39x  
import { Injectable, inject } from '@angular/core';
import { CookieService } from 'ngx-cookie-service';
 
@Injectable({
	providedIn: 'root',
})
export class UserJourneyService {
	private cookieService = inject(CookieService);
 
 
	private flow: any = {
		B: ['/trip/where-b', '/trip/interests-b', '/trip/logistics-b', '/trip/sign-up-b', '/ready-b'],
	};
 
	public nextJourney(current: string) {
		const currentVersion = this.getVersion();
		const fullLink = `${current}-${currentVersion.toLowerCase()}`;
		const flow = this.flow[currentVersion] as string[];
		const indexOfCurrent = flow.indexOf(fullLink);
		return flow[indexOfCurrent + 1];
	}
 
	public backourney(current: string) {
		const currentVersion = this.getVersion();
		const fullLink = `${current}-${currentVersion.toLowerCase()}`;
		const flow = this.flow[currentVersion] as string[];
		const indexOfCurrent = flow.indexOf(fullLink);
		return flow[indexOfCurrent - 1];
	}
 
	public firstStep() {
		let currentVersion = this.getVersion();
		if (!currentVersion) {
			currentVersion = 'B';
		}
		const flow = this.flow[currentVersion] as string[];
		return flow[0];
	}
 
	public setVersion(version: string) {
		this.cookieService.delete('JOURNEY_VERSION');
		const date = new Date();
		date.setDate(date.getDate() + 7);
		this.cookieService.set('JOURNEY_VERSION', version, date);
	}
 
	public getVersion() {
		return this.cookieService.get('JOURNEY_VERSION');
	}
 
	public showDayCountInSummaryFooter() {
		return this.cookieService.get('JOURNEY_VERSION') === 'A';
	}
 
	homePage() {
		return '/';
	}
}