diff --git a/app/javascript/react-components/src/components/ChatwootConversation.jsx b/app/javascript/react-components/src/components/ChatwootConversation.jsx new file mode 100644 index 000000000..6af23cfc1 --- /dev/null +++ b/app/javascript/react-components/src/components/ChatwootConversation.jsx @@ -0,0 +1,64 @@ +import { useState, useCallback } from 'react'; +import { useChatwoot } from './ChatwootProvider'; +import { ChatwootMessageListWrapper } from './ChatwootMessageListWrapper'; + +export const ChatwootConversation = ({ + conversationId, + className = '', + style = {}, + onError = null, + onLoad = null, + ...otherProps +}) => { + // Ensure we're inside a ChatwootProvider + useChatwoot(); // This will throw if not in Provider context + + const [isLoaded, setIsLoaded] = useState(false); + const [error, setError] = useState(null); + + // Validate required props + if (!conversationId) { + throw new Error('ChatwootConversation: conversationId is required'); + } + + const handleLoad = useCallback(() => { + setIsLoaded(true); + setError(null); + onLoad?.(); + }, [onLoad]); + + const handleError = useCallback((err) => { + setError(err.message); + setIsLoaded(false); + onError?.(err); + }, [onError]); + + return ( +