Files
super-app/components/reusable/cta-button/CtaButton.tsx
Kshitij Pramod Ghongadi feb5b7d3fb TP-61032 | RN Quote PageTesting fixes (#10203)
Co-authored-by: Raaj Gopal <raaj.gopal@navi.com>
2024-03-28 06:42:34 +00:00

40 lines
1.1 KiB
TypeScript

import { TouchableHighlight, ViewStyle } from "react-native";
import { Lottie } from "../../../App/common/constants/StringConstant";
import { ButtonState } from "../../../App/common/interface/widgets/widgetData/FooterWithCardWidgetData";
import { LottieFieldData } from "../../../App/common/interface/widgets/widgetData/TitleWidgetData";
import { StyledLottie } from "../../widgets/styled-lottie/StyledLottie";
import styles from "./CtaButtonStyle";
const CtaButton = ({
onPress,
style,
children,
state,
}: {
onPress?: () => void;
style?: ViewStyle;
children?: React.ReactNode;
state?: ButtonState;
}) => {
const loaderData: LottieFieldData = {
url: Lottie.FOOTER_LOADER_URL,
loop: true,
lottieStyle: styles.loaderLottieStyle,
};
return (
<TouchableHighlight
onPress={onPress}
disabled={state === ButtonState.DISABLED || state === ButtonState.LOADING}
style={[styles.footerButtonContainer, style]}
>
{state === ButtonState.LOADING ? (
<StyledLottie lottieFieldData={loaderData} />
) : (
children
)}
</TouchableHighlight>
);
};
export default CtaButton;