import { Injectable } from '@angular/core'; import { CookieService } from 'ngx-cookie'; import { UserConstants } from '../../constants/user.constants'; import { UserInfoService } from '../../services/user-info/user-info.service'; @Injectable() export class UserDetailsService { userId: string; constructor(private cookieService: CookieService, private user: UserInfoService) { } getUserId(): string { if (typeof document !== 'undefined') { this.userId = this.cookieService.get(UserConstants.CUSTOMER_ID) ? this.cookieService.get(UserConstants.CUSTOMER_ID) : this.getCurrentUser(); } return this.userId; } getCurrentUser() { const currentUser = this.user.getUserAccountData(); return currentUser.email; } }