File

libs/common/web-components/src/back-link-adapter/back-link-utils.service.ts

Index

Methods

Constructor

constructor(channel: CHANNEL, backLinkAdapterService: BackLinkAdapterService)
Parameters :
Name Type Optional
channel CHANNEL No
backLinkAdapterService BackLinkAdapterService No

Methods

isBackLinkFeatureActiveForActions
isBackLinkFeatureActiveForActions(isLastPage: boolean)
Parameters :
Name Type Optional
isLastPage boolean No
Returns : boolean
isBackLinkFeatureActiveForStage
isBackLinkFeatureActiveForStage(hideBackLink: boolean | undefined)
Parameters :
Name Type Optional
hideBackLink boolean | undefined No
Returns : boolean
import { CHANNEL, CHANNEL_TOKEN } from '@allianz/taly-core';
import { Inject, Injectable, Optional } from '@angular/core';
import { BackLinkAdapterService } from './back-link-adapter.service';

@Injectable({
  providedIn: 'root'
})
export class BackLinkUtilsService {
  private isRetailChannel: boolean;

  constructor(
    @Inject(CHANNEL_TOKEN) channel: CHANNEL,
    @Optional() private backLinkAdapterService: BackLinkAdapterService
  ) {
    this.isRetailChannel = channel === CHANNEL.RETAIL;
  }

  isBackLinkFeatureActiveForStage(hideBackLink: boolean | undefined): boolean {
    return Boolean(
      this.isRetailChannel &&
        !hideBackLink &&
        this.backLinkAdapterService?.backLinkData?.stageLinkLabel
    );
  }

  isBackLinkFeatureActiveForActions(isLastPage: boolean): boolean {
    return Boolean(this.isRetailChannel && isLastPage && this.hasNextButtonLabel());
  }

  private hasNextButtonLabel(): boolean {
    const nextButtonLabel = this.backLinkAdapterService?.backLinkData?.nextButtonLabel;
    if (Array.isArray(nextButtonLabel) && nextButtonLabel.length > 0) {
      return true;
    }

    return Boolean(nextButtonLabel);
  }
}

results matching ""

    No results matching ""