TP-73673 | TP-74249 | Remove Shimmer & QuoteID Caching (#11822)
This commit is contained in:
35
App.tsx
35
App.tsx
@@ -1,11 +1,18 @@
|
||||
import { init } from "@sentry/react-native";
|
||||
import { Component } from "react";
|
||||
import codePush from "react-native-code-push";
|
||||
import {
|
||||
GenericErrorScreen
|
||||
} from "./App/Container/Navi-Insurance";
|
||||
import {
|
||||
BundleState,
|
||||
CODEPUSH_METHOD,
|
||||
EVENT_NAMES,
|
||||
EVENT_PROPERTY_KEYS,
|
||||
EVENT_PROPERTY_VALUES,
|
||||
SentryConstants,
|
||||
} from "./App/common/constants";
|
||||
import { sendAsAnalyticsEvent } from "./App/common/hooks/useAnalyticsEvent";
|
||||
import { logToSentry } from "./App/common/hooks/useSentryLogging";
|
||||
import { CtaData } from "./App/common/interface";
|
||||
import RnApp from "./App/common/navigator/RnAppCreator";
|
||||
@@ -13,20 +20,10 @@ import {
|
||||
getBuildConfigDetails,
|
||||
setBuildConfigDetails,
|
||||
} from "./App/common/utilities/CacheUtils";
|
||||
import {
|
||||
GenericErrorScreen,
|
||||
GenericShimmerScreen,
|
||||
} from "./App/Container/Navi-Insurance";
|
||||
import {
|
||||
getStringPreference,
|
||||
setStringPreference,
|
||||
} from "./App/common/utilities/SharedPreferenceUtils";
|
||||
import { sendAsAnalyticsEvent } from "./App/common/hooks/useAnalyticsEvent";
|
||||
import {
|
||||
EVENT_NAMES,
|
||||
EVENT_PROPERTY_KEYS,
|
||||
EVENT_PROPERTY_VALUES,
|
||||
} from "./App/common/constants";
|
||||
|
||||
init({
|
||||
dsn: SentryConstants.SENTRY_DSN,
|
||||
@@ -53,9 +50,10 @@ export default class App extends Component<{}, AppState> {
|
||||
getBuildConfigDetails().then(res => {
|
||||
flavor = res?.baseUrl;
|
||||
});
|
||||
const cta = this.getInitialCta();
|
||||
await codePush.sync(
|
||||
{
|
||||
installMode: codePush.InstallMode.IMMEDIATE,
|
||||
installMode: (cta?.title === preloadBundle) ? codePush.InstallMode.IMMEDIATE : codePush.InstallMode.ON_NEXT_RESTART,
|
||||
mandatoryInstallMode: codePush.InstallMode.IMMEDIATE,
|
||||
},
|
||||
status => {
|
||||
@@ -145,12 +143,15 @@ export default class App extends Component<{}, AppState> {
|
||||
if (cta?.title === preloadBundle) {
|
||||
return <></>;
|
||||
}
|
||||
|
||||
return !!cta && this.state.bundleState !== BundleState.LOADING ? (
|
||||
RnApp.create(cta)
|
||||
) : (
|
||||
<GenericShimmerScreen />
|
||||
);
|
||||
else if (!!cta){
|
||||
return RnApp.create(cta)
|
||||
}
|
||||
else {
|
||||
sendAsAnalyticsEvent({
|
||||
name: EVENT_NAMES.INVALID_SCREEN_CTA
|
||||
});
|
||||
return <GenericErrorScreen />;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
import { View } from "react-native";
|
||||
import SkeletonPlaceholder from "react-native-skeleton-placeholder";
|
||||
import Colors from "../../../../../assets/colors/colors";
|
||||
import styles from "./GenericShimmerScreenStyle";
|
||||
import { StaticHeader } from "../../../../../components/reusable/static-header/StaticHeader";
|
||||
import { CtaData, CtaType } from "../../../../common/interface";
|
||||
import { ConstantCta } from "../../../../common/constants/CtaConstants";
|
||||
import { logToSentry } from "../../../../common/hooks/useSentryLogging";
|
||||
import {
|
||||
invalidateCacheWithUrl,
|
||||
shouldInvalidateSavedData,
|
||||
} from "../../../../common/utilities/CacheUtils";
|
||||
import { CtaData, CtaType } from "../../../../common/interface";
|
||||
import { NativeDeeplinkNavigatorModule } from "../../../../common/native-module/NativeModules";
|
||||
import styles from "./GenericShimmerScreenStyle";
|
||||
|
||||
const GenericShimmerScreen = () => {
|
||||
const handleClick = (cta?: CtaData) => {
|
||||
@@ -21,10 +17,6 @@ const GenericShimmerScreen = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (invalidateCacheWithUrl(cta.url) || shouldInvalidateSavedData(cta)) {
|
||||
invalidatePostApiData();
|
||||
}
|
||||
|
||||
try {
|
||||
switch (cta.type) {
|
||||
case CtaType.DEEP_LINK:
|
||||
@@ -99,6 +91,3 @@ const FooterShimmer = () => {
|
||||
</View>
|
||||
);
|
||||
};
|
||||
function invalidatePostApiData() {
|
||||
throw new Error("Function not implemented.");
|
||||
}
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
import { TouchableOpacity, View, Text } from "react-native";
|
||||
import { GenericActionPayload } from "../../../../common/actions/GenericAction";
|
||||
import { CtaData, CtaType } from "../../../../common/interface";
|
||||
import { ScreenData } from "../../../../common/interface/widgets/screenData/ScreenData";
|
||||
import { Text, TouchableOpacity, View } from "react-native";
|
||||
import { AppImage } from "../../../../../components/AppImage";
|
||||
import { StaticHeader } from "../../../../../components/reusable/static-header/StaticHeader";
|
||||
import { GenericActionPayload } from "../../../../common/actions/GenericAction";
|
||||
import { ConstantCta } from "../../../../common/constants/CtaConstants";
|
||||
import {
|
||||
ImageName,
|
||||
QUOTE_APOLOGY_BUTTON,
|
||||
QUOTE_APOLOGY_SUBTITLE,
|
||||
QUOTE_APOLOGY_TITLE,
|
||||
} from "../../../../common/constants/StringConstant";
|
||||
import { CtaData, CtaType } from "../../../../common/interface";
|
||||
import { ScreenData } from "../../../../common/interface/widgets/screenData/ScreenData";
|
||||
import { NativeDeeplinkNavigatorModule } from "../../../../common/native-module/NativeModules";
|
||||
import { styles } from "./QuoteApologyScreenStyle";
|
||||
import { StaticHeader } from "../../../../../components/reusable/static-header/StaticHeader";
|
||||
import { ConstantCta } from "../../../../common/constants/CtaConstants";
|
||||
import {
|
||||
invalidateCacheWithUrl,
|
||||
shouldInvalidateSavedData,
|
||||
} from "../../../../common/utilities/CacheUtils";
|
||||
import { setStringPreference } from "../../../../common/utilities/SharedPreferenceUtils";
|
||||
import { styles } from "./QuoteApologyScreenStyle";
|
||||
|
||||
const QuoteApologyScreen = ({
|
||||
ctaData,
|
||||
@@ -28,17 +24,8 @@ const QuoteApologyScreen = ({
|
||||
screenData: ScreenData | null;
|
||||
handleActions: (screenPayload?: GenericActionPayload) => void;
|
||||
}) => {
|
||||
const invalidatePostApiData = () => {
|
||||
return setStringPreference("POST_API_CALLED", "false");
|
||||
};
|
||||
|
||||
const handleClick = (cta?: CtaData) => {
|
||||
if (!cta) return; // Handle case when cta is undefined or null
|
||||
|
||||
if (invalidateCacheWithUrl(cta.url) || shouldInvalidateSavedData(cta)) {
|
||||
invalidatePostApiData();
|
||||
}
|
||||
|
||||
try {
|
||||
switch (cta.type) {
|
||||
case CtaType.DEEP_LINK:
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import throttle from "lodash/throttle";
|
||||
import React, { useCallback, useEffect } from "react";
|
||||
import {
|
||||
EmitterSubscription,
|
||||
NativeEventEmitter,
|
||||
NativeScrollEvent,
|
||||
NativeSyntheticEvent,
|
||||
View,
|
||||
View
|
||||
} from "react-native";
|
||||
import Animated, {
|
||||
useAnimatedStyle,
|
||||
@@ -13,10 +15,12 @@ import Animated, {
|
||||
} from "react-native-reanimated";
|
||||
import Colors from "../../../../../assets/colors/colors";
|
||||
import BaseWidget from "../../../../../components/widgets/BaseWidget";
|
||||
import FAB from "../../../../../components/widgets/fab/FAB";
|
||||
import {
|
||||
BaseActionTypes,
|
||||
GenericActionPayload,
|
||||
} from "../../../../common/actions/GenericAction";
|
||||
import { ConstantCta, ScreenProperties } from "../../../../common/constants";
|
||||
import { AnalyticsEventNameConstants } from "../../../../common/constants/AnalyticsEventsConstant";
|
||||
import { NativeEventNameConstants } from "../../../../common/constants/EventNameConstants";
|
||||
import {
|
||||
@@ -30,27 +34,15 @@ import { Widget } from "../../../../common/interface/widgets/Widget";
|
||||
import { ScreenData } from "../../../../common/interface/widgets/screenData/ScreenData";
|
||||
import { FabWidgetData } from "../../../../common/interface/widgets/widgetData/FabWidgetData";
|
||||
import { NativeDeeplinkNavigatorModule } from "../../../../common/native-module/NativeModules";
|
||||
import {
|
||||
CtaNavigator,
|
||||
extractCtaParameters,
|
||||
} from "../../../../common/navigator/NavigationRouter";
|
||||
import { ScreenState } from "../../../../common/screen/BaseScreen";
|
||||
import { ScreenActionTypes } from "../../../../common/screen/ScreenActionTypes";
|
||||
import styles from "./QuoteOfferScreenStyle";
|
||||
import QuoteOfferErrorScreen from "./error-screen/QuoteOfferErrorScreen";
|
||||
import QuoteOfferShimmerScreen from "./shimmer-screen/QuoteOfferShimmerScreen";
|
||||
import FAB from "../../../../../components/widgets/fab/FAB";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import {
|
||||
CtaNavigator,
|
||||
extractCtaParameters,
|
||||
} from "../../../../common/navigator/NavigationRouter";
|
||||
import {
|
||||
getStringPreference,
|
||||
setStringPreference,
|
||||
} from "../../../../common/utilities/SharedPreferenceUtils";
|
||||
import {
|
||||
invalidateCacheWithUrl,
|
||||
shouldInvalidateSavedData,
|
||||
} from "../../../../common/utilities/CacheUtils";
|
||||
import throttle from "lodash/throttle";
|
||||
import { ConstantCta, ScreenProperties } from "../../../../common/constants";
|
||||
const QuoteOfferScreen = ({
|
||||
ctaData,
|
||||
screenData,
|
||||
@@ -107,14 +99,6 @@ const QuoteOfferScreen = ({
|
||||
|
||||
const { preQuoteId, quoteId, navigatorType } = extractCtaParameters(ctaData);
|
||||
|
||||
const validatePostApiData = async () => {
|
||||
return await getStringPreference("POST_API_CALLED", "string");
|
||||
};
|
||||
|
||||
const invalidatePostApiData = () => {
|
||||
return setStringPreference("POST_API_CALLED", "false");
|
||||
};
|
||||
|
||||
const nativeEventListener = new NativeEventEmitter();
|
||||
let reloadPageEventListener = {} as EmitterSubscription;
|
||||
|
||||
@@ -126,10 +110,6 @@ const QuoteOfferScreen = ({
|
||||
return;
|
||||
}
|
||||
|
||||
if (invalidateCacheWithUrl(cta.url) || shouldInvalidateSavedData(cta)) {
|
||||
invalidatePostApiData();
|
||||
}
|
||||
|
||||
try {
|
||||
switch (cta.type) {
|
||||
case CtaType.DEEP_LINK:
|
||||
@@ -163,19 +143,10 @@ const QuoteOfferScreen = ({
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
let postApiCalled = "false";
|
||||
validatePostApiData()
|
||||
.then(value => {
|
||||
postApiCalled = value;
|
||||
})
|
||||
.then(() => {
|
||||
const screenActionType =
|
||||
postApiCalled === "true"
|
||||
? ScreenActionTypes.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND
|
||||
: preQuoteId
|
||||
? ScreenActionTypes.FETCH_QUOTE_V4
|
||||
: ScreenActionTypes.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND;
|
||||
const data: QuoteOfferRequest = {
|
||||
const screenActionType = preQuoteId
|
||||
? ScreenActionTypes.FETCH_QUOTE_V4
|
||||
: ScreenActionTypes.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND;
|
||||
const data: QuoteOfferRequest = {
|
||||
preQuoteId: preQuoteId ? preQuoteId : undefined,
|
||||
quoteId: quoteId ? quoteId : undefined,
|
||||
};
|
||||
@@ -188,7 +159,6 @@ const QuoteOfferScreen = ({
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
return () => {};
|
||||
}, [ctaData, preQuoteId, quoteId]);
|
||||
|
||||
@@ -197,18 +167,9 @@ const QuoteOfferScreen = ({
|
||||
NativeEventNameConstants.reloadPage,
|
||||
event => {
|
||||
if (event === true) {
|
||||
let postApiCalled = "false";
|
||||
validatePostApiData()
|
||||
.then(value => {
|
||||
postApiCalled = value;
|
||||
})
|
||||
.then(() => {
|
||||
const screenActionType =
|
||||
postApiCalled === "true"
|
||||
? ScreenActionTypes.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND
|
||||
: preQuoteId
|
||||
? ScreenActionTypes.FETCH_QUOTE_V4
|
||||
: ScreenActionTypes.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND;
|
||||
const screenActionType = preQuoteId
|
||||
? ScreenActionTypes.FETCH_QUOTE_V4
|
||||
: ScreenActionTypes.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND;
|
||||
const data: QuoteOfferRequest = {
|
||||
preQuoteId: preQuoteId ? preQuoteId : undefined,
|
||||
quoteId: quoteId ? quoteId : undefined,
|
||||
@@ -222,7 +183,6 @@ const QuoteOfferScreen = ({
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
@@ -42,6 +42,7 @@ export const AnalyticsGlobalErrorTypeConstant = {
|
||||
export const EVENT_NAMES = {
|
||||
CODEPUSH_FETCH_ERROR: "codepush_fetch_error",
|
||||
SCREEN_LOAD_TIME: "react_screen_load_time",
|
||||
INVALID_SCREEN_CTA: "invalid_screen_cta",
|
||||
};
|
||||
|
||||
export const EVENT_PROPERTY_KEYS = {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { GZIP } from "../../../network/NetworkConstant";
|
||||
import { get, post } from "../../../network/NetworkService";
|
||||
import { mergeHeaders } from "../../../network/NetworkUtils";
|
||||
import { ActionMetaData, BaseActionTypes } from "../actions/GenericAction";
|
||||
import { BASE_SCREEN, GI, QUOTE_ID } from "../constants";
|
||||
import { BASE_SCREEN, GI } from "../constants";
|
||||
import {
|
||||
AnalyticsFlowNameConstant,
|
||||
AnalyticsGlobalErrorTypeConstant,
|
||||
@@ -21,10 +21,6 @@ import {
|
||||
import { logToSentry } from "../hooks/useSentryLogging";
|
||||
import { CtaData } from "../interface";
|
||||
import { ScreenData } from "../interface/widgets/screenData/ScreenData";
|
||||
import {
|
||||
getStringPreference,
|
||||
setStringPreference,
|
||||
} from "../utilities/SharedPreferenceUtils";
|
||||
import { ScreenState } from "./BaseScreen";
|
||||
import { ScreenActionTypes } from "./ScreenActionTypes";
|
||||
|
||||
@@ -38,48 +34,22 @@ export const ScreenActionHandler = {
|
||||
switch (screenMetaData.actionType) {
|
||||
case ScreenActionTypes.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND: {
|
||||
let quoteId = screenMetaData.data.quoteId;
|
||||
if (!quoteId) {
|
||||
getQuoteIdFromCache().then(value => {
|
||||
if (!!value) {
|
||||
quoteId = value;
|
||||
return get<ApiResponse<CtaData>>(
|
||||
`v3/quotes/${quoteId}`,
|
||||
getXTargetHeaderInfo(GI.toLocaleUpperCase()),
|
||||
)
|
||||
.then(response => {
|
||||
handleResponseData(setScreenData, response);
|
||||
})
|
||||
.catch(error => {
|
||||
handleErrorData(
|
||||
error,
|
||||
setScreenData,
|
||||
screenMetaData,
|
||||
AnalyticsMethodNameConstant.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND,
|
||||
ScreenActionTypes.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND,
|
||||
);
|
||||
});
|
||||
}
|
||||
return;
|
||||
});
|
||||
} else {
|
||||
return get<ApiResponse<CtaData>>(
|
||||
return get<ApiResponse<CtaData>>(
|
||||
`v3/quotes/${quoteId}`,
|
||||
getXTargetHeaderInfo(GI.toLocaleUpperCase()),
|
||||
)
|
||||
.then(response => {
|
||||
handleResponseData(setScreenData, response);
|
||||
})
|
||||
.catch(error => {
|
||||
handleErrorData(
|
||||
error,
|
||||
setScreenData,
|
||||
screenMetaData,
|
||||
AnalyticsMethodNameConstant.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND,
|
||||
ScreenActionTypes.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND,
|
||||
);
|
||||
});
|
||||
}
|
||||
return;
|
||||
.then(response => {
|
||||
handleResponseData(setScreenData, response);
|
||||
})
|
||||
.catch(error => {
|
||||
handleErrorData(
|
||||
error,
|
||||
setScreenData,
|
||||
screenMetaData,
|
||||
AnalyticsMethodNameConstant.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND,
|
||||
ScreenActionTypes.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND,
|
||||
);
|
||||
});
|
||||
}
|
||||
case ScreenActionTypes.FETCH_QUOTE_V3: {
|
||||
return post<ApiResponse<CtaData>>(
|
||||
@@ -91,18 +61,8 @@ export const ScreenActionHandler = {
|
||||
if (screenData?.screenState) {
|
||||
screenData.screenState = ScreenState.LOADING;
|
||||
}
|
||||
setPostApiData();
|
||||
if (response.data) {
|
||||
const cta = response.data as CtaData;
|
||||
let quoteId;
|
||||
cta?.parameters?.forEach(item => {
|
||||
if (item.key === "quoteId") {
|
||||
quoteId = item.value;
|
||||
}
|
||||
});
|
||||
if (!!quoteId) {
|
||||
storeQuoteId(quoteId);
|
||||
}
|
||||
// By default routing is happening via Base screen hence below navigate sends the cta there to get routed to specific screenName based on Cta
|
||||
if (!!cta.analyticsEventProperties) {
|
||||
sendAsAnalyticsEvent(cta.analyticsEventProperties);
|
||||
@@ -159,23 +119,11 @@ export const ScreenActionHandler = {
|
||||
screenState: ScreenState.LOADING,
|
||||
});
|
||||
}
|
||||
setPostApiData();
|
||||
if (response) {
|
||||
const updatedScreenData: ScreenData = {
|
||||
...(response.data as ScreenData),
|
||||
screenState: ScreenState.LOADED,
|
||||
};
|
||||
let quoteId;
|
||||
updatedScreenData?.screenMetaData?.screenProperties?.forEach(
|
||||
item => {
|
||||
if (item.key === QUOTE_ID) {
|
||||
quoteId = item.value;
|
||||
}
|
||||
},
|
||||
);
|
||||
if (!!quoteId) {
|
||||
storeQuoteId(quoteId);
|
||||
}
|
||||
// If redirectionCta is present and screenWidgets is not present then navigate to Base screen to get routed to specific screenName based on Cta
|
||||
if (
|
||||
!!updatedScreenData.screenMetaData?.redirectionCta &&
|
||||
@@ -240,18 +188,6 @@ export const ScreenActionHandler = {
|
||||
},
|
||||
};
|
||||
|
||||
const setPostApiData = () => {
|
||||
return setStringPreference("POST_API_CALLED", "true");
|
||||
};
|
||||
|
||||
const storeQuoteId = (quoteId: string) => {
|
||||
return setStringPreference("QUOTE_ID", quoteId);
|
||||
};
|
||||
|
||||
const getQuoteIdFromCache = async () => {
|
||||
return await getStringPreference("QUOTE_ID", "string");
|
||||
};
|
||||
|
||||
const handleResponseData = (
|
||||
setScreenData: Dispatch<SetStateAction<ScreenData | null>>,
|
||||
response: any,
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||
import { BUY_INSURANCE_SCREEN, COMPARE_PLAN_SCREEN, QUOTE_OFFER_SCREEN } from "../constants/ScreenNameConstants";
|
||||
import { ScreenData } from "../interface/widgets/screenData/ScreenData";
|
||||
import { NetworkConnectorModule } from "../../common/native-module/NativeModules";
|
||||
import { BUY_INSURANCE_SCREEN, COMPARE_PLAN_SCREEN, QUOTE_OFFER_SCREEN } from "../constants/ScreenNameConstants";
|
||||
import { BUILD_CONFIG_DETAILS } from "../constants/StringConstant";
|
||||
import { CtaData } from "../interface";
|
||||
import { ScreenData } from "../interface/widgets/screenData/ScreenData";
|
||||
|
||||
export const getScreenDataFromCache = async (
|
||||
key: string
|
||||
@@ -88,24 +87,3 @@ export const isScreenWhiteListedForCaching = (
|
||||
};
|
||||
|
||||
export const screensWithCachingDisabled = [BUY_INSURANCE_SCREEN, QUOTE_OFFER_SCREEN, COMPARE_PLAN_SCREEN];
|
||||
|
||||
|
||||
export const invalidateCacheWithUrl = (
|
||||
screenUrl: string | null | undefined
|
||||
) => {
|
||||
return screenUrlCacheList.includes(screenUrl || "");
|
||||
};
|
||||
|
||||
export const screenUrlCacheList = ["gi/insurance_container/pre_quote_journey", "react_native/gi/insurance_container/pre_quote_journey"];
|
||||
|
||||
|
||||
export const shouldInvalidateSavedData = (
|
||||
cta: CtaData
|
||||
): boolean => {
|
||||
cta.parameters?.forEach((item) => {
|
||||
if (item.key === 'invalidateCache' && item.value === 'true') {
|
||||
return true;
|
||||
}
|
||||
})
|
||||
return false;
|
||||
};
|
||||
|
||||
@@ -29,10 +29,6 @@ import { getQuoteIdFromCta, getQuoteIdFromScreenMetaData } from "../../utilities
|
||||
import { updateValueByKeyPath } from "../../utilities/MiscUtils";
|
||||
import { parseValue } from "../../utilities/SerializerUtil";
|
||||
import { WidgetActionTypes } from "./WidgetActionTypes";
|
||||
import {
|
||||
getStringPreference,
|
||||
setStringPreference,
|
||||
} from "../../utilities/SharedPreferenceUtils";
|
||||
|
||||
const WidgetActionHandler = {
|
||||
handleWidgetAction: (
|
||||
@@ -136,32 +132,14 @@ const WidgetActionHandler = {
|
||||
case WidgetActionTypes.PATCH_QUOTE_V2: {
|
||||
let quoteId = getQuoteIdFromCta(ctaData) ?? getQuoteIdFromScreenMetaData(screenData?.screenMetaData);
|
||||
const requestData: SumInsuredRequestData = widgetMetaData.data;
|
||||
if (!quoteId) {
|
||||
getQuoteIdFromCache().then((value) => {
|
||||
if (!!value) {
|
||||
quoteId = value;
|
||||
return updateSumInsuredData(requestData, quoteId!!)
|
||||
.then((response) => {})
|
||||
.catch((error) => {
|
||||
const errorEvent: AnalyticsEvent = {
|
||||
name: AnalyticsEventNameConstants.PATCH_QUOTE_V2
|
||||
};
|
||||
sendAsAnalyticsEvent(errorEvent);
|
||||
});
|
||||
}
|
||||
return;
|
||||
return updateSumInsuredData(requestData, quoteId!!)
|
||||
.then((response) => {})
|
||||
.catch((error) => {
|
||||
const errorEvent: AnalyticsEvent = {
|
||||
name: AnalyticsEventNameConstants.PATCH_QUOTE_V2
|
||||
};
|
||||
sendAsAnalyticsEvent(errorEvent);
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
return updateSumInsuredData(requestData, quoteId!!)
|
||||
.then((response) => {})
|
||||
.catch((error) => {
|
||||
const errorEvent: AnalyticsEvent = {
|
||||
name: AnalyticsEventNameConstants.PATCH_QUOTE_V2
|
||||
};
|
||||
sendAsAnalyticsEvent(errorEvent);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
case WidgetActionTypes.FINAL_PATCH_CALL: {
|
||||
@@ -169,7 +147,6 @@ const WidgetActionHandler = {
|
||||
...screenData,
|
||||
screenState: ScreenState.OVERLAY,
|
||||
});
|
||||
invalidatePostApiData();
|
||||
let quoteId = getQuoteIdFromCta(ctaData) ?? getQuoteIdFromScreenMetaData(screenData?.screenMetaData);
|
||||
const requestData: SumInsuredRequestData = (
|
||||
widgetMetaData?.data as FinalPatchCallRequestBody
|
||||
@@ -177,27 +154,6 @@ const WidgetActionHandler = {
|
||||
const nextPageCta: CtaData = (
|
||||
widgetMetaData?.data as FinalPatchCallRequestBody
|
||||
).nextPageCta;
|
||||
if (!quoteId) {
|
||||
getQuoteIdFromCache().then((value) => {
|
||||
if (!!value) {
|
||||
quoteId = value;
|
||||
return updateSumInsuredData(requestData, quoteId!!)
|
||||
.then((response) => {
|
||||
handleResponseData(nextPageCta, setScreenData, screenData);
|
||||
})
|
||||
.catch((error) => {
|
||||
handleErrorData(
|
||||
error,
|
||||
setScreenData,
|
||||
widgetMetaData,
|
||||
AnalyticsMethodNameConstant.FINAL_PATCH_CALL,
|
||||
screenData
|
||||
);
|
||||
});
|
||||
}
|
||||
return;
|
||||
});
|
||||
} else {
|
||||
return updateSumInsuredData(requestData, quoteId!!)
|
||||
.then((response) => {
|
||||
handleResponseData(nextPageCta, setScreenData, screenData);
|
||||
@@ -211,8 +167,6 @@ const WidgetActionHandler = {
|
||||
screenData
|
||||
);
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
case WidgetActionTypes.SHOW_LOADER: {
|
||||
@@ -280,14 +234,6 @@ const WidgetActionHandler = {
|
||||
},
|
||||
};
|
||||
|
||||
const getQuoteIdFromCache = async () => {
|
||||
return await getStringPreference("QUOTE_ID", "string");
|
||||
};
|
||||
|
||||
const invalidatePostApiData = () => {
|
||||
return setStringPreference("POST_API_CALLED", "false");
|
||||
};
|
||||
|
||||
const handleResponseData = (
|
||||
nextPageCta: CtaData,
|
||||
setScreenData: Dispatch<SetStateAction<ScreenData | null>>,
|
||||
|
||||
@@ -9,11 +9,6 @@ import { ModalView } from "../../App/common/interface/modals/ModalView";
|
||||
import { GetModalView } from "../../App/common/modals/modalViewResolver";
|
||||
import { NativeDeeplinkNavigatorModule } from "../../App/common/native-module/NativeModules";
|
||||
import styles from "../../App/common/styles/BaseBottomSheetComponentStyles";
|
||||
import {
|
||||
invalidateCacheWithUrl,
|
||||
shouldInvalidateSavedData,
|
||||
} from "../../App/common/utilities/CacheUtils";
|
||||
import { setStringPreference } from "../../App/common/utilities/SharedPreferenceUtils";
|
||||
import WidgetActionHandler from "../../App/common/widgets/widget-actions/WidgetActionHandler";
|
||||
import { WidgetActionTypes } from "../../App/common/widgets/widget-actions/WidgetActionTypes";
|
||||
|
||||
@@ -40,14 +35,7 @@ const BaseBottomSheetComponent = ({
|
||||
}, BOTTOMSHEET_ANIMATION_DURATION);
|
||||
};
|
||||
|
||||
const invalidatePostApiData = () => {
|
||||
return setStringPreference("POST_API_CALLED", "false");
|
||||
};
|
||||
|
||||
const handleModalClick = (cta: CtaData) => {
|
||||
if (invalidateCacheWithUrl(cta.url) || shouldInvalidateSavedData(cta)) {
|
||||
invalidatePostApiData();
|
||||
}
|
||||
switch (cta?.type) {
|
||||
case CtaType.DISMISS_MODAL:
|
||||
if (!!cta?.analyticsEventProperties) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import codePush from "react-native-code-push";
|
||||
import App from "./App";
|
||||
|
||||
let codePushOptions = {
|
||||
installMode: codePush.InstallMode.IMMEDIATE,
|
||||
installMode: codePush.InstallMode.ON_NEXT_RESTART,
|
||||
checkFrequency: codePush.CheckFrequency.MANUAL,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user