diff --git a/src/components/FloatingWhatsApp.tsx b/src/components/FloatingWhatsApp.tsx index c2745d3..c47190e 100644 --- a/src/components/FloatingWhatsApp.tsx +++ b/src/components/FloatingWhatsApp.tsx @@ -36,6 +36,8 @@ export interface FloatingWhatsAppProps { statusMessage?: string /** Text inside the chat box */ chatMessage?: string + /** Text that will be submitted with the input value */ + defaultMessage?: string /** Input placeholder */ placeholder?: string @@ -86,6 +88,7 @@ export function FloatingWhatsApp({ avatar = dummyAvatar, statusMessage = 'Typically replies within 1 hour', chatMessage = 'Hello there! 🤝 \nHow can we help?', + defaultMessage, placeholder = 'Type a message..', messageDelay = 2, @@ -179,7 +182,7 @@ export function FloatingWhatsApp({ event.preventDefault() if (!inputRef.current?.value) return - window.open(`https://api.whatsapp.com/send/?phone=${phoneNumber}&text=${inputRef.current.value}`) + window.open(`https://api.whatsapp.com/send/?phone=${phoneNumber}&text=${defaultMessage ?? ''}${inputRef.current.value}`) if (onSubmit) onSubmit(event, inputRef.current.value) inputRef.current.value = '' } diff --git a/src/stories/FloatingWhatsapp.stories.tsx b/src/stories/FloatingWhatsapp.stories.tsx index 443a930..a1222f8 100644 --- a/src/stories/FloatingWhatsapp.stories.tsx +++ b/src/stories/FloatingWhatsapp.stories.tsx @@ -21,7 +21,8 @@ const Template: ComponentStory = (args) =>