NTP-58342 | Renewal Revamp (#16434)
Co-authored-by: Chirayu Mor <chirayu.mor@navi.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Dispatch, SetStateAction } from "react";
|
||||
import { getXTargetHeaderInfo } from "../../../../network/ApiClient";
|
||||
import { post } from "../../../../network/NetworkService";
|
||||
import { patch, post } from "../../../../network/NetworkService";
|
||||
import { ActionMetaData } from "../../../common/actions/GenericAction";
|
||||
import {
|
||||
ALCHEMIST,
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
ApiMethod,
|
||||
CacheKeyConstants,
|
||||
CacheValueConstants,
|
||||
GI,
|
||||
GI_ZORO,
|
||||
} from "../../../common/constants";
|
||||
import { CtaData } from "../../../common/interface";
|
||||
import { ScreenData } from "../../../common/interface/widgets/screenData/ScreenData";
|
||||
@@ -23,6 +23,23 @@ import {
|
||||
import { handleResponseData } from "../../../common/widgets/widget-actions/WidgetActionHandler";
|
||||
import { RenewalPlanPatchRequest } from "../screen/renewal-plan-migration-screen/types";
|
||||
|
||||
export interface PatchTransitionResponseData {
|
||||
cta?: CtaData | null;
|
||||
applicationId?: string | null;
|
||||
}
|
||||
|
||||
export interface PatchTransitionRequestData {
|
||||
transition?: string | null;
|
||||
pageType?: string | null;
|
||||
applicationId?: string | null;
|
||||
}
|
||||
|
||||
export interface PatchTransitionRequestBodyData {
|
||||
transition?: string | null;
|
||||
applicationId?: string | null;
|
||||
pageType?: string | null;
|
||||
}
|
||||
|
||||
export const getRenewalPlanMigrationPageData = async (
|
||||
screenMetaData: ActionMetaData,
|
||||
setScreenData: Dispatch<SetStateAction<ScreenData | null>>,
|
||||
@@ -101,3 +118,21 @@ export const handlePatchRenewalQuote = async ({
|
||||
const isBottomSheetDisabled = async () => {
|
||||
return await getStringPreference(CacheKeyConstants.DISABLE_BOTTOM_SHEET);
|
||||
};
|
||||
|
||||
export const makeTransition = async (
|
||||
applicationId?: string | null,
|
||||
transition?: string | null,
|
||||
pageType?: string | null,
|
||||
) => {
|
||||
const url = `application/${applicationId}/transition/${transition}`;
|
||||
const requestBody: PatchTransitionRequestBodyData = {
|
||||
transition,
|
||||
applicationId,
|
||||
pageType,
|
||||
};
|
||||
return patch<ApiResponse<PatchTransitionResponseData>>(
|
||||
url,
|
||||
requestBody,
|
||||
getXTargetHeaderInfo(GI_ZORO.toLocaleUpperCase()),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -42,7 +42,7 @@ const MigrationBenefitScreen = ({
|
||||
}: MigrationBenefitScreenProps) => {
|
||||
const navigation = useNavigation();
|
||||
|
||||
const { planId, previousPlanId, preQuoteId, planType } =
|
||||
const { planId, previousPlanId, preQuoteId, planType, applicationId } =
|
||||
extractCtaParameters(ctaData);
|
||||
|
||||
const handleClick = (cta?: CtaData) => {
|
||||
@@ -67,9 +67,12 @@ const MigrationBenefitScreen = ({
|
||||
planId: planId,
|
||||
previousPlanId: previousPlanId,
|
||||
preQuoteId: preQuoteId,
|
||||
applicationId: applicationId,
|
||||
planType: planType,
|
||||
} as MigrationBenefitScreenRequest,
|
||||
screenName: UrlConstants.MIGRATION_BENEFIT_SCREEN_URL,
|
||||
screenName: applicationId
|
||||
? UrlConstants.MIGRATION_BENEFIT_SCREEN_URL_V2
|
||||
: UrlConstants.MIGRATION_BENEFIT_SCREEN_URL,
|
||||
};
|
||||
|
||||
handleActions({
|
||||
|
||||
@@ -50,13 +50,16 @@ const RenewalPlanMigrationScreen = ({
|
||||
y.value = event.nativeEvent.contentOffset.y;
|
||||
};
|
||||
|
||||
const { preQuoteId } = extractCtaParameters(ctaData);
|
||||
const { preQuoteId, applicationId } = extractCtaParameters(ctaData);
|
||||
|
||||
const data: RenewalPlanMigrationScreenRequestData = {
|
||||
inputMap: {
|
||||
preQuoteId: preQuoteId,
|
||||
applicationId: applicationId,
|
||||
} as RenewalPlanMigrationScreenRequest,
|
||||
screenName: UrlConstants.RENEWAL_PLAN_MIGRATION_SCREEN_URL,
|
||||
screenName: applicationId
|
||||
? UrlConstants.RENEWAL_PLAN_MIGRATION_SCREEN_URL_V2
|
||||
: UrlConstants.RENEWAL_PLAN_MIGRATION_SCREEN_URL,
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -76,6 +76,7 @@ export const AnalyticsMethodNameConstant = {
|
||||
RENEWAL_PLAN_MIGRATION_SCREEN: "gi_renewal_plan_migration_screen_error",
|
||||
HANDLE_CTA_CLICK: "handleCtaClick",
|
||||
HANDLE_CTA_CLICK_BOTTOMSHEET: "handleCtaClickBottomSheet",
|
||||
TRANSITION_PATCH_CALL: "transitionPatchCall",
|
||||
};
|
||||
|
||||
export const AnalyticsGlobalErrorTypeConstant = {
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
export const GI = "gi";
|
||||
export const GI_ZORO = "GI-ZORO";
|
||||
export const ALCHEMIST = "alchemist";
|
||||
|
||||
@@ -81,7 +81,9 @@ export const FontMapping = {
|
||||
|
||||
export const UrlConstants = {
|
||||
MIGRATION_BENEFIT_SCREEN_URL: "GI_MIGRATION_BENEFIT",
|
||||
RENEWAL_PLAN_MIGRATION_SCREEN_URL: "GI_RENEWAL_PLAN_MIGRATION_SCREEN",
|
||||
MIGRATION_BENEFIT_SCREEN_URL_V2: "GI_MIGRATION_BENEFIT_V2",
|
||||
RENEWAL_PLAN_MIGRATION_SCREEN_URL: "GI_RENEWAL_PLAN_MIGRATION_SCREEN_V2",
|
||||
RENEWAL_PLAN_MIGRATION_SCREEN_URL_V2: "GI_RENEWAL_PLAN_MIGRATION_SCREEN_V2",
|
||||
};
|
||||
|
||||
export enum CacheKeyConstants {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { Dispatch, SetStateAction } from "react";
|
||||
import {
|
||||
PatchTransitionRequestData,
|
||||
SumInsuredRequestData,
|
||||
handlePatchRenewalQuote,
|
||||
makeTransition,
|
||||
updateSumInsuredData,
|
||||
} from "../../../Container/Navi-Insurance/network";
|
||||
|
||||
@@ -10,7 +12,7 @@ import {
|
||||
GenericActionPayload,
|
||||
TargetWidgetPayload,
|
||||
} from "../../actions/GenericAction";
|
||||
import { ApiMethod } from "../../constants";
|
||||
import { ApiMethod, ConstantCta } from "../../constants";
|
||||
import {
|
||||
AnalyticsEventNameConstants,
|
||||
AnalyticsFlowNameConstant,
|
||||
@@ -219,6 +221,41 @@ const WidgetActionHandler = {
|
||||
return;
|
||||
}
|
||||
|
||||
case WidgetActionTypes.TRANSITION_API: {
|
||||
setScreenData({
|
||||
...screenData,
|
||||
screenState: ScreenState.OVERLAY,
|
||||
});
|
||||
let applicationId =
|
||||
getApplicationIdFromCta(ctaData) ??
|
||||
getApplicationFromScreenMetaData(screenData?.screenMetaData);
|
||||
let transition = (widgetMetaData?.data as PatchTransitionRequestData)
|
||||
.transition;
|
||||
let pageType = (widgetMetaData?.data as PatchTransitionRequestData)
|
||||
.pageType;
|
||||
const url = `/application/${applicationId}/transition/${transition}`;
|
||||
return makeTransition(applicationId, transition, pageType)
|
||||
.then(response => {
|
||||
handleResponseData(
|
||||
response?.data?.cta ?? ConstantCta.STATIC_HEADER_LEFT_ICON_CTA,
|
||||
setScreenData,
|
||||
screenData,
|
||||
);
|
||||
})
|
||||
.catch(error => {
|
||||
handleErrorData(
|
||||
error,
|
||||
setScreenData,
|
||||
widgetMetaData,
|
||||
AnalyticsMethodNameConstant.TRANSITION_PATCH_CALL,
|
||||
AnalyticsFlowNameConstant.GI_RN_RENEWAL_PLAN_MIGRATION,
|
||||
screenData,
|
||||
url,
|
||||
ApiMethod.PATCH,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
default: {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -9,4 +9,5 @@ export const WidgetActionTypes = {
|
||||
FINAL_PATCH_CALL: "FINAL_PATCH_CALL",
|
||||
ANALYTIC_ACTION: "ANALYTIC_ACTION",
|
||||
PATCH_RENEWAL_QUOTE: "PATCH_RENEWAL_QUOTE",
|
||||
TRANSITION_API: "TRANSITION_API",
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user