import React from 'react'; import { StyleSheet, TextStyle, View, ViewStyle } from 'react-native'; import { useStyles, useWidget, useWidgetInteractions } from '../../hooks'; import { ComponentStyleProp, LLComponentStyleFn } from '../../types'; import { LLWidgetActionInfo, LLWidgetActionInfoProps } from '../LLWidgetFooter'; import { LLTextAskWidgetSubmitButton } from './LLTextAskWidgetSubmitButton'; import { LLText } from '../LLText/LLText'; export type LLTextAskWidgetActionInfoStyles = { container: ViewStyle; confirmMessageText: TextStyle; }; export type LLTextAskWidgetActionInfoProps = ComponentStyleProp & Omit & { ActionInfoComponent?: typeof LLWidgetActionInfo; ActionInfoComponentStyles?: LLWidgetActionInfoProps['styles']; }; export function LLTextAskWidgetActionInfo({ widgetId, styles: stylesProp, ActionInfoComponent = LLWidgetActionInfo, ActionInfoComponentStyles, ...props }: LLTextAskWidgetActionInfoProps) { const styles = useStyles({ componentStylesFn: getTextAskWidgetActionInfoStyles, stylesProp, }); const widget = useWidget({ widgetId }); const widgetInteractions = useWidgetInteractions({ widgetId }); const widgetInteraction = widgetInteractions?.[0]; return ( {widgetInteraction && !!widget.confirmation_message && ( {widget.confirmation_message} )} ); } const getTextAskWidgetActionInfoStyles: LLComponentStyleFn< LLTextAskWidgetActionInfoStyles > = ({ theme }) => StyleSheet.create({ container: { display: 'flex', flexDirection: 'column', justifyContent: 'flex-start', }, confirmMessageText: { paddingLeft: 16, fontSize: 12, lineHeight: 12, marginBottom: 8, color: theme.text, }, });