TP-74032 | Journey Revamp Phase 1 | API Endpoint Changes (#11865)
Co-authored-by: Prajjaval Verma <prajjaval.verma@navi.com>
This commit is contained in:
committed by
GitHub
parent
cbc3843305
commit
6d8f1b2933
@@ -3,22 +3,14 @@ import { Dispatch, SetStateAction } from "react";
|
||||
import { getXTargetHeaderInfo } from "../../../../network/ApiClient";
|
||||
import { GZIP } from "../../../../network/NetworkConstant";
|
||||
import { get, patch, post } from "../../../../network/NetworkService";
|
||||
import {
|
||||
ActionMetaData,
|
||||
BaseActionTypes,
|
||||
} from "../../../common/actions/GenericAction";
|
||||
import { ActionMetaData } from "../../../common/actions/GenericAction";
|
||||
import {
|
||||
AnalyticsFlowNameConstant,
|
||||
AnalyticsMethodNameConstant,
|
||||
AnalyticsModuleNameConstant,
|
||||
BASE_SCREEN,
|
||||
} from "../../../common/constants";
|
||||
import { GI } from "../../../common/constants/NavigationHandlerConstants";
|
||||
import {
|
||||
sendAsAnalyticsEvent,
|
||||
sendAsGlobalErrorEvent,
|
||||
} from "../../../common/hooks/useAnalyticsEvent";
|
||||
import { logToSentry } from "../../../common/hooks/useSentryLogging";
|
||||
import { sendAsAnalyticsEvent } from "../../../common/hooks/useAnalyticsEvent";
|
||||
import { CtaData } from "../../../common/interface";
|
||||
import { ScreenData } from "../../../common/interface/widgets/screenData/ScreenData";
|
||||
import { ScreenState } from "../../../common/screen/BaseScreen";
|
||||
@@ -27,10 +19,10 @@ import {
|
||||
handleResponseData,
|
||||
} from "../../../common/screen/ScreenActionHandler";
|
||||
import { ScreenActionTypes } from "../../../common/screen/ScreenActionTypes";
|
||||
import { getErrorTypeFromStatusCode } from "../../../common/utilities/ErrorUtils";
|
||||
export interface SumInsuredRequestData {
|
||||
sumInsured: string;
|
||||
planId?: string;
|
||||
applicationId?: string | null;
|
||||
}
|
||||
|
||||
export const createQuote = async (
|
||||
@@ -105,7 +97,7 @@ export const getQuotePageData = async (
|
||||
},
|
||||
};
|
||||
const url = `v3/quotes/${quoteId}`;
|
||||
return get<ApiResponse<CtaData>>(url, requestConfig)
|
||||
return get<ApiResponse<CtaData>>(url, requestConfig, screenMetaData.data)
|
||||
.then(response => {
|
||||
handleResponseData(setScreenData, response);
|
||||
})
|
||||
|
||||
@@ -113,7 +113,8 @@ const QuoteOfferScreen = ({
|
||||
};
|
||||
});
|
||||
|
||||
const { preQuoteId, quoteId, navigatorType } = extractCtaParameters(ctaData);
|
||||
const { applicationId, preQuoteId, quoteId, navigatorType } =
|
||||
extractCtaParameters(ctaData);
|
||||
|
||||
const nativeEventListener = new NativeEventEmitter();
|
||||
let reloadPageEventListener = {} as EmitterSubscription;
|
||||
@@ -163,8 +164,9 @@ const QuoteOfferScreen = ({
|
||||
? ScreenActionTypes.FETCH_QUOTE_V4
|
||||
: ScreenActionTypes.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND;
|
||||
const data: QuoteOfferRequest = {
|
||||
preQuoteId: preQuoteId ? preQuoteId : undefined,
|
||||
quoteId: quoteId ? quoteId : undefined,
|
||||
preQuoteId: preQuoteId,
|
||||
quoteId: quoteId,
|
||||
applicationId: applicationId,
|
||||
};
|
||||
handleActions({
|
||||
baseActionType: BaseActionTypes.SCREEN_ACTION,
|
||||
@@ -190,6 +192,7 @@ const QuoteOfferScreen = ({
|
||||
const data: QuoteOfferRequest = {
|
||||
preQuoteId: preQuoteId ? preQuoteId : undefined,
|
||||
quoteId: quoteId ? quoteId : undefined,
|
||||
applicationId: applicationId ? applicationId : undefined,
|
||||
};
|
||||
handleActions({
|
||||
baseActionType: BaseActionTypes.SCREEN_ACTION,
|
||||
|
||||
@@ -42,6 +42,7 @@ export const QUOTE_APOLOGY_SUBTITLE =
|
||||
export const QUOTE_APOLOGY_BUTTON = "Buy new policy";
|
||||
export const QUOTE_PATCH_FAIL_TOAST = "Failed. Try again";
|
||||
export const QUOTE_ID = "quoteId";
|
||||
export const APPLICATION_ID = "applicationId";
|
||||
export const BUILD_CONFIG_DETAILS = "BUILD_CONFIG_DETAILS";
|
||||
export const SPACE_UNICODE = "\u00A0";
|
||||
export const REACT_NATIVE = "rn";
|
||||
|
||||
@@ -51,6 +51,7 @@ export enum ParameterType {
|
||||
PRE_QUOTE_ID = "preQuoteId",
|
||||
QUOTE_ID = "quoteId",
|
||||
NAVIGATOR_TYPE = "RnNavigatorType",
|
||||
APPLICATION_ID = "applicationId",
|
||||
}
|
||||
|
||||
export enum CtaType {
|
||||
@@ -60,4 +61,3 @@ export enum CtaType {
|
||||
RN_NAVIGATOR = "RN_NAVIGATOR",
|
||||
GO_BACK = "GO_BACK",
|
||||
}
|
||||
|
||||
|
||||
@@ -49,10 +49,12 @@ export const extractCtaParameters = (
|
||||
preQuoteId?: string | undefined | null;
|
||||
quoteId?: string | undefined | null;
|
||||
navigatorType?: string | undefined | null;
|
||||
applicationId?: string | undefined | null;
|
||||
} => {
|
||||
let preQuoteId: string | undefined | null = undefined;
|
||||
let quoteId: string | undefined | null = undefined;
|
||||
let navigatorType: string | undefined | null = undefined;
|
||||
let applicationId: string | undefined | null = undefined;
|
||||
|
||||
ctaData?.parameters?.forEach((item: CtaParameter) => {
|
||||
switch (item.key) {
|
||||
@@ -65,12 +67,15 @@ export const extractCtaParameters = (
|
||||
case ParameterType.NAVIGATOR_TYPE:
|
||||
navigatorType = item.value;
|
||||
break;
|
||||
case ParameterType.APPLICATION_ID:
|
||||
applicationId = item.value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
return { preQuoteId, quoteId, navigatorType };
|
||||
return { preQuoteId, quoteId, navigatorType, applicationId };
|
||||
};
|
||||
|
||||
export const Router = {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { QUOTE_ID } from "../constants";
|
||||
import { APPLICATION_ID, QUOTE_ID } from "../constants";
|
||||
import { CtaData } from "../interface";
|
||||
import { ScreenMetaData } from "../interface/widgets/screenData/ScreenMetaData";
|
||||
|
||||
@@ -15,3 +15,19 @@ export const getQuoteIdFromScreenMetaData = (
|
||||
);
|
||||
return quoteObj?.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;
|
||||
};
|
||||
|
||||
@@ -25,6 +25,8 @@ import { FinalPatchCallRequestBody } from "../../interface/widgets/widgetData/Fo
|
||||
import { NativeDeeplinkNavigatorModule } from "../../native-module/NativeModules";
|
||||
import { ScreenState } from "../../screen/BaseScreen";
|
||||
import {
|
||||
getApplicationFromScreenMetaData,
|
||||
getApplicationIdFromCta,
|
||||
getQuoteIdFromCta,
|
||||
getQuoteIdFromScreenMetaData,
|
||||
} from "../../utilities/CtaParamsUtils";
|
||||
@@ -136,7 +138,11 @@ const WidgetActionHandler = {
|
||||
let quoteId =
|
||||
getQuoteIdFromCta(ctaData) ??
|
||||
getQuoteIdFromScreenMetaData(screenData?.screenMetaData);
|
||||
let applicationId =
|
||||
getApplicationIdFromCta(ctaData) ??
|
||||
getApplicationFromScreenMetaData(screenData?.screenMetaData);
|
||||
const requestData: SumInsuredRequestData = widgetMetaData.data;
|
||||
requestData.applicationId = applicationId;
|
||||
return updateSumInsuredData(requestData, quoteId!!)
|
||||
.then(response => {})
|
||||
.catch(error => {
|
||||
@@ -155,12 +161,16 @@ const WidgetActionHandler = {
|
||||
let quoteId =
|
||||
getQuoteIdFromCta(ctaData) ??
|
||||
getQuoteIdFromScreenMetaData(screenData?.screenMetaData);
|
||||
let applicationId =
|
||||
getApplicationIdFromCta(ctaData) ??
|
||||
getApplicationFromScreenMetaData(screenData?.screenMetaData);
|
||||
const requestData: SumInsuredRequestData = (
|
||||
widgetMetaData?.data as FinalPatchCallRequestBody
|
||||
).requestData;
|
||||
const nextPageCta: CtaData = (
|
||||
widgetMetaData?.data as FinalPatchCallRequestBody
|
||||
).nextPageCta;
|
||||
requestData.applicationId = applicationId;
|
||||
return updateSumInsuredData(requestData, quoteId!!)
|
||||
.then(response => {
|
||||
handleResponseData(nextPageCta, setScreenData, screenData);
|
||||
|
||||
Reference in New Issue
Block a user