96 lines
2.6 KiB
TypeScript
96 lines
2.6 KiB
TypeScript
import { APPLICATION_ID, PRE_QUOTE_ID, QUOTE_ID } from "../constants";
|
|
import { CtaData, CtaParameter } from "../interface";
|
|
import { ScreenMetaData } from "../interface/widgets/screenData/ScreenMetaData";
|
|
|
|
export const extractCtaParameters = (ctaData: any) => {
|
|
const params: Record<string, string | undefined | null> = {
|
|
preQuoteId: undefined,
|
|
quoteId: undefined,
|
|
navigatorType: undefined,
|
|
applicationId: undefined,
|
|
source: undefined,
|
|
planId: undefined,
|
|
benefitType: undefined,
|
|
sourceScreen: undefined,
|
|
toggleNextCta: undefined,
|
|
previousPlanId: undefined,
|
|
planType: undefined,
|
|
shimmerType: undefined,
|
|
pageName: undefined,
|
|
title: undefined,
|
|
description: undefined,
|
|
footerTitle: undefined,
|
|
};
|
|
|
|
ctaData?.parameters?.forEach((item: CtaParameter) => {
|
|
if (item.key in params) {
|
|
params[item.key] = item.value;
|
|
}
|
|
});
|
|
|
|
return params as {
|
|
preQuoteId?: string | null;
|
|
quoteId?: string | null;
|
|
navigatorType?: string | null;
|
|
applicationId?: string | null;
|
|
source?: string | null;
|
|
planId?: string | null;
|
|
benefitType?: string | null;
|
|
sourceScreen?: string | null;
|
|
toggleNextCta?: boolean | null;
|
|
previousPlanId?: string | null;
|
|
planType?: string | null;
|
|
shimmerType?: string | null;
|
|
pageName?: string | null;
|
|
title?: string | null;
|
|
description?: string | null;
|
|
footerTitle?: string | null;
|
|
};
|
|
};
|
|
|
|
export const getQuoteIdFromCta = (ctaData?: CtaData) => {
|
|
const quoteObj = ctaData?.parameters?.find(item => item.key === QUOTE_ID);
|
|
return quoteObj?.value;
|
|
};
|
|
|
|
export const getPreQuoteIdFromCta = (ctaData?: CtaData) => {
|
|
const preQuoteObj = ctaData?.parameters?.find(
|
|
item => item.key === PRE_QUOTE_ID,
|
|
);
|
|
return preQuoteObj?.value;
|
|
};
|
|
|
|
export const getQuoteIdFromScreenMetaData = (
|
|
screenMetaData?: ScreenMetaData,
|
|
) => {
|
|
const quoteObj = screenMetaData?.screenProperties?.find(
|
|
item => item.key === QUOTE_ID,
|
|
);
|
|
return quoteObj?.value;
|
|
};
|
|
|
|
export const getPreQuoteIdFromScreenMetaData = (
|
|
screenMetaData?: ScreenMetaData,
|
|
) => {
|
|
const preQuoteObj = screenMetaData?.screenProperties?.find(
|
|
item => item.key === PRE_QUOTE_ID,
|
|
);
|
|
return preQuoteObj?.value;
|
|
};
|
|
|
|
export const getApplicationIdFromCta = (ctaData?: CtaData) => {
|
|
const quoteObj = ctaData?.parameters?.find(
|
|
item => item.key === APPLICATION_ID,
|
|
);
|
|
return quoteObj?.value;
|
|
};
|
|
|
|
export const getApplicationFromScreenMetaData = (
|
|
screenMetaData?: ScreenMetaData,
|
|
) => {
|
|
const quoteObj = screenMetaData?.screenProperties?.find(
|
|
item => item.key === APPLICATION_ID,
|
|
);
|
|
return quoteObj?.value;
|
|
};
|