Files
super-app/App/Container/Navi-Insurance/screen/quote-apology-screen/QuoteApologyScreen.tsx
2024-03-27 15:06:03 +00:00

79 lines
2.6 KiB
TypeScript

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 { AppImage } from "../../../../../components/AppImage";
import {
ImageName,
QUOTE_APOLOGY_BUTTON,
QUOTE_APOLOGY_SUBTITLE,
QUOTE_APOLOGY_TITLE,
} from "../../../../common/constants/StringConstant";
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";
const QuoteApologyScreen = ({
ctaData,
screenData,
handleActions,
}: {
ctaData: CtaData;
screenData: ScreenData | null;
handleActions: (screenPayload?: GenericActionPayload) => void;
}) => {
const handleClick = (cta?: CtaData) => {
if (!cta) return; // Handle case when cta is undefined or null
try {
switch (cta.type) {
case CtaType.DEEP_LINK:
case CtaType.USE_ROOT_DEEPLINK_NAVIGATOR:
NativeDeeplinkNavigatorModule.navigateToNaviInsuranceDeeplinkNavigator(
JSON.stringify(cta)
);
break;
default:
NativeDeeplinkNavigatorModule.navigateToNaviDeeplinkNavigator(
JSON.stringify(cta)
);
break;
}
} catch (error) {
// #TODO: Handle the error gracefully using Sentry.
console.error("Error while navigating to deep link:", error);
}
};
const onPress = () => {
handleClick && handleClick(ConstantCta.QUOTE_APOLOGY_FOOTER_BUTTON);
};
return (
<View style={styles.container}>
<View>
<StaticHeader
handleClick={handleClick}
leftIconCta={ConstantCta.STATIC_HEADER_LEFT_ICON_CTA}
rightIconCta={ConstantCta.STATIC_HEADER_RIGHT_ICON_CTA}
/>
<View style={styles.headerBorder} />
</View>
<View style={styles.centerContent}>
{AppImage(ImageName.QUOTE_APOLOGY_ICON, styles.centerIcon)}
<Text style={styles.title}>{QUOTE_APOLOGY_TITLE}</Text>
<Text style={styles.subtitle}>{QUOTE_APOLOGY_SUBTITLE}</Text>
</View>
<TouchableOpacity
onPress={onPress}
style={styles.footerButton}
activeOpacity={1}
>
<Text style={styles.buttonText}>{QUOTE_APOLOGY_BUTTON}</Text>
</TouchableOpacity>
</View>
);
};
export default QuoteApologyScreen;