TP-61357: Introducing ReactNative | Insurance - Quote page experiments (#10199)
Co-authored-by: Shivam Goyal <shivam.goyal@navi.com>
This commit is contained in:
57
App.tsx
Normal file
57
App.tsx
Normal file
@@ -0,0 +1,57 @@
|
||||
import { Component } from "react";
|
||||
import codePush from "react-native-code-push";
|
||||
import { CtaData } from "./App/common/interface";
|
||||
import RnApp from "./App/common/navigator/RnAppCreator";
|
||||
import { getBuildConfigDetails, setBuildConfigDetails } from "./App/common/utilities/CacheUtils";
|
||||
import { logToSentry } from "./App/common/hooks/useSentryLogging";
|
||||
|
||||
export default class App extends Component<{}> {
|
||||
checkForUpdates = () => {
|
||||
let flavor: string | undefined
|
||||
getBuildConfigDetails().then((res) => {
|
||||
flavor = res?.baseUrl
|
||||
})
|
||||
codePush.sync({
|
||||
updateDialog: flavor && flavor === "QA" ? {appendReleaseDescription: true} : {appendReleaseDescription: false},
|
||||
installMode: codePush.InstallMode.IMMEDIATE,
|
||||
mandatoryInstallMode: codePush.InstallMode.IMMEDIATE,
|
||||
});
|
||||
};
|
||||
|
||||
getInitialCta = (): CtaData | undefined => {
|
||||
const { CtaData } = this.props as any;
|
||||
|
||||
if (!CtaData) {
|
||||
logToSentry(
|
||||
`CtaData is missing or invalid: ${CtaData} | MethodName: getInitialCta`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const cta = JSON.parse(CtaData) as CtaData;
|
||||
return cta;
|
||||
} catch (error) {
|
||||
logToSentry(
|
||||
`Error parsing CtaData: ${CtaData} | Error: ${error} | MethodName: getInitialCta`
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
override componentDidMount(): void {
|
||||
setBuildConfigDetails()
|
||||
this.checkForUpdates();
|
||||
}
|
||||
|
||||
override render() {
|
||||
const cta = this.getInitialCta();
|
||||
if (!!cta) {
|
||||
return RnApp.create(cta);
|
||||
} else {
|
||||
// return error screen
|
||||
}
|
||||
}
|
||||
}
|
||||
//return RnNavigator.navigate(screenBundle);
|
||||
Reference in New Issue
Block a user