import React, { forwardRef } from 'react'; import { useWatch } from 'react-hook-form'; import type { Control } from 'react-hook-form'; import { TooltipAnchor, SendIcon, CallIcon } from '~/components'; import { useLocalize } from '~/hooks'; import { cn } from '~/utils'; type ButtonProps = { disabled: boolean; control: Control<{ text: string }>; }; const ActionButton = forwardRef( ( props: { disabled: boolean; icon: React.ReactNode; tooltip: string; testId: string; }, ref: React.ForwardedRef, ) => { return ( {props.icon} } /> ); }, ); const SendButton = forwardRef((props: ButtonProps, ref: React.ForwardedRef) => { const localize = useLocalize(); const { text } = useWatch({ control: props.control }); const buttonProps = text ? { icon: , tooltip: localize('com_nav_send_message'), testId: 'send-button', } : { icon: , tooltip: localize('com_nav_call'), testId: 'call-button', }; return ; }); SendButton.displayName = 'SendButton'; export default SendButton;